MCPcopy Create free account
hub / github.com/FastLED/FastLED / FL_TEST_FILE

Function FL_TEST_FILE

tests/fl/fx/time.cpp:8–59  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6#include "test.h"
7
8FL_TEST_FILE(FL_FILEPATH) {
9using namespace fl;
10FL_TEST_CASE("TimeWarp basic functionality") {
11
12 FL_SUBCASE("Initialization and normal time progression") {
13 TimeWarp tw(1000, 1.0f); // 1000 ms is the start time, speed is set at 1x
14 FL_CHECK(tw.time() == 0);
15 FL_CHECK(tw.scale() == 1.0f);
16
17 tw.update(2000);
18 FL_CHECK(tw.time() == 1000);
19 }
20
21 FL_SUBCASE("Time scaling") {
22 TimeWarp tw(1000);
23 tw.setSpeed(2.0f); // now we are at 2x speed.
24 FL_CHECK(tw.time() == 0); // at t0 = 1000ms
25
26 tw.update(1500); // we give 500 at 2x => add 1000 to time counter.
27 FL_CHECK(tw.time() == 1000);
28
29 tw.setSpeed(0.5f); // Set half speed: 500ms.
30 FL_CHECK(tw.scale() == 0.5f);
31
32 tw.update(2500);
33 FL_CHECK(tw.time() == 1500);
34 }
35
36 FL_SUBCASE("Reset functionality") {
37 TimeWarp tw(1000, 1.0f);
38 tw.update(2000);
39 FL_CHECK(tw.time() == 1000);
40
41 tw.reset(3000);
42 FL_CHECK(tw.time() == 0);
43
44 tw.update(4000);
45 FL_CHECK(tw.time() == 1000);
46 }
47
48 FL_SUBCASE("Wrap-around protection - prevent from going below start time") {
49 TimeWarp tw(1000, 1.0f);
50 tw.update(1001);
51 FL_CHECK(tw.time() == 1);
52 tw.setSpeed(-1.0f);
53 tw.update(2000);
54 FL_CHECK_EQ(tw.time(), 0);
55 }
56
57}
58
59} // FL_TEST_FILE

Callers

nothing calls this directly

Calls 5

timeMethod · 0.80
scaleMethod · 0.45
updateMethod · 0.45
setSpeedMethod · 0.45
resetMethod · 0.45

Tested by

no test coverage detected