summaryrefslogtreecommitdiffhomepage
path: root/test
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2022-10-08 01:34:44 +0200
committerStanislaw Halik <sthalik@misaki.pl>2022-10-08 01:34:44 +0200
commit41f4f4b6f9ba5fa20bb41967dc8ef8020081e38e (patch)
treef06241318bf19d07329b4130fc7e92d4b75dc234 /test
parentf845dbb21799d7b2879ba1ea9761fd3e68303ae8 (diff)
a
Diffstat (limited to 'test')
-rw-r--r--test/app.hpp1
-rw-r--r--test/json.cpp3
-rw-r--r--test/main.cpp1
-rw-r--r--test/tile-iter.cpp39
4 files changed, 43 insertions, 1 deletions
diff --git a/test/app.hpp b/test/app.hpp
index c77c3369..44fbed11 100644
--- a/test/app.hpp
+++ b/test/app.hpp
@@ -8,5 +8,6 @@ struct app final : Platform::WindowlessWglApplication // NOLINT(cppcoreguideline
~app();
int exec() override;
static bool test_json();
+ static bool test_tile_iter();
};
} // namespace Magnum::Examples
diff --git a/test/json.cpp b/test/json.cpp
index 3ce3c9d0..46bdf528 100644
--- a/test/json.cpp
+++ b/test/json.cpp
@@ -18,7 +18,7 @@ static chunk make_test_chunk()
metal3 = loader.tile_atlas("share/game/images/metal3.tga", {2, 2});
constexpr auto N = TILE_MAX_DIM;
chunk c;
- for (auto [x, k, pt] : c) {
+ for (auto& [x, k, pt] : c) {
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()) };
}
@@ -52,6 +52,7 @@ bool app::test_json() // NOLINT(readability-convert-member-functions-to-static)
const auto chunk = make_test_chunk();
ret &= json_helper::to_json(chunk, output_dir/"zzz_chunk-1.json");
}
+
return ret;
}
diff --git a/test/main.cpp b/test/main.cpp
index d190c27b..06a2e64d 100644
--- a/test/main.cpp
+++ b/test/main.cpp
@@ -25,6 +25,7 @@ int app::exec()
{
bool ret = true;
ret &= test_json();
+ ret &= test_tile_iter();
return !ret;
}
diff --git a/test/tile-iter.cpp b/test/tile-iter.cpp
new file mode 100644
index 00000000..aea6b8b5
--- /dev/null
+++ b/test/tile-iter.cpp
@@ -0,0 +1,39 @@
+#include "app.hpp"
+#include "chunk.hpp"
+namespace Magnum::Examples {
+
+static inline bool always_false()
+{
+ volatile bool ret = false;
+ return ret;
+}
+
+bool app::test_tile_iter() // NOLINT(readability-function-size)
+{
+ if (always_false())
+ {
+ const chunk c;
+ for (const auto& [x, k, pt] : c)
+ static_assert(std::is_same_v<decltype(x), const tile&>);
+ for (auto& [x, k, pt] : c)
+ static_assert(std::is_same_v<decltype(x), const tile&>);
+ for (auto [x, k, pt] : c)
+ static_assert(std::is_same_v<decltype(x), const tile&>);
+ }
+ if (always_false())
+ {
+ chunk c;
+ for (auto& [x, k, pt] : c)
+ static_assert(std::is_same_v<decltype(x), tile&>);
+ for (const auto& [x, k, pt] : c)
+ static_assert(std::is_same_v<decltype(x), const tile&>);
+#if 1
+ for (auto [x, k, pt] : c)
+ static_assert(std::is_same_v<decltype(x), tile&>);
+#endif
+ }
+ return true;
+}
+
+} // namespace Magnum::Examples
+