summaryrefslogtreecommitdiffhomepage
path: root/test
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2024-02-08 08:38:45 +0100
committerStanislaw Halik <sthalik@misaki.pl>2024-02-08 08:38:58 +0100
commit4575194adb4615deeca174044a872093c3664ad4 (patch)
tree5c403a30ff03fed9ceeb2f72a38936767068e68f /test
parent2a05099c367670107f7537d4e4b77e8e3276b878 (diff)
add more tests (and clean them up a bit too)
Diffstat (limited to 'test')
-rw-r--r--test/app.cpp12
-rw-r--r--test/app.hpp12
-rw-r--r--test/json.cpp20
-rw-r--r--test/serializer.cpp2
-rw-r--r--test/wall-atlas2.cpp14
5 files changed, 49 insertions, 11 deletions
diff --git a/test/app.cpp b/test/app.cpp
index 6aaebb80..ffaf8201 100644
--- a/test/app.cpp
+++ b/test/app.cpp
@@ -49,20 +49,22 @@ int test_app::exec()
FM_TEST(test_magnum_math),
FM_TEST(test_math),
FM_TEST(test_entity),
- FM_TEST(test_intrusive_ptr),
+ FM_TEST(test_iptr),
FM_TEST(test_hash),
+ FM_TEST(test_raycast),
FM_TEST(test_json),
FM_TEST(test_wall_atlas),
+ FM_TEST(test_json2),
FM_TEST(test_wall_atlas2),
+ FM_TEST(test_json3),
FM_TEST(test_bitmask),
FM_TEST(test_loader),
FM_TEST(test_serializer1),
FM_TEST(test_scenery),
- FM_TEST(test_raycast),
- FM_TEST(test_path_search_pool),
- FM_TEST(test_path_search),
+ FM_TEST(test_astar_pool),
+ FM_TEST(test_astar),
FM_TEST(test_dijkstra), // todo add dummy atlases to avoid expensive loading
- FM_TEST(test_serializer2),
+ FM_TEST(test_load_all),
FM_TEST(test_zzz_misc),
};
diff --git a/test/app.hpp b/test/app.hpp
index f2a169fb..d7e66b17 100644
--- a/test/app.hpp
+++ b/test/app.hpp
@@ -25,19 +25,21 @@ struct test_app final : private FM_APPLICATION
static void test_tile_iter();
static void test_magnum_math();
static void test_math();
- static void test_intrusive_ptr();
+ static void test_iptr();
static void test_entity();
static void test_serializer1();
static void test_bitmask();
static void test_hash();
static void test_json();
+ static void test_wall_atlas();
static void test_dijkstra();
- static void test_serializer2();
static void test_loader();
- static void test_path_search();
+ static void test_json2();
+ static void test_json3();
+ static void test_load_all();
+ static void test_astar();
static void test_scenery();
- static void test_path_search_pool();
- static void test_wall_atlas();
+ static void test_astar_pool();
static void test_wall_atlas2();
static void test_raycast();
static void test_zzz_misc();
diff --git a/test/json.cpp b/test/json.cpp
index 70d8a80c..d94489ee 100644
--- a/test/json.cpp
+++ b/test/json.cpp
@@ -35,4 +35,24 @@ void test_app::test_json() // NOLINT(readability-convert-member-functions-to-sta
}
}
+void test_app::test_json2()
+{
+ fm_assert(Path::exists(Path::join(loader.TEMP_PATH, "CMakeCache.txt")));
+ const auto output_dir = Path::join(loader.TEMP_PATH, "test/."_s);
+ auto atlas1 = loader.make_invalid_ground_atlas().atlas;
+ json_helper::to_json(atlas1, Path::join(output_dir, "atlas1.json"));
+ auto atlas2 = loader.make_invalid_wall_atlas().atlas;
+ atlas2->serialize(Path::join(output_dir, "atlas2.json"));
+}
+
+void test_app::test_json3()
+{
+ fm_assert(Path::exists(Path::join(loader.TEMP_PATH, "CMakeCache.txt")));
+ const auto output_dir = Path::join(loader.TEMP_PATH, "test/."_s);
+ auto atlas3 = loader.ground_atlas("metal1");
+ json_helper::to_json(atlas3, Path::join(output_dir, "atlas3.json"));
+ auto atlas4 = loader.wall_atlas("empty");
+ atlas4->serialize(Path::join(output_dir, "atlas4.json"));
+}
+
} // namespace floormat
diff --git a/test/serializer.cpp b/test/serializer.cpp
index b810f974..d4f08d48 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_serializer2()
+void test_app::test_load_all()
{
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);
diff --git a/test/wall-atlas2.cpp b/test/wall-atlas2.cpp
index fc875767..4e86885b 100644
--- a/test/wall-atlas2.cpp
+++ b/test/wall-atlas2.cpp
@@ -9,6 +9,19 @@ namespace floormat {
namespace {
+void test_loading()
+{
+ { 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));
+}
+
void test_empty_wall()
{
constexpr auto wall_size = Vector2ui(Vector2i{iTILE_SIZE.x(), iTILE_SIZE.z()});
@@ -78,6 +91,7 @@ void test_concrete_wall()
void test_app::test_wall_atlas2()
{
test_empty_wall();
+ test_loading();
test_concrete_wall();
}