|
| 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 two basic constructs the same","[IPAddress6-Operator-==-01]") |
| 18 | +{ |
| 19 | + arduino::IPAddressip1(0x20,0x01,0xd,0xb8,1,2,3,4,5,6,7,8,9,0xa,0xb,0xc),ip2(0x20,0x01,0xd,0xb8,1,2,3,4,5,6,7,8,9,0xa,0xb,0xc); |
| 20 | +REQUIRE((ip1 == ip2) ==true); |
| 21 | +} |
| 22 | + |
| 23 | +TEST_CASE ("Testing two addresses different","[IPAddress-Operator-==-02]") |
| 24 | +{ |
| 25 | + arduino::IPAddressip1(0x20,0x01,0xd,0xb8,1,2,3,4,5,6,7,8,9,0xa,0xb,0xc),ip2(0xfd,0x12,0x34,0x56,0x78,0x9a,0,1,0,0,0,0,0,0,0,1); |
| 26 | +REQUIRE((ip1 == ip2) ==false); |
| 27 | +} |
| 28 | + |
| 29 | +TEST_CASE ("Testing not equals different address is true","[IPAddress-Operator-==-03]") |
| 30 | +{ |
| 31 | + arduino::IPAddressip1(0x20,0x01,0xd,0xb8,1,2,3,4,5,6,7,8,9,0xa,0xb,0xc),ip2(0xfd,0x12,0x34,0x56,0x78,0x9a,0,1,0,0,0,0,0,0,0,1); |
| 32 | +REQUIRE((ip1 != ip2) ==true); |
| 33 | +} |
| 34 | + |
| 35 | +TEST_CASE ("Testing not equals same address is false","[IPAddress-Operator-==-04]") |
| 36 | +{ |
| 37 | + arduino::IPAddressip1(0x20,0x01,0xd,0xb8,1,2,3,4,5,6,7,8,9,0xa,0xb,0xc),ip2(0x20,0x01,0xd,0xb8,1,2,3,4,5,6,7,8,9,0xa,0xb,0xc); |
| 38 | +REQUIRE((ip1 != ip2) ==false); |
| 39 | +} |
| 40 | + |
| 41 | +// IPv4 and IPv6 differ based on type (irrespective of bytes) |
| 42 | + |
| 43 | +TEST_CASE ("Testing IPv4 vs IPv6","[IPAddress6-Operator-==-05]") |
| 44 | +{ |
| 45 | + arduino::IPAddressip1(10,0,0,1),ip2(0x20,0x01,0xd,0xb8,1,2,3,4,5,6,7,8,9,0xa,0xb,0xc); |
| 46 | +REQUIRE((ip1 == ip2) ==false); |
| 47 | +} |
| 48 | + |
| 49 | +TEST_CASE ("Testing IPv4 vs IPv6 equivalent IPv4-compatible address (deprecated)","[IPAddress6-Operator-==-05]") |
| 50 | +{ |
| 51 | + arduino::IPAddressip1(10,0,0,1),ip2(0,0,0,0,0,0,0,0,0,0,0,0,10,0,0,1); |
| 52 | +REQUIRE((ip1 == ip2) ==false); |
| 53 | +} |
| 54 | + |
| 55 | +TEST_CASE ("Testing IPv4 vs IPv6 localhost","[IPAddress6-Operator-==-05]") |
| 56 | +{ |
| 57 | + arduino::IPAddressip1(127,0,0,1),ip2(0,0,0,0,0,0,0,0,0,0,0,0,10,0,0,1); |
| 58 | +REQUIRE((ip1 == ip2) ==false); |
| 59 | +} |
| 60 | + |
| 61 | +TEST_CASE ("Testing IPv4 equivalent compatible address vs IPv6 localhost","[IPAddress6-Operator-==-05]") |
| 62 | +{ |
| 63 | + arduino::IPAddressip1(0,0,0,1),ip2(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1); |
| 64 | +REQUIRE((ip1 == ip2) ==false); |
| 65 | +} |