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

Function FL_TEST_FILE

tests/fl/stl/bitset.cpp:7–377  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5#include "fl/stl/int.h"
6
7FL_TEST_FILE(FL_FILEPATH) {
8
9using namespace fl;
10
11// Test the utility functions
12FL_TEST_CASE("fl::popcount") {
13 FL_CHECK_EQ(popcount(0u), 0);
14 FL_CHECK_EQ(popcount(1u), 1);
15 FL_CHECK_EQ(popcount(3u), 2);
16 FL_CHECK_EQ(popcount(7u), 3);
17 FL_CHECK_EQ(popcount(15u), 4);
18 FL_CHECK_EQ(popcount(255u), 8);
19}
20
21FL_TEST_CASE("fl::countr_zero") {
22 FL_CHECK_EQ(countr_zero(1u), 0);
23 FL_CHECK_EQ(countr_zero(2u), 1);
24 FL_CHECK_EQ(countr_zero(4u), 2);
25 FL_CHECK_EQ(countr_zero(8u), 3);
26 FL_CHECK_EQ(countr_zero(16u), 4);
27}
28
29// Test bitset_fixed class
30FL_TEST_CASE("fl::bitset_fixed<8> - basic operations") {
31 bitset_fixed<8> bs;
32
33 FL_SUBCASE("construction and size") {
34 FL_CHECK_EQ(bs.size(), 8);
35 FL_CHECK(bs.none());
36 FL_CHECK(!bs.any());
37 }
38
39 FL_SUBCASE("set and test") {
40 bs.set(0);
41 FL_CHECK(bs.test(0));
42 FL_CHECK(!bs.test(1));
43 FL_CHECK(bs.any());
44 FL_CHECK_EQ(bs.count(), 1);
45
46 bs.set(7);
47 FL_CHECK(bs.test(7));
48 FL_CHECK_EQ(bs.count(), 2);
49 }
50
51 FL_SUBCASE("reset") {
52 bs.set(0).set(3).set(7);
53 FL_CHECK_EQ(bs.count(), 3);
54
55 bs.reset(3);
56 FL_CHECK(!bs.test(3));
57 FL_CHECK_EQ(bs.count(), 2);
58
59 bs.reset();
60 FL_CHECK(bs.none());
61 }
62
63 FL_SUBCASE("flip") {
64 bs.flip(2);

Callers

nothing calls this directly

Calls 14

popcountFunction · 0.85
countr_zeroFunction · 0.85
flipMethod · 0.80
find_runMethod · 0.80
anyMethod · 0.65
sizeMethod · 0.45
noneMethod · 0.45
setMethod · 0.45
testMethod · 0.45
countMethod · 0.45
resetMethod · 0.45
assignMethod · 0.45

Tested by

no test coverage detected