summaryrefslogtreecommitdiffhomepage
path: root/test
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2022-10-06 23:37:35 +0200
committerStanislaw Halik <sthalik@misaki.pl>2022-10-06 23:37:35 +0200
commit85d9552871b1bbf2df86f9f20d93d5bac575dd12 (patch)
tree443002c8f0359d825fbe1dda1b2e401249865b82 /test
parent86d09212e84b7d3b41acf4abd420d4e14cbc3592 (diff)
a
Diffstat (limited to 'test')
-rw-r--r--test/json.cpp30
1 files changed, 30 insertions, 0 deletions
diff --git a/test/json.cpp b/test/json.cpp
index 5e60b7ee..b98c9ae2 100644
--- a/test/json.cpp
+++ b/test/json.cpp
@@ -5,9 +5,31 @@
#include "serialize/json-helper.hpp"
#include "compat/assert.hpp"
#include "tile-atlas.hpp"
+#include "tile.hpp"
+#include "chunk.hpp"
#include "loader.hpp"
namespace Magnum::Examples {
+
+static chunk make_test_chunk()
+{
+ auto metal1 = loader.tile_atlas("share/game/images/metal1.tga", {2, 2}),
+ metal2 = loader.tile_atlas("share/game/images/metal2.tga", {2, 2}),
+ metal3 = loader.tile_atlas("share/game/images/metal3.tga", {2, 2});
+ constexpr auto N = TILE_MAX_DIM;
+ chunk c;
+ c.foreach_tile([&](tile& x, std::size_t k, local_coords pt) {
+ const auto& atlas = pt.x > N/2 && pt.y >= N/2 ? metal1 : metal2;
+ x.ground_image = { atlas, (std::uint8_t)(k % atlas->num_tiles().product()) };
+ });
+ constexpr auto K = N/2;
+ c[{K, K }].wall_north = { metal3, 0 };
+ c[{K, K }].wall_west = { metal3, 0 };
+ c[{K, K+1}].wall_north = { metal3, 0 };
+ c[{K+1, K }].wall_west = { metal3, 0 };
+ return c;
+}
+
bool app::test_json() // NOLINT(readability-convert-member-functions-to-static)
{
bool ret = true;
@@ -22,6 +44,14 @@ bool app::test_json() // NOLINT(readability-convert-member-functions-to-static)
ret &= json_helper::to_json(v2i_1, output_dir/"vec2i_1.json");
ret &= json_helper::to_json(v2i_2, output_dir/"vec2i_2.json");
}
+ {
+ Magnum::Math::Vector3 vec{0.f/0, -1.f/0, 123.f};
+ ret &= json_helper::to_json(vec, output_dir/"vec3_inf.json");
+ }
+ {
+ const auto chunk = make_test_chunk();
+ ret &= json_helper::to_json(chunk, output_dir/"chunk-1.json");
+ }
return ret;
}