restructuring, testing

This commit is contained in:
2021-05-02 01:20:47 +02:00
parent 009a035bc7
commit 61374b584a
6 changed files with 178 additions and 80 deletions

View File

@@ -0,0 +1,36 @@
#include <unity.h>
#include <Arduino.h>
#include "config.h"
#include "sensor433.h"
// somehow not possible to use method from sensor433.h/cpp, linking fails:
uint8_t add_device_id(uint8_t value, uint8_t device_id) {
return value |= device_id;
}
void test_message_header() {
uint8_t header = MSG_START;
header = add_device_id(header, DEVICE_ID);
// 0x10 | 0x01 = 0x11
TEST_ASSERT_EQUAL(0x11, header);
// header
TEST_ASSERT_EQUAL(0x10, header & 0x10);
// id
TEST_ASSERT_EQUAL(0x01, header & 0x01);
}
int main(int argc, char **argv) {
UNITY_BEGIN();
RUN_TEST(test_message_header);
UNITY_END();
return 0;
}