From 437dd5940bad6133561cb896cd558881fa5c8b44 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 6 Oct 2022 17:30:31 +0200 Subject: a --- test/app.hpp | 13 +++++++++++++ test/json.cpp | 29 +++++++++++++++++++++++++++++ test/main.cpp | 47 ++++++++++++----------------------------------- 3 files changed, 54 insertions(+), 35 deletions(-) create mode 100644 test/app.hpp create mode 100644 test/json.cpp (limited to 'test') diff --git a/test/app.hpp b/test/app.hpp new file mode 100644 index 00000000..53ee24b5 --- /dev/null +++ b/test/app.hpp @@ -0,0 +1,13 @@ +#pragma once +#include +#include +namespace Magnum::Examples { +struct app final : Platform::Application // NOLINT(cppcoreguidelines-virtual-class-destructor) +{ + explicit app(const Arguments& arguments); + ~app(); + void drawEvent() override; + static void test_json(); + void test(); +}; +} // namespace Magnum::Examples diff --git a/test/json.cpp b/test/json.cpp new file mode 100644 index 00000000..51bc6f80 --- /dev/null +++ b/test/json.cpp @@ -0,0 +1,29 @@ +#include "app.hpp" +#include "serialize/tile-atlas.hpp" +#include "serialize/magnum-vector.hpp" +#include "serialize/json-helper.hpp" +#include "compat/assert.hpp" +#include "tile-atlas.hpp" +#include "loader.hpp" + +namespace Magnum::Examples { +void app::test_json() // NOLINT(readability-convert-member-functions-to-static) +{ + bool ret = true; + using nlohmann::to_json; + const std::filesystem::path output_dir = "f:/dev/game/build/test/"; + { + nlohmann::json j; + auto atlas = loader.tile_atlas("share/game/images/metal1.tga", {2, 2}); + ret &= json_helper::to_json(atlas, output_dir/"atlas.json"); + } + { + Magnum::Math::Vector<2, int> v2i_1{1, 2}; + Vector2 v2i_2{2, 3}; + ret &= json_helper::to_json(v2i_1, output_dir/"vec2i_1.json"); + ret &= json_helper::to_json(v2i_2, output_dir/"vec2i_2.json"); + } + ASSERT(ret); +} + +} // namespace Magnum::Examples diff --git a/test/main.cpp b/test/main.cpp index f7014255..dffb19e1 100644 --- a/test/main.cpp +++ b/test/main.cpp @@ -1,35 +1,26 @@ -#include -#include -#include "compat/assert.hpp" -#include "tile-atlas.hpp" -#include "serialize/tile-atlas.hpp" -#include "serialize/json-helper.hpp" +#include "app.hpp" #include "loader.hpp" -#include "serialize/magnum-vector.hpp" +#include +#include +#include +#include +#include namespace Magnum::Examples { -struct app final : Platform::Application -{ - using dpi_policy = Platform::Implementation::Sdl2DpiScalingPolicy; - - explicit app(const Arguments& arguments); - ~app(); - void drawEvent() override; - void test(); -}; - app::app(const Arguments& arguments): Platform::Application{ arguments, Configuration{} .setTitle("Test") - .setSize({1024, 768}, dpi_policy::Physical), + .setSize({1024, 768}, Platform::Implementation::Sdl2DpiScalingPolicy::Physical), GLConfiguration{} .setSampleCount(4) - //.setFlags(Platform::Sdl2Application::GLConfiguration::Flag::Debug) + .setFlags(Platform::Sdl2Application::GLConfiguration::Flag::Debug) } { + if (auto path_opt = Utility::Path::executableLocation(); path_opt) + std::filesystem::current_path(std::string{Utility::Path::split(*path_opt).first()}); } app::~app() @@ -43,11 +34,9 @@ void app::drawEvent() Platform::Sdl2Application::exit(0); } -void app::test() // NOLINT(readability-convert-member-functions-to-static) +void app::test() { - auto atlas = loader.tile_atlas("../share/game/images/metal1.tga", {2, 2}); - bool ret = json_helper>::to_json(atlas, "f:/dev/game/build/test/atlas.json"); - ASSERT(ret); + test_json(); } } // namespace Magnum::Examples @@ -55,15 +44,3 @@ void app::test() // NOLINT(readability-convert-member-functions-to-static) using namespace Magnum::Examples; MAGNUM_APPLICATION_MAIN(Magnum::Examples::app) - -#ifdef _MSC_VER -# include -# ifdef __clang__ -# pragma clang diagnostic ignored "-Wmissing-prototypes" -# pragma clang diagnostic ignored "-Wmain" -# endif - -extern "C" int __stdcall WinMain(void*, void*, void*, int /* nCmdShow */) { - return main(__argc, __argv); -} -#endif -- cgit v1.2.3