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

Function FL_TEST_FILE

tests/fl/stl/chrono.cpp:8–537  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6#include "fl/stl/int.h"
7
8FL_TEST_FILE(FL_FILEPATH) {
9
10using namespace fl;
11
12FL_TEST_CASE("fl::time - basic functionality") {
13 FL_SUBCASE("time returns non-zero values") {
14 fl::u32 t1 = fl::millis();
15 FL_CHECK(t1 >= 0); // Always true, but documents expectation
16 }
17
18 FL_SUBCASE("time is monotonically increasing") {
19 fl::u32 t1 = fl::millis();
20 // Small delay to ensure time advances
21 volatile int dummy = 0;
22 for (int i = 0; i < 10000; ++i) {
23 dummy += i;
24 }
25 fl::u32 t2 = fl::millis();
26 // Time should be >= t1 (may be equal if very fast)
27 FL_CHECK(t2 >= t1);
28 }
29
30 FL_SUBCASE("time difference calculation") {
31 fl::u32 start = fl::millis();
32 // Small delay
33 volatile int dummy = 0;
34 for (int i = 0; i < 10000; ++i) {
35 dummy += i;
36 }
37 fl::u32 end = fl::millis();
38 fl::u32 elapsed = end - start;
39 // Elapsed should be small but >= 0
40 FL_CHECK(elapsed >= 0);
41 // Should be less than a reasonable threshold (e.g., 1 second)
42 FL_CHECK(elapsed < 1000);
43 }
44
45 FL_SUBCASE("multiple calls to time") {
46 fl::u32 t1 = fl::millis();
47 fl::u32 t2 = fl::millis();
48 fl::u32 t3 = fl::millis();
49
50 // All should be >= previous
51 FL_CHECK(t2 >= t1);
52 FL_CHECK(t3 >= t2);
53 }
54}
55
56#ifdef FASTLED_TESTING
57
58FL_TEST_CASE("fl::MockTimeProvider - basic functionality") {
59 FL_SUBCASE("constructor with initial time") {
60 MockTimeProvider mock(1000);
61 FL_CHECK_EQ(mock.current_time(), 1000);
62 }
63
64 FL_SUBCASE("constructor with default time") {
65 MockTimeProvider mock;

Callers

nothing calls this directly

Calls 8

inject_time_providerFunction · 0.85
clear_time_providerFunction · 0.85
millis64_resetFunction · 0.85
millis64Function · 0.85
current_timeMethod · 0.80
set_timeMethod · 0.80
millisFunction · 0.50
advanceMethod · 0.45

Tested by

no test coverage detected