finished adidas v1.0

This commit is contained in:
Rens Pastoor
2025-06-05 15:19:10 +02:00
parent 8e5cfa974b
commit 34ebc83b3e
6 changed files with 81 additions and 37 deletions

View File

@@ -6,26 +6,28 @@
// I rather dislike keeping line numbers updated, so I made my own macro to ditch the line number
#define MY_RUN_TEST(func) RUN_TEST(func, 0)
extern void channel_setUp(void)
{
// This is run before EACH test
extern void channel_setUp(void){
channel_init();
}
extern void channel_tearDown(void) {}
void test_channel_all_zero_test(){
uint8_t value = 0x00;
uint8_t result = channel_change_one_random_bit(value);
TEST_ASSERT_NOT_EQUAL(value, result);
}
extern void channel_tearDown(void)
{
// This is run after EACH test
void test_channel_all_one_test(){
uint8_t value = 0xFF;
uint8_t result = channel_change_one_random_bit(value);
TEST_ASSERT_NOT_EQUAL(value, result);
}
static void test_channel(void)
{
TEST_ASSERT_EQUAL(1, 0);
}
void run_channel_tests()
{
void run_channel_tests(){
UnityRegisterSetupTearDown( channel_setUp, channel_tearDown);
MY_RUN_TEST(test_channel);
MY_RUN_TEST(test_channel_all_zero_test);
MY_RUN_TEST(test_channel_all_one_test);
UnityUnregisterSetupTearDown();
}

View File

@@ -5,26 +5,61 @@
// I rather dislike keeping line numbers updated, so I made my own macro to ditch the line number
#define MY_RUN_TEST(func) RUN_TEST(func, 0)
extern void decode_setUp(void)
{
// This is run before EACH test
extern void decode_setUp(void) {}
extern void decode_tearDown(void) {}
// Format: [0][d3][d2][d1][d0][p2][p1][p0] (MSB first)
//general decode combine nibbles test
void test_decode_get_nibbles_normal(void){
uint8_t high = 0b01101100, low = 0b01001001;
// high data: 1101 or 0xD and low data: 1001 or 0x9
TEST_ASSERT_EQUAL(0xD9, decode_combine_nibbles(high, low)); // so the result should be 0b11011001 or 0xD9
}
extern void decode_tearDown(void)
{
// This is run after EACH test
void test_decode_get_nibbles_zero(void){
uint8_t high = 0b00000000, low = 0b00000000;
// high data: 0000 or 0x0 and low data: 0000 or 0x0
TEST_ASSERT_EQUAL(0x00, decode_combine_nibbles(high, low)); // so the result should be 0b00000000 or 0x00
}
void test_decode(void)
{
TEST_ASSERT_EQUAL(1, 0);
void test_decode_get_nibbles_all_ones(void){
uint8_t high = 0b11111111, low = 0b11111111;
// high data: 1111 or 0xF and low data: 1111 or 0xF
TEST_ASSERT_EQUAL(0xFF, decode_combine_nibbles(high, low)); // so the result should be 0b11111111 or 0xFF
}
void test_decode_MSB_flip (void){
uint8_t high = 0b11101100, low = 0b11001001;
// high data: 1101 or 0xD and low data: 1001 or 0x9
// but the MSB is flipped
TEST_ASSERT_EQUAL(0xD9, decode_combine_nibbles(high, low)); // so the result should be 0b11011001 or 0xD9
}
//
// parity bit testing
void test_decode_databit_flip (void){
uint8_t wrong_data = 0b01001100; // this should be 0b01101100 or unparityd 0b1101, 0xD
uint8_t right_data; // this is the correct data
decode_byte(wrong_data, &right_data);
TEST_ASSERT_EQUAL(0xD, right_data); // so the result should be 0b01101100 or 0xD
}
void test_decode_common_databit_flip (void){ // the common databit is d0
uint8_t wrong_data = 0b01100100; // this should be 0b01101100 or unparityd 0b1101, 0xD
uint8_t right_data; // this is the correct data
decode_byte(wrong_data, &right_data);
TEST_ASSERT_EQUAL(0xD, right_data); // so the result should be 0b01101100 or 0xD
}
void test_decode_parity_flip(void){
uint8_t wrong_data = 0b01101101; // this should be 0b01101100 or unparityd 0b1101, 0xD
uint8_t right_data; // this is the correct data
decode_byte(wrong_data, &right_data);
TEST_ASSERT_EQUAL(0xD, right_data); // so the result should be 0b01101100 or 0xD
}
//
void run_decode_tests(){
UnityRegisterSetupTearDown(decode_setUp, decode_tearDown);
void run_decode_tests()
{
UnityRegisterSetupTearDown( decode_setUp, decode_tearDown);
MY_RUN_TEST(test_decode);
MY_RUN_TEST(test_decode_get_nibbles_normal);
MY_RUN_TEST(test_decode_get_nibbles_zero);
MY_RUN_TEST(test_decode_get_nibbles_all_ones);
MY_RUN_TEST(test_decode_MSB_flip);
MY_RUN_TEST(test_decode_databit_flip);
UnityUnregisterSetupTearDown();
}