2020-11-15 09:27:47 -08:00
|
|
|
#include "engine_test_helper.h"
|
|
|
|
#include "tunerstudio_io.h"
|
|
|
|
|
|
|
|
extern int sr5TestWriteDataIndex;
|
|
|
|
extern uint8_t st5TestBuffer[16000];
|
|
|
|
|
|
|
|
#define CODE 2
|
|
|
|
#define PAYLOAD "123"
|
|
|
|
#define SIZE strlen(PAYLOAD)
|
|
|
|
|
2020-11-15 09:36:07 -08:00
|
|
|
static void assertCrcPacket() {
|
2020-11-15 09:27:47 -08:00
|
|
|
ASSERT_EQ(sr5TestWriteDataIndex, SIZE + 7);
|
|
|
|
|
|
|
|
// todo: proper uint16 comparison
|
|
|
|
ASSERT_EQ(st5TestBuffer[0], 0);
|
|
|
|
ASSERT_EQ(st5TestBuffer[1], SIZE + 1);
|
|
|
|
|
|
|
|
ASSERT_EQ(st5TestBuffer[2], CODE);
|
|
|
|
|
|
|
|
ASSERT_EQ(memcmp(&st5TestBuffer[3], PAYLOAD, SIZE), 0);
|
|
|
|
|
|
|
|
|
|
|
|
// todo: proper uint32 comparison
|
|
|
|
ASSERT_EQ(st5TestBuffer[6], 252);
|
|
|
|
ASSERT_EQ(st5TestBuffer[7], 68);
|
|
|
|
ASSERT_EQ(st5TestBuffer[8], 173);
|
|
|
|
ASSERT_EQ(st5TestBuffer[9], 87);
|
2020-11-15 09:36:07 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST(binary, testWriteCrc) {
|
2020-11-15 09:44:53 -08:00
|
|
|
static ts_channel_s test;
|
2020-11-15 09:27:47 -08:00
|
|
|
|
2020-11-15 13:59:02 -08:00
|
|
|
// Let it pick which impl (small vs large) to use
|
2020-11-15 09:36:07 -08:00
|
|
|
sr5TestWriteDataIndex = 0;
|
2020-11-15 13:59:02 -08:00
|
|
|
sr5WriteCrcPacket(&test, CODE, (const uint8_t * )PAYLOAD, SIZE);
|
2020-11-15 09:36:07 -08:00
|
|
|
assertCrcPacket();
|
|
|
|
|
2020-11-15 13:59:02 -08:00
|
|
|
// Force the large impl
|
2020-11-15 09:36:07 -08:00
|
|
|
sr5TestWriteDataIndex = 0;
|
2020-11-15 13:59:02 -08:00
|
|
|
sr5WriteCrcPacketLarge(&test, CODE, (const uint8_t * )PAYLOAD, SIZE);
|
2020-11-15 09:36:07 -08:00
|
|
|
assertCrcPacket();
|
|
|
|
|
2020-11-15 13:59:02 -08:00
|
|
|
// Force the small impl
|
2020-11-15 09:36:07 -08:00
|
|
|
sr5TestWriteDataIndex = 0;
|
2020-11-15 09:44:53 -08:00
|
|
|
sr5WriteCrcPacketSmall(&test, CODE, (const uint8_t * )PAYLOAD, SIZE);
|
|
|
|
assertCrcPacket();
|
2020-11-15 09:27:47 -08:00
|
|
|
}
|