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

Function FL_TEST_FILE

tests/fl/stl/atomic.cpp:5–328  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3#include "platforms/shared/atomic.h"
4
5FL_TEST_FILE(FL_FILEPATH) {
6
7using namespace fl;
8
9// Test both AtomicFake (single-threaded) and AtomicReal (multi-threaded)
10// Note: Only test the common interface that both implementations support:
11// - load(), store()
12// - operator++, operator-- (pre-increment/decrement only)
13// - fetch_add(), fetch_sub()
14// - operator=, operator T() (conversion)
15
16FL_TEST_CASE("fl::atomic<int> - basic construction and initialization") {
17 FL_SUBCASE("default constructor initializes to zero") {
18 atomic_int a;
19 FL_CHECK_EQ(a.load(), 0);
20 }
21
22 FL_SUBCASE("value constructor initializes to given value") {
23 atomic_int a(42);
24 FL_CHECK_EQ(a.load(), 42);
25 }
26
27 FL_SUBCASE("conversion operator works") {
28 atomic_int a(100);
29 int value = a; // Implicit conversion
30 FL_CHECK_EQ(value, 100);
31 }
32}
33
34FL_TEST_CASE("fl::atomic<int> - store and load operations") {
35 atomic_int a;
36
37 FL_SUBCASE("store and load basic value") {
38 a.store(123);
39 FL_CHECK_EQ(a.load(), 123);
40 }
41
42 FL_SUBCASE("store negative value") {
43 a.store(-456);
44 FL_CHECK_EQ(a.load(), -456);
45 }
46
47 FL_SUBCASE("multiple stores") {
48 a.store(10);
49 FL_CHECK_EQ(a.load(), 10);
50 a.store(20);
51 FL_CHECK_EQ(a.load(), 20);
52 a.store(30);
53 FL_CHECK_EQ(a.load(), 30);
54 }
55
56 FL_SUBCASE("store with memory order parameters") {
57 a.store(100, memory_order_relaxed);
58 FL_CHECK_EQ(a.load(memory_order_relaxed), 100);
59
60 a.store(200, memory_order_release);
61 FL_CHECK_EQ(a.load(memory_order_acquire), 200);
62

Callers

nothing calls this directly

Calls 4

loadMethod · 0.45
storeMethod · 0.45
fetch_addMethod · 0.45
fetch_subMethod · 0.45

Tested by

no test coverage detected