diff options
| author | Stanislaw Halik <sthalik@misaki.pl> | 2024-05-26 15:30:15 +0200 |
|---|---|---|
| committer | Stanislaw Halik <sthalik@misaki.pl> | 2024-05-26 15:30:15 +0200 |
| commit | 82ab34aa83463179339eb8382edf1c22cacdad61 (patch) | |
| tree | 3d02aaa7458a4f00e38527c7cfe0f8559398b5d5 /editor/tests | |
| parent | c3bebd8c3263d67f3b66cab7437bc24f5ea724c8 (diff) | |
use array_size instead of std::size/arraySize
Diffstat (limited to 'editor/tests')
| -rw-r--r-- | editor/tests/path-test.cpp | 11 | ||||
| -rw-r--r-- | editor/tests/raycast-test.cpp | 21 |
2 files changed, 17 insertions, 15 deletions
diff --git a/editor/tests/path-test.cpp b/editor/tests/path-test.cpp index 4558fedd..63b59dd4 100644 --- a/editor/tests/path-test.cpp +++ b/editor/tests/path-test.cpp @@ -1,5 +1,6 @@ #include "../tests-private.hpp" #include "../app.hpp" +#include "compat/array-size.hpp" #include "compat/shared-ptr-wrapper.hpp" #include "compat/vector-wrapper.hpp" #include "floormat/main.hpp" @@ -187,7 +188,7 @@ void path_test::draw_ui(app&, float) constexpr auto print_coord = [](auto&& buf, Vector3i c, Vector2i l, Vector2i p) { - std::snprintf(buf, std::size(buf), "(ch %dx%d) <%dx%d> {%dx%d px}", c.x(), c.y(), l.x(), l.y(), p.x(), p.y()); + std::snprintf(buf, array_size(buf), "(ch %dx%d) <%dx%d> {%dx%d px}", c.x(), c.y(), l.x(), l.y(), p.x(), p.y()); }; constexpr auto do_column = [](StringView name) @@ -226,21 +227,21 @@ void path_test::draw_ui(app&, float) { auto b = push_style_color(ImGuiCol_Text, 0xffff00ff_rgbaf); do_column("dist"); - std::snprintf(buf, std::size(buf), "%d", (int)res.distance()); + std::snprintf(buf, array_size(buf), "%d", (int)res.distance()); text(buf); } } do_column("cost"); - std::snprintf(buf, std::size(buf), "%d", (int)res.cost()); + std::snprintf(buf, array_size(buf), "%d", (int)res.cost()); text(buf); do_column("length"); - std::snprintf(buf, std::size(buf), "%d", (int)res.path().size()); + std::snprintf(buf, array_size(buf), "%d", (int)res.path().size()); text(buf); do_column("time"); - std::snprintf(buf, std::size(buf), "%.1f ms", (double)(1000 * res.time())); + std::snprintf(buf, array_size(buf), "%.1f ms", (double)(1000 * res.time())); text(buf); } } diff --git a/editor/tests/raycast-test.cpp b/editor/tests/raycast-test.cpp index d1f72b70..6596303f 100644 --- a/editor/tests/raycast-test.cpp +++ b/editor/tests/raycast-test.cpp @@ -1,6 +1,7 @@ #include "../tests-private.hpp" #include "editor/app.hpp" #include "floormat/main.hpp" +#include "compat/array-size.hpp" #include "compat/shared-ptr-wrapper.hpp" #include "../imgui-raii.hpp" #include "src/critter.hpp" @@ -27,7 +28,7 @@ struct pending_s void print_coord(auto&& buf, Vector3i c, Vector2i l, Vector2i p) { - std::snprintf(buf, std::size(buf), "(ch %dx%d) <%dx%d> {%dx%d px}", c.x(), c.y(), l.x(), l.y(), p.x(), p.y()); + std::snprintf(buf, array_size(buf), "(ch %dx%d) <%dx%d> {%dx%d px}", c.x(), c.y(), l.x(), l.y(), p.x(), p.y()); } void print_coord_(auto&& buf, point pt) @@ -40,7 +41,7 @@ void print_coord_(auto&& buf, point pt) void print_vec2(auto&& buf, Vector2 vec) { - std::snprintf(buf, std::size(buf), "(%.2f x %.2f)", (double)vec.x(), (double)vec.y()); + std::snprintf(buf, array_size(buf), "(%.2f x %.2f)", (double)vec.x(), (double)vec.y()); } void do_column(StringView name) @@ -197,7 +198,7 @@ struct raycast_test final : base_test } do_column("collider"); - std::snprintf(buf, std::size(buf), "%s @ %" PRIu64, + std::snprintf(buf, array_size(buf), "%s @ %" PRIu64, type, uint64_t{result.collider.data}); { auto b = push_style_color(ImGuiCol_Text, 0xffff00ff_rgbaf); text(buf); @@ -207,13 +208,13 @@ struct raycast_test final : base_test ImGui::NewLine(); do_column("dir"); - std::snprintf(buf, std::size(buf), "%.4f x %.4f", (double)diag.dir.x(), (double)diag.dir.y()); + std::snprintf(buf, array_size(buf), "%.4f x %.4f", (double)diag.dir.x(), (double)diag.dir.y()); text(buf); if (!result.success) { do_column("tmin"); - std::snprintf(buf, std::size(buf), "%f / %f", + std::snprintf(buf, array_size(buf), "%f / %f", (double)diag.tmin, (double)(diag.tmin / diag.V.length())); text(buf); @@ -221,7 +222,7 @@ struct raycast_test final : base_test else { do_column("tmin"); - std::snprintf(buf, std::size(buf), "%f / %f", + std::snprintf(buf, array_size(buf), "%f / %f", (double)diag.V.length(), 1.0); text(buf); } @@ -231,7 +232,7 @@ struct raycast_test final : base_test text(buf); do_column("||dir^-1||"); - std::snprintf(buf, std::size(buf), "%f x %f", + std::snprintf(buf, array_size(buf), "%f x %f", (double)diag.dir_inv_norm.x(), (double)diag.dir_inv_norm.y()); text(buf); @@ -239,15 +240,15 @@ struct raycast_test final : base_test ImGui::NewLine(); do_column("bbox-size"); - std::snprintf(buf, std::size(buf), "(%u x %u)", diag.size.x(), diag.size.y()); + std::snprintf(buf, array_size(buf), "(%u x %u)", diag.size.x(), diag.size.y()); text(buf); do_column("path-len"); - std::snprintf(buf, std::size(buf), "%zu", diag.path.size()); + std::snprintf(buf, array_size(buf), "%zu", diag.path.size()); text(buf); do_column("time"); - std::snprintf(buf, std::size(buf), "%.3f ms", (double)(1000 * result.time)); + std::snprintf(buf, array_size(buf), "%.3f ms", (double)(1000 * result.time)); text(buf); } } |
