MCPcopy Create free account
hub / github.com/SmingHub/Sming / execute

Method execute

tests/HostTests/modules/BitSet.cpp:66–153  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

64 }
65
66 void execute() override
67 {
68 TEST_CASE("constexpr")
69 {
70 REQUIRE(fixedBasket.value() == (_BV(Fruit::orange) | _BV(Fruit::banana) | _BV(Fruit::tomato)));
71 }
72
73 TEST_CASE("Operations")
74 {
75 Serial << _F("fixedBasket contains: ") << fixedBasket << endl;
76
77 FruitBasket basket;
78 REQUIRE(basket.value() == 0);
79 REQUIRE(!basket);
80
81 basket += Fruit::pear | Fruit::tomato;
82 REQUIRE(basket);
83 REQUIRE(basket.value() == (_BV(Fruit::pear) | _BV(Fruit::tomato)));
84
85 basket += fixedBasket;
86 REQUIRE(basket.value() == (fixedBasket.value() | _BV(Fruit::pear)));
87
88 FruitBasket basket2 = Fruit::pear;
89 debug_i("basket = 0x%08x", basket.value());
90 debug_i("fixedBasket = 0x%08x", fixedBasket.value());
91 REQUIRE(basket != fixedBasket);
92 REQUIRE(!(basket == fixedBasket));
93 basket -= basket2;
94 REQUIRE(basket == fixedBasket);
95
96 FruitBasket empty;
97 REQUIRE(!(basket == empty));
98 REQUIRE(basket != empty);
99
100 basket -= Fruit::orange;
101 REQUIRE(basket.value() == (_BV(Fruit::banana) | _BV(Fruit::tomato)));
102
103 basket |= Fruit::kiwi;
104 REQUIRE(basket.value() == (_BV(Fruit::kiwi) | _BV(Fruit::banana) | _BV(Fruit::tomato)));
105
106 basket &= fixedBasket;
107 REQUIRE(basket.value() == (_BV(Fruit::banana) | _BV(Fruit::tomato)));
108
109 basket = ~fixedBasket;
110 debug_e("basket.value = 0x%08x", basket.value());
111 REQUIRE(basket.value() == (_BV(Fruit::apple) | _BV(Fruit::kiwi) | _BV(Fruit::passion) | _BV(Fruit::pear)));
112
113 REQUIRE(basket[Fruit::apple]);
114 REQUIRE(!basket[Fruit::tomato]);
115
116 REQUIRE(basket.domain().value() ==
117 (_BV(Fruit::apple) | _BV(Fruit::banana) | _BV(Fruit::kiwi) | _BV(Fruit::orange) |
118 _BV(Fruit::passion) | _BV(Fruit::pear) | _BV(Fruit::tomato)));
119 }
120
121 TEST_CASE("Number set")
122 {
123 using NumberSet = BitSet<uint32_t, uint8_t>;

Callers

nothing calls this directly

Calls 3

domainMethod · 0.80
toStringFunction · 0.70
valueMethod · 0.45

Tested by

no test coverage detected