summaryrefslogtreecommitdiffhomepage
path: root/test/json.cpp
blob: 51bc6f80e5c97080e42e21e11331fa5d145231db (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
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