summaryrefslogtreecommitdiffhomepage
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/hole.cpp16
-rw-r--r--test/save.cpp16
2 files changed, 23 insertions, 9 deletions
diff --git a/test/hole.cpp b/test/hole.cpp
index 248ae59d..d0a80a9c 100644
--- a/test/hole.cpp
+++ b/test/hole.cpp
@@ -27,18 +27,22 @@ void test1(Vector2i offset)
fm_assert_not_equal(0, cut(rect, {{ 49, -49}, {50, 50}}, offset));
#endif
#if 1
- fm_assert_equal(0, cut(rect, {{50, 0}, {50, 50}}, offset));
- fm_assert_equal(0, cut(rect, {{ 0, 50}, {50, 50}}, offset));
- fm_assert_equal(0, cut(rect, {{50, 50}, {50, 50}}, offset));
+ fm_assert_equal(1, cut(rect, {{ 0, 0}, {50, 50}}, offset));
+ fm_assert_equal(1, cut(rect, {{50, 0}, {50, 50}}, offset));
+ fm_assert_equal(1, cut(rect, {{ 0, 50}, {50, 50}}, offset));
+ fm_assert_equal(1, cut(rect, {{50, 50}, {50, 50}}, offset));
#endif
#if 1
fm_assert_equal(1, cut(rect, {{ 9, 9}, {70, 70}}, offset));
fm_assert_equal(1, cut(rect, {{10, 10}, {70, 70}}, offset));
+ fm_assert_equal(2, cut(rect, {{20, 20}, {70, 70}}, offset));
#endif
#if 1
- fm_assert_equal(1, cut(rect, {{1, 0}, {50, 50}}, offset));
- fm_assert_equal(1, cut(rect, {{0, 1}, {50, 50}}, offset));
- fm_assert_equal(2, cut(rect, {{1, 1}, {50, 50}}, offset));
+ fm_assert_equal(1, cut(rect, {{ 1, 0}, {50, 50}}, offset));
+ fm_assert_equal(1, cut(rect, {{ 0, 1}, {50, 50}}, offset));
+ fm_assert_equal(2, cut(rect, {{ 1, 1}, {50, 50}}, offset));
+ fm_assert_equal(2, cut(rect, {{49, 49}, {50, 50}}, offset));
+ fm_assert_equal(1, cut(rect, {{50, 50}, {50, 50}}, offset));
#endif
#if 1
// todo! coverage
diff --git a/test/save.cpp b/test/save.cpp
index f596cf00..3d4a71a0 100644
--- a/test/save.cpp
+++ b/test/save.cpp
@@ -1,14 +1,15 @@
#include "app.hpp"
#include "src/world.hpp"
-#include "loader/loader.hpp"
-#include "loader/scenery-cell.hpp"
#include "src/scenery.hpp"
#include "src/scenery-proto.hpp"
#include "src/critter.hpp"
#include "src/light.hpp"
+#include "src/hole.hpp"
#include "src/ground-atlas.hpp"
#include "src/anim-atlas.hpp"
#include "src/nanosecond.inl"
+#include "loader/loader.hpp"
+#include "loader/scenery-cell.hpp"
#include <Corrade/Utility/Path.h>
namespace floormat {
@@ -98,8 +99,10 @@ void assert_chunks_equal(const chunk& a, const chunk& b)
switch (type)
{
case object_type::none:
- case object_type::COUNT: std::unreachable();
+ case object_type::COUNT:
+ fm_assert(false);
case object_type::critter: {
+ // todo! remove duplication
const auto& e1 = static_cast<const critter&>(ae);
const auto& e2 = static_cast<const critter&>(be);
const auto p1 = critter_proto(e1), p2 = critter_proto(e2);
@@ -120,6 +123,13 @@ void assert_chunks_equal(const chunk& a, const chunk& b)
fm_assert(p1 == p2);
break;
}
+ case object_type::hole: {
+ const auto& e1 = static_cast<const hole&>(ae);
+ const auto& e2 = static_cast<const hole&>(be);
+ const auto p1 = hole_proto(e1), p2 = hole_proto(e2);
+ fm_assert(p1 == p2);
+ break;
+ }
}
}
}