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

Function FL_TEST_FILE

tests/fl/bytestream.cpp:15–259  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

13#include "hsv2rgb.h"
14
15FL_TEST_FILE(FL_FILEPATH) {
16
17FL_TEST_CASE("memorybuf basic operations") {
18
19 FL_SUBCASE("Write and read single byte") {
20 fl::memorybuf stream(10); // Stream with 10 bytes capacity
21 fl::u8 testByte = 42;
22 FL_CHECK(stream.write(fl::span<const fl::u8>(&testByte, 1)) == 1);
23
24 fl::u8 readByte = 0;
25 FL_CHECK(stream.read(&readByte, 1) == 1);
26 FL_CHECK(readByte == testByte);
27
28 // Next read should fail since the stream is empty
29 FL_CHECK(stream.read(&readByte, 1) == 0);
30 }
31
32 FL_SUBCASE("Write and read multiple bytes") {
33 fl::memorybuf stream(10);
34 fl::u8 testData[] = {1, 2, 3, 4, 5};
35 FL_CHECK(stream.write(fl::span<const fl::u8>(testData, 5)) == 5);
36
37 fl::u8 readData[5] = {0};
38 FL_CHECK(stream.read(readData, 5) == 5);
39 for (int i = 0; i < 5; ++i) {
40 FL_CHECK(readData[i] == testData[i]);
41 }
42 }
43
44 FL_SUBCASE("Attempt to read from empty stream") {
45 fl::memorybuf stream(10);
46 fl::u8 readByte = 0;
47 FL_CHECK(stream.read(&readByte, 1) == 0);
48 }
49
50 FL_SUBCASE("Attempt to write beyond capacity") {
51 fl::memorybuf stream(5);
52 fl::u8 testData[] = {1, 2, 3, 4, 5, 6};
53 FL_CHECK(stream.write(fl::span<const fl::u8>(testData, 6)) == 5); // Should write up to capacity
54 }
55
56 FL_SUBCASE("Attempt to read more than available data") {
57 fl::memorybuf stream(10);
58 fl::u8 testData[] = {1, 2, 3};
59 FL_CHECK(stream.write(fl::span<const fl::u8>(testData, 3)) == 3);
60
61 fl::u8 readData[5] = {0};
62 FL_CHECK(stream.read(readData, 5) == 3); // Should read only available data
63 }
64
65 FL_SUBCASE("Multiple write and read operations") {
66 fl::memorybuf stream(10);
67 fl::u8 testData1[] = {1, 2, 3};
68 fl::u8 testData2[] = {4, 5};
69 FL_CHECK(stream.write(fl::span<const fl::u8>(testData1, 3)) == 3);
70 FL_CHECK(stream.write(fl::span<const fl::u8>(testData2, 2)) == 2);
71
72 fl::u8 readData[5] = {0};

Callers

nothing calls this directly

Calls 9

bytesPerFrameMethod · 0.80
readPixelMethod · 0.80
writeMethod · 0.45
readMethod · 0.45
clearMethod · 0.45
beginMethod · 0.45
getTypeMethod · 0.45
readBytesMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected