summaryrefslogtreecommitdiffhomepage
path: root/test
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2023-11-05 07:39:06 +0100
committerStanislaw Halik <sthalik@misaki.pl>2023-11-05 07:39:06 +0100
commit98da53beb78d9a617a1c66b404e9a7d8469a443a (patch)
treee708c5133ea5705d402b31b16aadcb24ec25b6c1 /test
parent8cd318bc55e9d1588307999618a0d8bef09f9f68 (diff)
a
Diffstat (limited to 'test')
-rw-r--r--test/CMakeLists.txt6
-rw-r--r--test/json/frameset-header.json9
-rw-r--r--test/wall-atlas.cpp38
3 files changed, 53 insertions, 0 deletions
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index 2c1ce2ff..897268f3 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -26,3 +26,9 @@ file(GLOB files "save/*.dat" CONFIGURE_ARGS)
foreach(file ${files})
install(FILES "${file}" DESTINATION "${save-dir}")
endforeach()
+
+set(json-dir "${CMAKE_BINARY_DIR}/test/json")
+file(GLOB files "json/*.json" CONFIGURE_ARGS)
+foreach(file ${files})
+ install(FILES "${file}" DESTINATION "${json-dir}")
+endforeach()
diff --git a/test/json/frameset-header.json b/test/json/frameset-header.json
new file mode 100644
index 00000000..8b32cabc
--- /dev/null
+++ b/test/json/frameset-header.json
@@ -0,0 +1,9 @@
+{
+ "name": "foo",
+ "depth": 42,
+ "framesets": {
+ "w": {},
+ "n": {}
+ },
+ "frames": []
+}
diff --git a/test/wall-atlas.cpp b/test/wall-atlas.cpp
index 61f252b7..b1cdd8d6 100644
--- a/test/wall-atlas.cpp
+++ b/test/wall-atlas.cpp
@@ -1,16 +1,54 @@
#include "test/app.hpp"
#include "src/wall-atlas.hpp"
+#include "serialize/wall-atlas.hpp"
+#include "serialize/json-helper.hpp"
+#include "loader/loader.hpp"
+#include <algorithm>
+#include <Corrade/Utility/Path.h>
namespace floormat {
+namespace ranges = std::ranges;
+namespace test = floormat::Serialize::wall_test;
+
namespace {
+void test_atlas_header(StringView path)
+{
+ auto j = json_helper::from_json_(Path::join(path, "frameset-header.json"_s));
+ wall_atlas_def def;
+ test::read_atlas_header(j, def);
+
+ fm_assert(def.info.name == "foo"_s);
+ fm_assert(def.info.depth == 42);
+ fm_assert(def.frameset_count == 2);
+
+ constexpr auto none = (uint8_t)-1;
+ enum : uint8_t { N, E, S, W, };
+
+ fm_assert(def.frameset_indexes[N] == 0 || def.frameset_indexes[N] == 1);
+ fm_assert(def.frameset_indexes[E] == none);
+ fm_assert(def.frameset_indexes[S] == none);
+ if (def.frameset_indexes[N] == 0)
+ fm_assert(def.frameset_indexes[W] == 1);
+ else if (def.frameset_indexes[N] == 1)
+ fm_assert(def.frameset_indexes[W] == 0);
+
+ std::fputs("", stdout);
+}
} // namespace
void test_app::test_wall_atlas()
{
+ fm_assert(Path::exists(Path::join(loader.TEMP_PATH, "CMakeCache.txt")));
+ const auto path = Path::join(loader.TEMP_PATH, "test/json"_s);
+ fm_assert(Path::isDirectory(path));
+
+ test_atlas_header(path);
}
+
+
} // namespace floormat