diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/dijkstra.cpp | 15 | ||||
-rw-r--r-- | test/json.cpp | 7 | ||||
-rw-r--r-- | test/loader.cpp | 20 | ||||
-rw-r--r-- | test/path-search.cpp | 11 | ||||
-rw-r--r-- | test/raycast.cpp | 6 | ||||
-rw-r--r-- | test/save/quicksave - Copy (0034).dat | bin | 0 -> 3014 bytes | |||
-rw-r--r-- | test/save/quicksave - Copy (0035).dat | bin | 0 -> 7450 bytes |
7 files changed, 32 insertions, 27 deletions
diff --git a/test/dijkstra.cpp b/test/dijkstra.cpp index d5412559..8a702a52 100644 --- a/test/dijkstra.cpp +++ b/test/dijkstra.cpp @@ -1,6 +1,7 @@ #include "app.hpp" #include "src/path-search.hpp" #include "loader/loader.hpp" +#include "loader/wall-info.hpp" #include <Magnum/Math/Functions.h> namespace floormat { @@ -19,7 +20,7 @@ void test_app::test_dijkstra() constexpr auto wpos = global_coords{wch, wt}; auto& ch = w[wch]; - auto metal2 = wall_image_proto{loader.wall_atlas("empty", loader_policy::warn), 0}; + auto wall = wall_image_proto{loader.make_invalid_wall_atlas().atlas, 0}; for (int16_t j = wcy - 1; j <= wcy + 1; j++) for (int16_t i = wcx - 1; i <= wcx + 1; i++) @@ -27,15 +28,15 @@ void test_app::test_dijkstra() auto &c = w[chunk_coords_{i, j, 0}]; for (int k : { 3, 4, 5, 6, 11, 12, 13, 14, 15, }) { - c[{ k, k }].wall_north() = metal2; - c[{ k, k }].wall_west() = metal2; + c[{ k, k }].wall_north() = wall; + c[{ k, k }].wall_west() = wall; } } - ch[{ wtx, wty }].wall_west() = metal2; - ch[{ wtx, wty }].wall_north() = metal2; - ch[{ wtx+1, wty }].wall_west() = metal2; - ch[{ wtx, wty +1}].wall_north() = metal2; + ch[{ wtx, wty }].wall_west() = wall; + ch[{ wtx, wty }].wall_north() = wall; + ch[{ wtx+1, wty }].wall_west() = wall; + ch[{ wtx, wty +1}].wall_north() = wall; for (int16_t j = wcy - 1; j <= wcy + 1; j++) for (int16_t i = wcx - 1; i <= wcx + 1; i++) diff --git a/test/json.cpp b/test/json.cpp index d9be8ff3..70d8a80c 100644 --- a/test/json.cpp +++ b/test/json.cpp @@ -1,6 +1,7 @@ #include "app.hpp" #include "serialize/tile.hpp" #include "serialize/ground-atlas.hpp" +#include "serialize/wall-atlas.hpp" #include "serialize/magnum-vector.hpp" #include "serialize/json-helper.hpp" #include "compat/assert.hpp" @@ -10,6 +11,8 @@ #include "src/chunk.hpp" #include "src/world.hpp" #include "loader/loader.hpp" +#include "loader/wall-info.hpp" +#include <memory> #include <Corrade/Containers/StringView.h> #include <Corrade/Utility/Path.h> @@ -20,10 +23,6 @@ void test_app::test_json() // NOLINT(readability-convert-member-functions-to-sta fm_assert(Path::exists(Path::join(loader.TEMP_PATH, "CMakeCache.txt"))); const auto output_dir = Path::join(loader.TEMP_PATH, "test/."_s); { - auto atlas = loader.ground_atlas("metal1"); - json_helper::to_json(atlas, Path::join(output_dir, "atlas.json")); - } - { Magnum::Math::Vector<2, int> v2i_1{1, 2}; Vector2i v2i_2{2, 3}; json_helper::to_json(v2i_1, Path::join(output_dir, "vec2i_1.json")); diff --git a/test/loader.cpp b/test/loader.cpp index 2716d238..3b04459a 100644 --- a/test/loader.cpp +++ b/test/loader.cpp @@ -1,8 +1,8 @@ #include "app.hpp" #include "compat/assert.hpp" #include "loader/loader.hpp" -#include "src/ground-atlas.hpp" #include "loader/wall-info.hpp" +#include "src/ground-atlas.hpp" namespace floormat { @@ -37,6 +37,14 @@ constexpr const char* anim_atlases[] = { void test_app::test_loader() { + fm_assert(loader.make_invalid_ground_atlas().atlas); + fm_assert(&loader.make_invalid_ground_atlas().atlas == &loader.make_invalid_ground_atlas().atlas); + fm_assert(loader.make_invalid_ground_atlas().name == loader.INVALID); + + fm_assert(loader.make_invalid_wall_atlas().atlas); + fm_assert(&loader.make_invalid_wall_atlas().atlas == &loader.make_invalid_wall_atlas().atlas); + fm_assert(loader.make_invalid_wall_atlas().name == loader.INVALID); + for (const auto& str : anim_atlases) (void)loader.get_anim_atlas(str); for (const auto& x : ground_atlases) @@ -51,16 +59,6 @@ void test_app::test_loader() loader.sceneries(); for (StringView name : loader.anim_atlas_list()) loader.anim_atlas(name); - - { auto walls = loader.wall_atlas_list(); - fm_assert(!walls.isEmpty()); - fm_assert(loader.wall_atlas("test1"_s)); - fm_assert(loader.wall_atlas(loader.INVALID, loader_policy::ignore)); - fm_assert(loader.wall_atlas("test1"_s) == loader.wall_atlas("test1"_s)); - fm_assert(loader.wall_atlas("test1"_s) != loader.wall_atlas(loader.INVALID, loader_policy::ignore)); - } - for (const auto& info : loader.wall_atlas_list()) - fm_assert(loader.wall_atlas(info.name)); } } // namespace floormat diff --git a/test/path-search.cpp b/test/path-search.cpp index 1345f091..5a1dc825 100644 --- a/test/path-search.cpp +++ b/test/path-search.cpp @@ -2,6 +2,7 @@ #include "compat/assert.hpp" #include "compat/function2.hpp" #include "loader/loader.hpp" +#include "loader/wall-info.hpp" #include "src/world.hpp" #include "src/scenery.hpp" #include "src/path-search.hpp" @@ -178,7 +179,7 @@ void test_bbox() return neighbor_tiles(w, { ch, pos }, {}, (object_id)-1, path_search::never_continue()); }; - const auto metal2 = loader.wall_atlas("empty", loader_policy::warn); + const auto wall = loader.make_invalid_wall_atlas().atlas; const auto table = loader.scenery("table1"); { @@ -190,7 +191,7 @@ void test_bbox() auto w = world(); [[maybe_unused]] auto& c12 = w[coord2]; [[maybe_unused]] auto& c11 = w[coord1]; - c12[{0, 0}].wall_north() = {metal2, 0}; + c12[{0, 0}].wall_north() = { wall, 0}; fm_assert( !is_passable_1(c12, bbox({}, N)) ); fm_assert( is_passable_1(c12, bbox({}, E)) ); @@ -211,8 +212,8 @@ void test_bbox() auto w = world(); auto& c = w[ch]; - c[{8, 7}].wall_north() = {metal2,0}; - c[{8, 9}].wall_north() = {metal2,0}; + c[{8, 7}].wall_north() = { wall,0}; + c[{8, 9}].wall_north() = { wall,0}; fm_assert( is_passable_1(c, bbox({8, 6}, N)) ); fm_assert( !is_passable_1(c, bbox({8, 6}, S)) ); fm_assert( !is_passable_1(c, bbox({8, 7}, N)) ); @@ -224,7 +225,7 @@ void test_bbox() fm_assert(neighbors(w, ch, {8, 8}).size == 3); - c[{8, 8}].wall_north() = {metal2,0}; + c[{8, 8}].wall_north() = { wall,0}; c.mark_passability_modified(); fm_assert( is_passable_1(c, bbox({8, 8}, C)) ); fm_assert( !is_passable_1(c, bbox({8, 7}, S)) ); diff --git a/test/raycast.cpp b/test/raycast.cpp index 23b03926..cb76333f 100644 --- a/test/raycast.cpp +++ b/test/raycast.cpp @@ -3,6 +3,7 @@ #include "src/raycast-diag.hpp" #include "src/world.hpp" #include "loader/loader.hpp" +#include "loader/wall-info.hpp" #include <Magnum/Math/Functions.h> namespace floormat { @@ -12,8 +13,13 @@ namespace { world make_world() { constexpr auto var = (variant_t)-1; +#if 1 + auto wall1_ = loader.make_invalid_wall_atlas().atlas; + auto wall2_ = loader.make_invalid_wall_atlas().atlas; +#else auto wall1_ = loader.wall_atlas("test1"_s); auto wall2_ = loader.wall_atlas("concrete1"_s); +#endif auto wall1 = wall_image_proto{wall1_, var}; auto wall2 = wall_image_proto{wall2_, var}; diff --git a/test/save/quicksave - Copy (0034).dat b/test/save/quicksave - Copy (0034).dat Binary files differnew file mode 100644 index 00000000..20d38b8a --- /dev/null +++ b/test/save/quicksave - Copy (0034).dat diff --git a/test/save/quicksave - Copy (0035).dat b/test/save/quicksave - Copy (0035).dat Binary files differnew file mode 100644 index 00000000..e548dc75 --- /dev/null +++ b/test/save/quicksave - Copy (0035).dat |