#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();
}
