forked from arduino/ArduinoCore-API
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_IPAddress.cpp
53 lines (44 loc) · 1.37 KB
/
test_IPAddress.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
45
46
47
48
49
50
51
52
53
/*
* Copyright (c) 2020 Arduino. All rights reserved.
*/
/**************************************************************************************
* INCLUDE
**************************************************************************************/
#include <catch.hpp>
#include <api/IPAddress.h>
/**************************************************************************************
* TEST CODE
**************************************************************************************/
TEST_CASE ("Testing IPAddress() default constructor()", "[IPAddress-Ctor-01]")
{
arduino::IPAddress ip;
REQUIRE(ip[0] == 0);
REQUIRE(ip[1] == 0);
REQUIRE(ip[2] == 0);
REQUIRE(ip[3] == 0);
}
TEST_CASE ("Testing IPAddress(o,o,o,o) constructor", "[IPAddress-Ctor-02]")
{
arduino::IPAddress ip(129,168,1,2);
REQUIRE(ip[0] == 129);
REQUIRE(ip[1] == 168);
REQUIRE(ip[2] == 1);
REQUIRE(ip[3] == 2);
}
TEST_CASE ("Testing IPAddress(a) constructor", "[IPAddress-Ctor-03]")
{
arduino::IPAddress ip(129 | (168 << 8) | (1 << 16) | (2 << 24));
REQUIRE(ip[0] == 129);
REQUIRE(ip[1] == 168);
REQUIRE(ip[2] == 1);
REQUIRE(ip[3] == 2);
}
TEST_CASE ("Testing IPAddress(a *) constructor", "[IPAddress-Ctor-04]")
{
uint8_t const ip_addr_array[] = {129,168,1,2};
arduino::IPAddress ip(ip_addr_array);
REQUIRE(ip[0] == 129);
REQUIRE(ip[1] == 168);
REQUIRE(ip[2] == 1);
REQUIRE(ip[3] == 2);
}