summaryrefslogtreecommitdiffhomepage
path: root/test
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2024-01-17 10:59:44 +0100
committerStanislaw Halik <sthalik@misaki.pl>2024-01-17 11:01:18 +0100
commit8b67a492f459a47a1d2eeebc852c9741a77708d5 (patch)
tree1f98c71721e3841da1bbfb49afa211f8c92af472 /test
parent7e8875bac57fdf2bf5e773a890ad868b5ff22727 (diff)
a
Diffstat (limited to 'test')
-rw-r--r--test/wall-atlas.cpp2
-rw-r--r--test/wall-atlas2.cpp66
2 files changed, 54 insertions, 14 deletions
diff --git a/test/wall-atlas.cpp b/test/wall-atlas.cpp
index 14046a09..4a761cfe 100644
--- a/test/wall-atlas.cpp
+++ b/test/wall-atlas.cpp
@@ -107,7 +107,7 @@ void test_from_rotation(StringView filename)
constexpr Frame frame_defaults;
constexpr Group group_defaults;
- fm_assert(!atlas.frames.empty());
+ fm_assert(!atlas.frames.isEmpty());
fm_assert(atlas.frames[0].offset != frame_defaults.offset);
auto dir_index = atlas.direction_map[(size_t)Direction_::W];
fm_assert(dir_index);
diff --git a/test/wall-atlas2.cpp b/test/wall-atlas2.cpp
index 7c64166c..ebfa3f54 100644
--- a/test/wall-atlas2.cpp
+++ b/test/wall-atlas2.cpp
@@ -7,22 +7,62 @@
namespace floormat {
-void test_app::test_wall_atlas2()
+namespace {
+
+void test_empty_wall()
+{
+ using enum Wall::Direction_;
+
+ const auto& wall = *loader.wall_atlas("empty"_s);
+ constexpr auto wall_size = Vector2ui(Vector2i{iTILE_SIZE.x(), iTILE_SIZE.z()});
+ fm_assert(wall_atlas::expected_size(wall.info().depth, Wall::Group_::wall) == wall_size);
+ fm_assert(wall.depth() == 8);
+ fm_assert(wall.direction_count() == 1);
+ fm_assert(wall.raw_frame_array().size() == 1);
+ fm_assert(wall.direction(N) != nullptr);
+ const auto& n = *wall.direction(N);
+ fm_assert(wall.direction(W) == nullptr);
+ fm_assert(&wall.calc_direction(N) == wall.direction(N));
+ fm_assert(&wall.calc_direction(W) == wall.direction(N));
+ fm_assert(n.side == Wall::Group{});
+ fm_assert(n.top == Wall::Group{});
+ fm_assert(n.corner == Wall::Group{});
+ fm_assert(!n.wall.mirrored);
+ fm_assert(n.wall.pixel_size == wall_size);
+ fm_assert(wall.raw_frame_array()[0].offset.isZero());
+ fm_assert(wall.raw_frame_array()[0].size == wall_atlas::expected_size(wall.info().depth, Wall::Group_::wall));
+ fm_assert(wall.info().name == "empty"_s);
+ fm_assert(wall.info().passability == pass_mode::blocked);
+}
+
+void test_concrete_wall()
{
using enum Wall::Direction_;
+ constexpr auto name = "concrete1"_s;
- static constexpr auto name = "concrete1"_s;
- auto& a = *loader.wall_atlas(name, false);
- fm_assert(a.name() == name);
- fm_assert(a.info().depth == 20);
- fm_assert(a.raw_frame_array().size() >= 3);
- fm_assert(!a.direction(W));
- fm_assert(a.direction(N));
- fm_assert(&a.calc_direction(W) == a.direction(N));
- fm_assert(&a.calc_direction(N) == a.direction(N));
- fm_assert(a.frames(N, Wall::Group_::wall).size() >= 3);
- fm_assert(a.group(N, Wall::Group_::top)->is_defined);
- fm_assert(a.frames(N, Wall::Group_::wall)[0].size == Vector2ui(Vector2i{iTILE_SIZE.x(), iTILE_SIZE.z()}));
+ auto& wall = *loader.wall_atlas(name, false);
+ fm_assert(wall.name() == name);
+ fm_assert(wall.info().depth == 20);
+ fm_assert(wall.raw_frame_array().size() >= 3);
+ fm_assert(!wall.direction(W));
+ fm_assert(wall.direction(N));
+ fm_assert(&wall.calc_direction(W) == wall.direction(N));
+ fm_assert(&wall.calc_direction(N) == wall.direction(N));
+ fm_assert(wall.frames(N, Wall::Group_::wall).size() >= 3);
+ fm_assert(wall.group(N, Wall::Group_::top)->is_defined);
+ fm_assert(wall.frames(N, Wall::Group_::wall)[0].size == Vector2ui(Vector2i{iTILE_SIZE.x(), iTILE_SIZE.z()}));
+ fm_assert(&wall.calc_direction(N) == wall.direction(N));
+ fm_assert(&wall.calc_direction(W) == wall.direction(N));
}
+} // namespace
+
+void test_app::test_wall_atlas2()
+{
+ test_empty_wall();
+ test_concrete_wall();
+}
+
+// todo add test for wall-tileset-tool for making sure it generates the correct image pixels out of placeholder input
+
} // namespace floormat