init
This commit is contained in:
11
test/README
Normal file
11
test/README
Normal 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
33
test/test.cpp
Normal 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();
|
||||
}
|
Reference in New Issue
Block a user