Skip to content

Commit e514ac5

Browse files
committed
Adding test code for 'IPAddress::operator =(...)'
1 parent 9951941 commit e514ac5

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

test/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ set(TEST_SRCS
3030
src/Common/test_min.cpp
3131
src/IPAddress/test_fromString.cpp
3232
src/IPAddress/test_IPAddress.cpp
33+
src/IPAddress/test_operator_assignment.cpp
3334
src/IPAddress/test_operator_comparison.cpp
3435
src/Print/test_clearWriteError.cpp
3536
src/Print/test_getWriteError.cpp
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*
2+
* Copyright (c) 2020 Arduino. All rights reserved.
3+
*/
4+
5+
/**************************************************************************************
6+
* INCLUDE
7+
**************************************************************************************/
8+
9+
#include <catch.hpp>
10+
11+
#include <IPAddress.h>
12+
13+
/**************************************************************************************
14+
* TEST CODE
15+
**************************************************************************************/
16+
17+
TEST_CASE ("Testing IPAddress::operator = (const uint8_t * a)", "[IPAddress-Operator-=-01]")
18+
{
19+
arduino::IPAddress ip1;
20+
uint8_t const ip2[] = {192,168,1,2};
21+
22+
ip1 = ip2;
23+
REQUIRE(ip1 == arduino::IPAddress(192,168,1,2));
24+
}
25+
26+
TEST_CASE ("Testing IPAddress::operator = (uint32_t a)", "[IPAddress-Operator-=-02]")
27+
{
28+
arduino::IPAddress ip1;
29+
uint32_t const ip2 = 192 | (168 << 8) | (1 << 16) | (2 << 24);
30+
31+
ip1 = ip2;
32+
REQUIRE(ip1 == arduino::IPAddress(192,168,1,2));
33+
}

0 commit comments

Comments
 (0)