From fbac21cf14be13e39b7848863e3d84377707c970 Mon Sep 17 00:00:00 2001 From: Martin Felis Date: Tue, 16 Nov 2021 18:23:04 +0100 Subject: [PATCH] Simple sync track blending tests. --- CMakeLists.txt | 3 ++- tests/SyncTrackTests.cc | 40 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b8f48d9..5ccb793 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.13) -cmake_policy(SET CMP0077 NEW) +set(CMAKE_POLICY_DEFAULT_CMP0077 NEW) project(AnimTestbed VERSION 0.0.1 @@ -83,6 +83,7 @@ add_executable(runtests) target_sources(runtests PRIVATE tests/main.cc tests/SyncTrackTests.cc) target_include_directories( runtests + PUBLIC $ ${ThirdPartyIncludeDeps} ) diff --git a/tests/SyncTrackTests.cc b/tests/SyncTrackTests.cc index edddcf7..816bef5 100644 --- a/tests/SyncTrackTests.cc +++ b/tests/SyncTrackTests.cc @@ -3,3 +3,43 @@ // #include "catch.hpp" + +#include "SkinnedMesh.h" + +TEST_CASE("SyncTrackBlendSimple", "[SyncTrackBlend]") { + SyncTrack track_A; + track_A.m_num_intervals = 2; + track_A.m_duration = 1.0; + track_A.m_interval_durations[0] = 0.8; + track_A.m_interval_durations[1] = 0.2; + + SyncTrack track_B; + track_B.m_num_intervals = 2; + track_B.m_duration = 2.0; + track_B.m_interval_durations[0] = 0.1; + track_B.m_interval_durations[1] = 0.9; + + WHEN("Blending two synctracks with weight 0.") { + SyncTrack blended = SyncTrack::Blend(0.f, track_A, track_B); + + THEN ("Result must equal track_A") { + REQUIRE(blended.m_duration == track_A.m_duration); + REQUIRE( + blended.m_interval_durations[0] == track_A.m_interval_durations[0]); + REQUIRE( + blended.m_interval_durations[1] == track_A.m_interval_durations[1]); + } + } + + WHEN("Blending two synctracks with weight 1.") { + SyncTrack blended = SyncTrack::Blend(1.f, track_A, track_B); + + THEN ("Result must equal track_B") { + REQUIRE(blended.m_duration == track_B.m_duration); + REQUIRE( + blended.m_interval_durations[0] == track_B.m_interval_durations[0]); + REQUIRE( + blended.m_interval_durations[1] == track_B.m_interval_durations[1]); + } + } +}