-
-
Notifications
You must be signed in to change notification settings - Fork 130
/
Copy pathtest_printTo.cpp
44 lines (32 loc) · 1.29 KB
/
test_printTo.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/*
* Copyright (c) 2020 Arduino. All rights reserved.
*/
/**************************************************************************************
* INCLUDE
**************************************************************************************/
#include <catch.hpp>
#include <CanMsg.h>
#include <PrintMock.h>
/**************************************************************************************
* NAMESPACE
**************************************************************************************/
using namespace arduino;
/**************************************************************************************
* TEST CODE
**************************************************************************************/
TEST_CASE ("Print CAN frame with standard ID", "[CanMsg-printTo-1]")
{
uint8_t const std_msg_data[] = {0xBE, 0xEF};
CanMsg const std_msg(CanStandardId(0x20), sizeof(std_msg_data), std_msg_data);
PrintMock mock;
mock.print(std_msg);
REQUIRE(mock._str == "[020] (2) : BEEF");
}
TEST_CASE ("Print CAN frame with extended ID", "[CanMsg-printTo-1]")
{
uint8_t const ext_msg_data[] = {0xDE, 0xAD, 0xC0, 0xDE};
CanMsg const ext_msg(CanExtendedId(0x20), sizeof(ext_msg_data), ext_msg_data);
PrintMock mock;
mock.print(ext_msg);
REQUIRE(mock._str == "[00000020] (4) : DEADC0DE");
}