This commit is contained in:
Oliver Atkinson
2025-01-15 15:12:17 -07:00
commit a19475e7e6
10 changed files with 472 additions and 0 deletions

11
test/README Normal file
View File

@@ -0,0 +1,11 @@
This directory is intended for PlatformIO Test Runner and project tests.
Unit Testing is a software testing method by which individual units of
source code, sets of one or more MCU program modules together with associated
control data, usage procedures, and operating procedures, are tested to
determine whether they are fit for use. Unit testing finds problems early
in the development cycle.
More information about PlatformIO Unit Testing:
- https://docs.platformio.org/en/latest/advanced/unit-testing/index.html

33
test/test.cpp Normal file
View File

@@ -0,0 +1,33 @@
#include "unity.h"
#include "cmd/write.h"
void setUp() {}
void tearDown() {}
void test_byte_ordering() {
uint8_t expected[9] = {
0xF0, // Begin
0x05, // size ({data bytes}+4)
0x36, // dev addr
0x78, // class addr
0x02, // subclass addr
0x00, // r/w flag (0 = write, 1 = read)
0x64, // data
0x14, // Checksum (dev addr + sub addr + class addr + rw flag + data) & 0xFF
0xFF, // End
};
Addr cmd = *new Addr(FuncCommands::Brightness);
uint8_t data[] = {0x64};
uint8_t buf[1+8];
command(cmd, data, 1, buf);
TEST_ASSERT_EQUAL(expected, buf);
}
int main() {
UNITY_BEGIN();
RUN_TEST(test_byte_ordering);
return UNITY_END();
}