| 200 | #include "fl/stl/type_traits.h" |
| 201 | |
| 202 | FL_TEST_FILE(FL_FILEPATH) { |
| 203 | |
| 204 | FL_TEST_CASE("not_null - works with CRGB pointer") { |
| 205 | fl::CRGB pixel(255, 128, 64); |
| 206 | not_null<fl::CRGB*> ptr(&pixel); |
| 207 | |
| 208 | FL_CHECK(ptr->r == 255); |
| 209 | FL_CHECK(ptr->g == 128); |
| 210 | FL_CHECK(ptr->b == 64); |
| 211 | } |
| 212 | |
| 213 | FL_TEST_CASE("not_null - array of CRGB pixels") { |
| 214 | fl::CRGB pixels[3]; |
| 215 | pixels[0] = fl::CRGB(255, 0, 0); // Red |
| 216 | pixels[1] = fl::CRGB(0, 255, 0); // Green |
| 217 | pixels[2] = fl::CRGB(0, 0, 255); // Blue |
| 218 | |
| 219 | not_null<fl::CRGB*> ptr(pixels); |
| 220 | |
| 221 | FL_CHECK(ptr[0].r == 255); |
| 222 | FL_CHECK(ptr[1].g == 255); |
| 223 | FL_CHECK(ptr[2].b == 255); |
| 224 | } |
| 225 | |
| 226 | FL_TEST_CASE("not_null - modify CRGB through pointer") { |
| 227 | fl::CRGB pixel(0, 0, 0); |
| 228 | not_null<fl::CRGB*> ptr(&pixel); |
| 229 | |
| 230 | ptr->r = 255; |
| 231 | ptr->g = 128; |
| 232 | ptr->b = 64; |
| 233 | |
| 234 | FL_CHECK(pixel.r == 255); |
| 235 | FL_CHECK(pixel.g == 128); |
| 236 | FL_CHECK(pixel.b == 64); |
| 237 | } |
| 238 | |
| 239 | FL_TEST_CASE("not_null - const CRGB pointer") { |
| 240 | const fl::CRGB pixel(255, 128, 64); |
| 241 | not_null<const fl::CRGB*> ptr(&pixel); |
| 242 | |
| 243 | FL_CHECK(ptr->r == 255); |
| 244 | FL_CHECK(ptr->g == 128); |
| 245 | FL_CHECK(ptr->b == 64); |
| 246 | } |
| 247 | |
| 248 | // ============================================================================ |
| 249 | // Edge Case Tests: Function-like usage patterns |
| 250 | // ============================================================================ |
| 251 | |
| 252 | // Helper function demonstrating typical FastLED usage pattern |
| 253 | static void setPixelsRed(not_null<fl::CRGB*> leds, int count) { |
| 254 | // No need to check for null - guaranteed by type |
| 255 | for (int i = 0; i < count; i++) { |
| 256 | leds[i] = fl::CRGB(255, 0, 0); |
| 257 | } |
| 258 | } |
| 259 |
nothing calls this directly
no test coverage detected