restructuring, testing
This commit is contained in:
36
sensor433/test/test_desktop/test_sensor.cpp
Normal file
36
sensor433/test/test_desktop/test_sensor.cpp
Normal 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;
|
||||
}
|
||||
Reference in New Issue
Block a user