45 lines
1.3 KiB
C++
45 lines
1.3 KiB
C++
//
|
|
// Created by martin on 11.04.25.
|
|
//
|
|
|
|
#include "3rdparty/json/json.hpp"
|
|
#include "AnimGraph/AnimLibrary.h"
|
|
#include "TestAnimData.h"
|
|
#include "catch.hpp"
|
|
|
|
using namespace nlohmann;
|
|
|
|
TEST_CASE("Serialize AnimLibrary", "[AnimLibrary]") {
|
|
AnimLibrary library;
|
|
|
|
TestAnimData::SingleBoneSkeleton single_bone_testdata;
|
|
|
|
REQUIRE(library.AddAnimationFile(
|
|
"translation_x",
|
|
single_bone_testdata.animation_translate_x_resource.m_filename));
|
|
REQUIRE(library.AddAnimationFile(
|
|
"translation_y",
|
|
single_bone_testdata.animation_translate_y_resource.m_filename));
|
|
|
|
// We're not actually doing anything with the animations, however loading them here ensures that
|
|
// when running valgrind a memory leak is detected.
|
|
library.LoadAnimations();
|
|
|
|
// serialize
|
|
json library_data;
|
|
library_data = library;
|
|
|
|
// deserialize
|
|
AnimLibrary library_deserialized;
|
|
library_deserialized = library_data;
|
|
|
|
CHECK(library_deserialized.mAnimations.size() == library.mAnimations.size());
|
|
for (AnimLibrary::AnimationResourceMap::const_iterator iter =
|
|
library.mAnimations.cbegin();
|
|
iter != library.mAnimations.cend();
|
|
++iter) {
|
|
CHECK(
|
|
library_deserialized.mAnimations.find(iter->first)
|
|
!= library_deserialized.mAnimations.end());
|
|
}
|
|
} |