forked from allen-cell-animated/agave
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_timeLine.cpp
76 lines (69 loc) · 1.81 KB
/
test_timeLine.cpp
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#include "catch.hpp"
#include "renderlib/Timeline.h"
TEST_CASE("Timeline", "[timeLine]")
{
SECTION("Timeline increment/decrement wrapping works")
{
Timeline t(0, 3);
REQUIRE(t.currentTime() == 0);
t.increment(1);
REQUIRE(t.currentTime() == 1);
t.increment(-2);
REQUIRE(t.currentTime() == 3);
t.increment(3);
REQUIRE(t.currentTime() == 2);
t.increment(10);
REQUIRE(t.currentTime() == 0);
t.increment(-10);
REQUIRE(t.currentTime() == 2);
}
SECTION("Timeline increment/decrement clamping works")
{
Timeline t(0, 3, Timeline::WrapMode::TIMELINE_CLAMP);
REQUIRE(t.currentTime() == 0);
t.increment(1);
REQUIRE(t.currentTime() == 1);
t.increment(-2);
REQUIRE(t.currentTime() == 0);
t.increment(3);
REQUIRE(t.currentTime() == 3);
t.increment(10);
REQUIRE(t.currentTime() == 3);
t.increment(-10);
REQUIRE(t.currentTime() == 0);
}
SECTION("Trivial default timeline works")
{
Timeline t;
REQUIRE(t.currentTime() == 0);
t.increment(1);
REQUIRE(t.currentTime() == 0);
t.increment(-2);
REQUIRE(t.currentTime() == 0);
t.increment(3);
REQUIRE(t.currentTime() == 0);
t.increment(10);
REQUIRE(t.currentTime() == 0);
t.increment(-10);
REQUIRE(t.currentTime() == 0);
}
SECTION("Changing the timeline range and clamp mode works")
{
Timeline t;
REQUIRE(t.currentTime() == 0);
t.increment(1);
REQUIRE(t.currentTime() == 0);
t.setRange(0, 7);
REQUIRE(t.currentTime() == 0);
t.increment(6);
REQUIRE(t.currentTime() == 6);
t.setRange(0, 4);
REQUIRE(t.currentTime() == 1);
// set to clamped
t.setWrap(Timeline::WrapMode::TIMELINE_CLAMP);
t.increment(7);
REQUIRE(t.currentTime() == 4);
t.setRange(0, 3);
REQUIRE(t.currentTime() == 3);
}
}