diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2022-10-29 16:51:36 +0200 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2022-10-29 16:51:36 +0200 |
commit | 9813d9263e0b45f46b90579ea217117da823dad7 (patch) | |
tree | 88199e91e5ec2f9469bb8197e89b7cd5c9ce45ab /test | |
parent | 4c982b2ffe99f5dee70657424161de9541e00a21 (diff) |
convert line endings
Diffstat (limited to 'test')
-rw-r--r-- | test/serializer.cpp | 114 |
1 files changed, 57 insertions, 57 deletions
diff --git a/test/serializer.cpp b/test/serializer.cpp index 7970bdac..db08a9f8 100644 --- a/test/serializer.cpp +++ b/test/serializer.cpp @@ -1,57 +1,57 @@ -#include "app.hpp"
-#include "src/world.hpp"
-#include "src/loader.hpp"
-#include "src/tile-atlas.hpp"
-#include <Corrade/Utility/Path.h>
-
-namespace floormat {
-
-namespace Path = Corrade::Utility::Path;
-
-static chunk make_test_chunk()
-{
- auto metal1 = loader.tile_atlas("metal1", {2, 2}),
- metal2 = loader.tile_atlas("metal2", {2, 2}),
- tiles = loader.tile_atlas("tiles", {8, 5});
- constexpr auto N = TILE_MAX_DIM;
- chunk c;
- for (auto& [x, k, pt] : c) {
- x.ground = { tiles, decltype(tile_image::variant)(k % tiles->num_tiles()) };
- }
- constexpr auto K = N/2;
- c[{K, K }].wall_north = { metal1, 0 };
- c[{K, K }].wall_west = { metal2, 0 };
- c[{K, K+1}].wall_north = { metal1, 0 };
- c[{K+1, K }].wall_west = { metal2, 0 };
- return c;
-}
-
-static bool chunks_equal(const chunk& a, const chunk& b)
-{
- for (std::size_t i = 0; i < TILE_COUNT; i++)
- if (a[i] != b[i])
- return false;
- return true;
-}
-
-static bool test_serializer1()
-{
- constexpr auto filename = "../test/test-serializer1.dat";
- if (Path::exists(filename))
- Path::remove(filename);
- world w;
- const chunk_coords coord{1, 1};
- w[coord] = make_test_chunk();
- w.serialize(filename);
- auto w2 = world::deserialize(filename);
- return chunks_equal(w[coord], w2[coord]);
-}
-
-bool floormat::test_serializer()
-{
- bool ret = true;
- ret &= test_serializer1();
- return ret;
-}
-
-} // namespace floormat
+#include "app.hpp" +#include "src/world.hpp" +#include "src/loader.hpp" +#include "src/tile-atlas.hpp" +#include <Corrade/Utility/Path.h> + +namespace floormat { + +namespace Path = Corrade::Utility::Path; + +static chunk make_test_chunk() +{ + auto metal1 = loader.tile_atlas("metal1", {2, 2}), + metal2 = loader.tile_atlas("metal2", {2, 2}), + tiles = loader.tile_atlas("tiles", {8, 5}); + constexpr auto N = TILE_MAX_DIM; + chunk c; + for (auto& [x, k, pt] : c) { + x.ground = { tiles, decltype(tile_image::variant)(k % tiles->num_tiles()) }; + } + constexpr auto K = N/2; + c[{K, K }].wall_north = { metal1, 0 }; + c[{K, K }].wall_west = { metal2, 0 }; + c[{K, K+1}].wall_north = { metal1, 0 }; + c[{K+1, K }].wall_west = { metal2, 0 }; + return c; +} + +static bool chunks_equal(const chunk& a, const chunk& b) +{ + for (std::size_t i = 0; i < TILE_COUNT; i++) + if (a[i] != b[i]) + return false; + return true; +} + +static bool test_serializer1() +{ + constexpr auto filename = "../test/test-serializer1.dat"; + if (Path::exists(filename)) + Path::remove(filename); + world w; + const chunk_coords coord{1, 1}; + w[coord] = make_test_chunk(); + w.serialize(filename); + auto w2 = world::deserialize(filename); + return chunks_equal(w[coord], w2[coord]); +} + +bool floormat::test_serializer() +{ + bool ret = true; + ret &= test_serializer1(); + return ret; +} + +} // namespace floormat |