Skip to content

Commit 1a0226a

Browse files
committed
Move Cache to from namespace utils to io.
1 parent a131997 commit 1a0226a

File tree

3 files changed

+16
-16
lines changed

3 files changed

+16
-16
lines changed

src/wmtk/io/Cache.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ std::string number_to_hex(long long l)
2828
return fmt::format("{0:x}", l);
2929
}
3030

31-
namespace wmtk::utils {
31+
namespace wmtk::io {
3232

3333
std::filesystem::path Cache::create_unique_directory(
3434
const std::string& prefix,
@@ -228,4 +228,4 @@ bool Cache::import_cache(const std::filesystem::path& import_location)
228228
return true;
229229
}
230230

231-
} // namespace wmtk::utils
231+
} // namespace wmtk::io

src/wmtk/io/Cache.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#include <map>
55
#include <wmtk/Mesh.hpp>
66

7-
namespace wmtk::utils {
7+
namespace wmtk::io {
88

99

1010
class Cache
@@ -124,4 +124,4 @@ class Cache
124124
inline static const std::string m_cache_content_name =
125125
"cache_contents"; // name of the json file used for import/export
126126
};
127-
} // namespace wmtk::utils
127+
} // namespace wmtk::io

tests/test_io.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
#include <wmtk/Mesh.hpp>
22
#include <wmtk/TetMesh.hpp>
33
#include <wmtk/TriMesh.hpp>
4+
#include <wmtk/io/Cache.hpp>
45
#include <wmtk/io/HDF5Writer.hpp>
56
#include <wmtk/io/MeshReader.hpp>
67
#include <wmtk/io/ParaviewWriter.hpp>
7-
#include <wmtk/io/Cache.hpp>
88
#include <wmtk/utils/mesh_utils.hpp>
99

1010
#include <wmtk/operations/OperationFactory.hpp>
@@ -156,14 +156,14 @@ TEST_CASE("attribute_after_split", "[io]")
156156
m.serialize(writer);
157157
}
158158

159-
TEST_CASE("cache_init", "[cache]")
159+
TEST_CASE("cache_init", "[cache][io]")
160160
{
161161
const fs::path dir = std::filesystem::current_path();
162162
const std::string prefix = "wmtk_cache";
163163

164164
fs::path cache_dir;
165165
{
166-
utils::Cache cache(prefix, dir);
166+
io::Cache cache(prefix, dir);
167167
cache_dir = cache.get_cache_path();
168168

169169
CHECK(fs::exists(cache_dir));
@@ -174,12 +174,12 @@ TEST_CASE("cache_init", "[cache]")
174174
CHECK_FALSE(fs::exists(cache_dir));
175175
}
176176

177-
TEST_CASE("cache_files", "[cache]")
177+
TEST_CASE("cache_files", "[cache][io]")
178178
{
179179
fs::path filepath;
180180
std::string file_name = "my_new_file";
181181
{
182-
utils::Cache cache("wmtk_cache", fs::current_path());
182+
io::Cache cache("wmtk_cache", fs::current_path());
183183

184184
filepath = cache.create_unique_file(file_name, ".txt");
185185

@@ -194,9 +194,9 @@ TEST_CASE("cache_files", "[cache]")
194194
CHECK_FALSE(fs::exists(filepath));
195195
}
196196

197-
TEST_CASE("cache_read_write_mesh", "[cache]")
197+
TEST_CASE("cache_read_write_mesh", "[cache][io]")
198198
{
199-
utils::Cache cache("wmtk_cache", fs::current_path());
199+
io::Cache cache("wmtk_cache", fs::current_path());
200200
TriMesh mesh = tests::single_triangle();
201201

202202
const std::string name = "cached_mesh";
@@ -208,17 +208,17 @@ TEST_CASE("cache_read_write_mesh", "[cache]")
208208
CHECK_THROWS(cache.read_mesh("some_file_that_does_not_exist"));
209209
}
210210

211-
TEST_CASE("cache_export_import", "[cache]")
211+
TEST_CASE("cache_export_import", "[cache][io]")
212212
{
213213
const fs::path export_location =
214-
utils::Cache::create_unique_directory("wmtk_cache_export", fs::current_path());
214+
io::Cache::create_unique_directory("wmtk_cache_export", fs::current_path());
215215

216216
const std::vector<std::string> file_names = {"a", "b", "c"};
217217

218218
// create cache
219219
fs::path first_cache_path;
220220
{
221-
utils::Cache cache("wmtk_cache", fs::current_path());
221+
io::Cache cache("wmtk_cache", fs::current_path());
222222
// generate some files
223223
for (const std::string& name : file_names) {
224224
const fs::path p = cache.create_unique_file(name, ".txt");
@@ -239,7 +239,7 @@ TEST_CASE("cache_export_import", "[cache]")
239239

240240
// create new cache
241241
{
242-
utils::Cache cache("wmtk_cache", fs::current_path());
242+
io::Cache cache("wmtk_cache", fs::current_path());
243243
// import the previously exported
244244
CHECK(cache.import_cache(export_location));
245245

@@ -254,7 +254,7 @@ TEST_CASE("cache_export_import", "[cache]")
254254

255255
// try to import even though the cache contains a file
256256
{
257-
utils::Cache cache("wmtk_cache", fs::current_path());
257+
io::Cache cache("wmtk_cache", fs::current_path());
258258
cache.create_unique_file("some_file", "");
259259
// import should not work if the cache already contains files
260260
CHECK_FALSE(cache.import_cache(export_location));

0 commit comments

Comments
 (0)