diff options
author | Christopher Peplin <chris.peplin@rhubarbtech.com> | 2013-12-27 21:46:15 -0500 |
---|---|---|
committer | Christopher Peplin <chris.peplin@rhubarbtech.com> | 2013-12-27 21:46:15 -0500 |
commit | 9fadf3909846796d3666c5b8f9cbec9fc4e979c4 (patch) | |
tree | 3bba6733ba16a08e901c8ad103f9e8469a7ea3ec /tests/test_receive.c | |
parent | 451ee4faa42eb304b27aeeef8c75387b4a12a614 (diff) |
Test basic rx of a single frame message.
Diffstat (limited to 'tests/test_receive.c')
-rw-r--r-- | tests/test_receive.c | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/tests/test_receive.c b/tests/test_receive.c index 2da2e897..d624a1fc 100644 --- a/tests/test_receive.c +++ b/tests/test_receive.c @@ -27,7 +27,7 @@ extern void setup(); START_TEST (test_receive_wrong_id) { - const uint8_t data[8] = {0}; + const uint64_t data = 0; isotp_receive_can_frame(&ISOTP_HANDLER, 0x100, data, sizeof(data)); fail_if(message_was_received); } @@ -36,21 +36,31 @@ END_TEST START_TEST (test_receive_bad_pci) { // 4 is a reserved number for the PCI field - only 0-3 are allowed - const uint8_t data[8] = {0x40}; + const uint64_t data = {0x4000000000000000}; isotp_receive_can_frame(&ISOTP_HANDLER, 0x2a, data, sizeof(data)); fail_if(message_was_received); } END_TEST +START_TEST (test_receive_single_frame_empty_payload) +{ + const uint64_t data = {0x0012340000000000}; + isotp_receive_can_frame(&ISOTP_HANDLER, 0x2a, data, sizeof(data)); + fail_unless(message_was_received); + ck_assert_int_eq(last_message_received_arb_id, 0x2a); + ck_assert_int_eq(last_message_received_payload_size, 0); +} +END_TEST + START_TEST (test_receive_single_frame) { - const uint8_t data[8] = {0x0, 0x12, 0x34}; + const uint64_t data = {0x0212340000000000}; isotp_receive_can_frame(&ISOTP_HANDLER, 0x2a, data, sizeof(data)); fail_unless(message_was_received); ck_assert_int_eq(last_message_received_arb_id, 0x2a); ck_assert_int_eq(last_message_received_payload_size, 2); ck_assert_int_eq(last_message_received_payload[0], 0x12); - ck_assert_int_eq(last_message_received_payload[0], 0x34); + ck_assert_int_eq(last_message_received_payload[1], 0x34); } END_TEST @@ -61,6 +71,7 @@ Suite* testSuite(void) { tcase_add_test(tc_core, test_receive_wrong_id); tcase_add_test(tc_core, test_receive_bad_pci); tcase_add_test(tc_core, test_receive_single_frame); + tcase_add_test(tc_core, test_receive_single_frame_empty_payload); suite_add_tcase(s, tc_core); return s; |