diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2024-02-11 08:32:10 +0100 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2024-02-11 08:49:53 +0100 |
commit | 017cb08bf33608f1ceb8d59800a8d1d2f9d5d455 (patch) | |
tree | 8918ad2e036d8dc79b7b2cbdce858a9617551aea /test | |
parent | b2be7d57642197c0f65d2645c767c4f868ababb1 (diff) |
loader: allow adding atlases to the list without parsing them
Diffstat (limited to 'test')
-rw-r--r-- | test/anim-atlas.cpp | 16 | ||||
-rw-r--r-- | test/app.cpp | 9 | ||||
-rw-r--r-- | test/app.hpp | 4 | ||||
-rw-r--r-- | test/loader.cpp | 52 | ||||
-rw-r--r-- | test/serializer.cpp | 2 |
5 files changed, 50 insertions, 33 deletions
diff --git a/test/anim-atlas.cpp b/test/anim-atlas.cpp deleted file mode 100644 index 9f84a6ff..00000000 --- a/test/anim-atlas.cpp +++ /dev/null @@ -1,16 +0,0 @@ -#include "app.hpp" - -namespace { - - - -} // namespace - -namespace floormat { - -void test_app::test_anim_atlas() -{ - -} - -} // namespace floormat diff --git a/test/app.cpp b/test/app.cpp index 99326c29..e896196d 100644 --- a/test/app.cpp +++ b/test/app.cpp @@ -60,12 +60,12 @@ int test_app::exec() FM_TEST(test_bitmask), FM_TEST(test_loader), FM_TEST(test_serializer1), - FM_TEST(test_anim_atlas), + FM_TEST(test_loader2), FM_TEST(test_scenery), FM_TEST(test_astar_pool), FM_TEST(test_astar), - FM_TEST(test_dijkstra), // todo add dummy atlases to avoid expensive loading - FM_TEST(test_load_all), + FM_TEST(test_dijkstra), + FM_TEST(test_saves), FM_TEST(test_zzz_misc), }; @@ -102,7 +102,8 @@ int test_app::exec() std::fwrite(name.data(), name.size(), 1, s); if constexpr(!sep.isEmpty()) std::fwrite(sep.data(), sep.size(), 1, s); - auto num_tabs = max_tabs - get_tabs(name); + auto num_tabs = max_tabs - get_tabs(name) - 1; + std::fputc('\t', s); std::fflush(stdout); auto ms = get_time(fun); fm_assert(num_tabs <= tab_limit); diff --git a/test/app.hpp b/test/app.hpp index 41f01507..e8669aed 100644 --- a/test/app.hpp +++ b/test/app.hpp @@ -21,7 +21,6 @@ struct test_app final : private FM_APPLICATION int exec() override; - static void test_anim_atlas(); static void test_astar(); static void test_astar_pool(); static void test_bitmask(); @@ -33,8 +32,9 @@ struct test_app final : private FM_APPLICATION static void test_json(); static void test_json2(); static void test_json3(); - static void test_load_all(); + static void test_saves(); static void test_loader(); + static void test_loader2(); static void test_magnum_math(); static void test_math(); static void test_raycast(); diff --git a/test/loader.cpp b/test/loader.cpp index e3e6921d..01792bd6 100644 --- a/test/loader.cpp +++ b/test/loader.cpp @@ -2,8 +2,10 @@ #include "compat/assert.hpp" #include "loader/loader.hpp" #include "loader/wall-cell.hpp" +#include "loader/anim-cell.hpp" #include "src/ground-atlas.hpp" #include "src/wall-atlas.hpp" +#include "src/anim-atlas.hpp" #include <mg/Texture.h> namespace floormat { @@ -62,24 +64,54 @@ void test_app::test_loader() fm_assert(!A.raw_frame_array().isEmpty()); fm_assert(A.texture().id()); } + fm_assert(loader.ground_atlas("texel")->pass_mode() == pass_mode::blocked); + fm_assert(loader.ground_atlas("metal1")->pass_mode() == pass_mode::pass); + loader.sceneries(); +} +void test_app::test_loader2() +{ for (const auto& x : loader.ground_atlas_list()) { - if (x.name != loader.INVALID) + fm_assert(x.name); + if (x.name == loader.INVALID) + continue; + if (!x.atlas) { - (void)loader.ground_atlas(x.name); - fm_assert(x.atlas); - fm_assert(x.atlas == loader.ground_atlas(x.name)); + auto atlas = loader.ground_atlas(x.name, loader_policy::error); + fm_assert(atlas->name() == x.name); + fm_assert(atlas->texture().id()); + fm_assert(!atlas->pixel_size().isZero()); + fm_assert(Vector2ui{atlas->num_tiles2()}.product()); } - else + } + for (const auto& x : loader.wall_atlas_list()) + { + fm_assert(x.name); + if (x.name == loader.INVALID) + continue; + if (!x.atlas) { - fm_assert(x.atlas); - fm_assert(x.atlas == loader.make_invalid_ground_atlas().atlas); + auto atlas = loader.wall_atlas(x.name, loader_policy::error); + fm_assert(atlas->name() == x.name); + fm_assert(atlas->texture().id()); + fm_assert(!atlas->raw_frame_array().isEmpty()); + fm_assert(atlas->calc_direction(Wall::Direction_::N).wall.count); } } - fm_assert(loader.ground_atlas("texel")->pass_mode() == pass_mode::blocked); - fm_assert(loader.ground_atlas("metal1")->pass_mode() == pass_mode::pass); - loader.sceneries(); + for (const auto& x : loader.anim_atlas_list()) + { + fm_assert(x.name); + if (x.name == loader.INVALID) + continue; + auto atlas_ = loader.anim_atlas(x.name, {}, loader_policy::error); + fm_assert(atlas_); + auto& atlas = *atlas_; + fm_assert(atlas.name() == x.name); + fm_assert(atlas.texture().id()); + fm_assert(atlas.info().nframes > 0); + } + // todo scenery_cell } } // namespace floormat diff --git a/test/serializer.cpp b/test/serializer.cpp index d4f08d48..44746449 100644 --- a/test/serializer.cpp +++ b/test/serializer.cpp @@ -145,7 +145,7 @@ void test_app::test_serializer1() test_serializer({}, tmp_filename); } -void test_app::test_load_all() +void test_app::test_saves() { fm_assert(Path::exists(Path::join(loader.TEMP_PATH, "CMakeCache.txt"))); const auto tmp_filename = Path::join(loader.TEMP_PATH, "test/test-serializer2.dat"_s); |