diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/CMakeLists.txt | 4 | ||||
-rw-r--r-- | test/json/wall-atlas-01_header.json | 7 | ||||
-rw-r--r-- | test/json/wall-atlas-02_groups.json | 12 | ||||
-rw-r--r-- | test/json/wall-atlas-header1.json | 9 | ||||
-rw-r--r-- | test/wall-atlas.cpp | 58 |
5 files changed, 52 insertions, 38 deletions
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 3764142f..e5fc6435 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -20,12 +20,12 @@ endif() fm_add_install_executable(${self}) -file(GLOB files "save/*.dat" CONFIGURE_ARGS) +file(GLOB files "${CMAKE_CURRENT_SOURCE_DIR}/save/*.dat" CONFIGURE_ARGS) foreach(file ${files}) install(FILES "${file}" DESTINATION "${CMAKE_BINARY_DIR}/test/save") endforeach() -file(GLOB files "json/*.json" CONFIGURE_ARGS) +file(GLOB files "${CMAKE_CURRENT_SOURCE_DIR}/json/*.json" CONFIGURE_ARGS) foreach(file ${files}) install(FILES "${file}" DESTINATION "${CMAKE_BINARY_DIR}/test/json") endforeach() diff --git a/test/json/wall-atlas-01_header.json b/test/json/wall-atlas-01_header.json new file mode 100644 index 00000000..6859c6da --- /dev/null +++ b/test/json/wall-atlas-01_header.json @@ -0,0 +1,7 @@ +{ + "name": "foo", + "depth": 42, + "frames": [], + "n": {}, + "w": {} +} diff --git a/test/json/wall-atlas-02_groups.json b/test/json/wall-atlas-02_groups.json new file mode 100644 index 00000000..cf342eac --- /dev/null +++ b/test/json/wall-atlas-02_groups.json @@ -0,0 +1,12 @@ +{ + "name": "foo", + "depth": 42, + "frames": [], + "n": {}, + "w": { + "wall": {}, + "side": { + "pixel-size": "42 x 192" + } + } +} diff --git a/test/json/wall-atlas-header1.json b/test/json/wall-atlas-header1.json deleted file mode 100644 index a5591245..00000000 --- a/test/json/wall-atlas-header1.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "name": "foo", - "depth": 42, - "directions": { - "w": {}, - "n": {} - }, - "frames": [] -} diff --git a/test/wall-atlas.cpp b/test/wall-atlas.cpp index 85f1e3f4..f5ddf2b5 100644 --- a/test/wall-atlas.cpp +++ b/test/wall-atlas.cpp @@ -23,44 +23,47 @@ StringView json_path() return path; } -void test_read_info(StringView filename) +void test_read_header(StringView filename) { const auto jroot = json_helper::from_json_(Path::join(json_path(), filename)); - fm_assert(jroot.contains("directions"s)); auto info = read_info_header(jroot); fm_assert(info.name == "foo"_s); fm_assert(info.depth == 42); - -#if 0 - fm_assert(def.dir_indexes[N] == 0 || def.dir_indexes[N] == 1); - fm_assert(def.dir_indexes[E] == none); - fm_assert(def.dir_indexes[S] == none); - - if (def.dir_indexes[N] == 0) - fm_assert(def.dir_indexes[W] == 1); - else if (def.dir_indexes[N] == 1) - fm_assert(def.dir_indexes[W] == 0); - else - fm_assert(false); -#endif } void test_read_empty_direction(StringView filename) { const auto jroot = json_helper::from_json_(Path::join(json_path(), filename)); - test_read_info(filename); + test_read_header(filename); fm_assert(!jroot.empty()); - fm_assert(jroot.contains("directions"s)); - const auto& jdir = jroot["directions"s]; - fm_assert( jdir.contains("n"s) ); - fm_assert(!jdir.contains("e"s) ); - fm_assert(!jdir.contains("s"s) ); - fm_assert( jdir.contains("w"s) ); + fm_assert( jroot.contains("n"s) ); + fm_assert(!jroot.contains("e"s) ); + fm_assert(!jroot.contains("s"s) ); + fm_assert( jroot.contains("w"s) ); + + fm_assert(jroot["n"s].is_object() && jroot["n"s].empty()); + fm_assert(jroot["w"s].is_object() && jroot["w"s].empty()); +} + +void test_read_groups(StringView filename) +{ + const auto jroot = json_helper::from_json_(Path::join(json_path(), filename)); + read_info_header(jroot); - { auto g = read_group_metadata(jdir["w"]); - fm_assert(g.is_empty()); - } + fm_assert(jroot["depth"s] == 42); + fm_assert( jroot.contains("n"s) ); + fm_assert(!jroot.contains("e"s) ); + fm_assert(!jroot.contains("s"s) ); + fm_assert( jroot.contains("w"s) ); + fm_assert(jroot["n"s].is_object() && jroot["n"s].empty()); + fm_assert(jroot["w"s].is_object() && !jroot["w"s].empty()); + fm_assert(read_direction_metadata(jroot, Direction_::N).is_empty()); + fm_assert(read_direction_metadata(jroot, Direction_::E).is_empty()); + fm_assert(read_direction_metadata(jroot, Direction_::S).is_empty()); + const auto dir = read_direction_metadata(jroot, Direction_::W); + fm_assert(dir.wall.pixel_size == Vector2ui{}); + fm_assert(dir.side.pixel_size == Vector2ui{42, 192}); } } // namespace @@ -70,6 +73,7 @@ void test_read_empty_direction(StringView filename) void floormat::test_app::test_wall_atlas() { using namespace floormat::Wall::detail; - test_read_info("wall-atlas-header1.json"_s); - test_read_empty_direction("wall-atlas-header1.json"_s); + test_read_header("wall-atlas-01_header.json"_s); + test_read_empty_direction("wall-atlas-01_header.json"_s); + test_read_groups("wall-atlas-02_groups.json"_s); } |