forked from arduino/ArduinoCore-API
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_CanMsg_CopyCtor.cpp
37 lines (27 loc) · 1.1 KB
/
test_CanMsg_CopyCtor.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
/*
* Copyright (c) 2020 Arduino. All rights reserved.
*/
/**************************************************************************************
* INCLUDE
**************************************************************************************/
#include <catch.hpp>
#include <api/CanMsg.h>
/**************************************************************************************
* NAMESPACE
**************************************************************************************/
using namespace arduino;
/**************************************************************************************
* TEST CODE
**************************************************************************************/
TEST_CASE ("Test copy constructor", "[CanMsg-CopyCtor-01]")
{
uint8_t const msg_data[4] = {0xDE, 0xAD, 0xC0, 0xDE};
CanMsg const msg_1(CanStandardId(0x20), sizeof(msg_data), msg_data);
CanMsg const msg_2(msg_1);
REQUIRE(msg_1.data_length == msg_2.data_length);
for (size_t i = 0; i < msg_1.data_length; i++)
{
REQUIRE(msg_1.data[i] == msg_data[i]);
REQUIRE(msg_2.data[i] == msg_data[i]);
}
}