|
| 1 | +/* |
| 2 | + * Copyright (c) 2020 Arduino. All rights reserved. |
| 3 | + */ |
| 4 | + |
| 5 | +/************************************************************************************** |
| 6 | + * INCLUDE |
| 7 | + **************************************************************************************/ |
| 8 | + |
| 9 | +#include <catch.hpp> |
| 10 | + |
| 11 | +#include <CanMsg.h> |
| 12 | + |
| 13 | +/************************************************************************************** |
| 14 | + * NAMESPACE |
| 15 | + **************************************************************************************/ |
| 16 | + |
| 17 | +using namespace arduino; |
| 18 | + |
| 19 | +/************************************************************************************** |
| 20 | + * TEST CODE |
| 21 | + **************************************************************************************/ |
| 22 | + |
| 23 | +TEST_CASE ("Test copy constructor", "[CanMsg-CopyCtor-01]") |
| 24 | +{ |
| 25 | + uint8_t const msg_data[4] = {0xDE, 0xAD, 0xC0, 0xDE}; |
| 26 | + |
| 27 | + CanMsg const msg_1(CanStandardId(0x20), sizeof(msg_data), msg_data); |
| 28 | + CanMsg const msg_2(msg_1); |
| 29 | + |
| 30 | + REQUIRE(msg_1.data_length == msg_2.data_length); |
| 31 | + |
| 32 | + for (size_t i = 0; i < msg_1.data_length; i++) |
| 33 | + { |
| 34 | + REQUIRE(msg_1.data[i] == msg_data[i]); |
| 35 | + REQUIRE(msg_2.data[i] == msg_data[i]); |
| 36 | + } |
| 37 | + |
| 38 | +} |
0 commit comments