-
-
Notifications
You must be signed in to change notification settings - Fork 130
/
Copy pathtest_operator_assignment.cpp
41 lines (30 loc) · 1.2 KB
/
test_operator_assignment.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
/*
* Copyright (c) 2020 Arduino. All rights reserved.
*
* SPDX-License-Identifier: LGPL-2.1-or-later
*/
/**************************************************************************************
* INCLUDE
**************************************************************************************/
#include <catch.hpp>
#include <api/CanMsg.h>
/**************************************************************************************
* NAMESPACE
**************************************************************************************/
using namespace arduino;
/**************************************************************************************
* TEST CODE
**************************************************************************************/
TEST_CASE ("Testing CanMsg::operator = (CanMsg const &)", "[CanMsg-Operator-=-1]")
{
uint8_t const msg_data[4] = {0xDE, 0xAD, 0xC0, 0xDE};
CanMsg const msg_1(CanStandardId(0x20), sizeof(msg_data), msg_data);
CanMsg msg_2(CanStandardId(0x21), 0, nullptr);
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]);
}
}