STAR
Cal STAR — firmware, DAQ server, and engine design
Loading...
Searching...
No Matches
test_main.cpp File Reference
#include <string.h>
#include "unity.h"
#include "../../../src/radio/frame.cpp"
Include dependency graph for test_main.cpp:

Go to the source code of this file.

Functions

void setUp (void)
void tearDown (void)
static size_t raw_frame (uint8_t *out, uint8_t type, uint16_t seq, const uint8_t *payload, uint8_t plen)
static void test_crc16_standard_check_value (void)
static void test_crc16_empty_is_init_value (void)
static void test_little_endian_helpers (void)
static void test_encode_matches_golden_un_arm (void)
static void test_encode_matches_golden_arm (void)
static void test_decode_golden_heartbeat (void)
static void test_roundtrip_every_type (void)
static void test_decode_rejects_too_short (void)
static void test_decode_rejects_null_buffer (void)
static void test_decode_rejects_wrong_version (void)
static void test_decode_rejects_extra_or_missing_bytes (void)
static void test_decode_rejects_oversize_length_field (void)
static void test_decode_rejects_any_single_bit_flip (void)
static void test_decode_rejects_unknown_type_with_valid_crc (void)
static void test_decode_rejects_wrong_payload_size_with_valid_crc (void)
static void test_encode_rejects_bad_inputs (void)
int main (void)

Variables

static const uint8_t GOLDEN_UN_ARM []
static const uint8_t GOLDEN_ARM []
static const uint8_t GOLDEN_HEARTBEAT []

Function Documentation

◆ main()

◆ raw_frame()

size_t raw_frame ( uint8_t * out,
uint8_t type,
uint16_t seq,
const uint8_t * payload,
uint8_t plen )
static

◆ setUp()

void setUp ( void )

Definition at line 11 of file test_main.cpp.

◆ tearDown()

void tearDown ( void )

Definition at line 13 of file test_main.cpp.

◆ test_crc16_empty_is_init_value()

void test_crc16_empty_is_init_value ( void )
static

Definition at line 46 of file test_main.cpp.

References radio_link::crc16().

Referenced by main().

◆ test_crc16_standard_check_value()

void test_crc16_standard_check_value ( void )
static

Definition at line 41 of file test_main.cpp.

References radio_link::crc16().

Referenced by main().

◆ test_decode_golden_heartbeat()

◆ test_decode_rejects_any_single_bit_flip()

void test_decode_rejects_any_single_bit_flip ( void )
static

Definition at line 173 of file test_main.cpp.

References b, radio_link::decode_frame(), GOLDEN_ARM, and radio_link::Ok.

Referenced by main().

◆ test_decode_rejects_extra_or_missing_bytes()

void test_decode_rejects_extra_or_missing_bytes ( void )
static

◆ test_decode_rejects_null_buffer()

void test_decode_rejects_null_buffer ( void )
static

Definition at line 136 of file test_main.cpp.

References radio_link::decode_frame(), and radio_link::ErrArgs.

Referenced by main().

◆ test_decode_rejects_oversize_length_field()

void test_decode_rejects_oversize_length_field ( void )
static

◆ test_decode_rejects_too_short()

void test_decode_rejects_too_short ( void )
static

Definition at line 128 of file test_main.cpp.

References radio_link::decode_frame(), radio_link::ErrTooShort, and GOLDEN_UN_ARM.

Referenced by main().

◆ test_decode_rejects_unknown_type_with_valid_crc()

void test_decode_rejects_unknown_type_with_valid_crc ( void )
static

Definition at line 190 of file test_main.cpp.

References b, radio_link::decode_frame(), radio_link::ErrType, and raw_frame().

Referenced by main().

◆ test_decode_rejects_wrong_payload_size_with_valid_crc()

void test_decode_rejects_wrong_payload_size_with_valid_crc ( void )
static

◆ test_decode_rejects_wrong_version()

void test_decode_rejects_wrong_version ( void )
static

Definition at line 141 of file test_main.cpp.

References b, radio_link::decode_frame(), radio_link::ErrVersion, raw_frame(), and radio_link::UnArm.

Referenced by main().

◆ test_encode_matches_golden_arm()

void test_encode_matches_golden_arm ( void )
static

◆ test_encode_matches_golden_un_arm()

void test_encode_matches_golden_un_arm ( void )
static

◆ test_encode_rejects_bad_inputs()

void test_encode_rejects_bad_inputs ( void )
static

◆ test_little_endian_helpers()

void test_little_endian_helpers ( void )
static

Definition at line 51 of file test_main.cpp.

References b, radio_link::get_u16(), radio_link::get_u32(), radio_link::put_u16(), and radio_link::put_u32().

Referenced by main().

◆ test_roundtrip_every_type()

Variable Documentation

◆ GOLDEN_ARM

const uint8_t GOLDEN_ARM[]
static
Initial value:
= {0x01, 0x10, 0x01, 0x00, 0x09, 0x5A,
0x96, 0xC3, 0xA5, 0xA5, 0x69, 0x3C,
0x5A, 0x07, 0xFA, 0xCF}

Definition at line 20 of file test_main.cpp.

Referenced by test_decode_rejects_any_single_bit_flip(), test_decode_rejects_extra_or_missing_bytes(), and test_encode_matches_golden_arm().

◆ GOLDEN_HEARTBEAT

const uint8_t GOLDEN_HEARTBEAT[]
static
Initial value:
= {0x01, 0x01, 0xEF, 0xBE, 0x07,
0x03, 0xE8, 0x1C, 0x40, 0xE2,
0x01, 0x00, 0xFD, 0x1B}

Definition at line 23 of file test_main.cpp.

Referenced by test_decode_golden_heartbeat().

◆ GOLDEN_UN_ARM

const uint8_t GOLDEN_UN_ARM[]
static
Initial value:
= {0x01, 0x11, 0x02, 0x01,
0x00, 0x1F, 0x8B}

Definition at line 18 of file test_main.cpp.

Referenced by test_decode_rejects_too_short(), and test_encode_matches_golden_un_arm().