Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit1a4a7f8

Browse files
committed
Add testcases for IPAddress::toString()
1 parent1b7ef0d commit1a4a7f8

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

‎test/CMakeLists.txt‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ set(TEST_SRCS
2929
src/Common/test_map.cpp
3030
src/Common/test_max.cpp
3131
src/Common/test_min.cpp
32+
src/IPAddress/test_toString.cpp
3233
src/IPAddress/test_fromString.cpp
3334
src/IPAddress/test_fromString6.cpp
3435
src/IPAddress/test_IPAddress.cpp
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
* Copyright (c) 2020 Arduino. All rights reserved.
3+
*/
4+
5+
/**************************************************************************************
6+
* INCLUDE
7+
**************************************************************************************/
8+
9+
#include<catch.hpp>
10+
11+
#include<String.h>
12+
#include<IPAddress.h>
13+
14+
/**************************************************************************************
15+
* TEST CODE
16+
**************************************************************************************/
17+
18+
TEST_CASE ("Extract valid string from IPv4address","[IPAddress-toString-01]")
19+
{
20+
arduino::IPAddressip(129,168,1,2);
21+
22+
REQUIRE(ip.toString().equals("129.168.1.2") ==true);
23+
}
24+
25+
TEST_CASE ("Extract valid ipv6 string from IPv6address","[IPAddress-toString-02]")
26+
{
27+
arduino::IPAddressip(0x20,0x01,0xd,0xb8,1,2,3,4,5,6,7,8,9,0xa,0xb,0xc);
28+
29+
REQUIRE(ip.toString().equals("2001:0db8:0102:0304:0506:0708:090a:0b0c") ==true);
30+
}
31+
32+
TEST_CASE ("Extract 0.0.0.0 string from uninitialized IP address","[IPAddress-toString-03]")
33+
{
34+
arduino::IPAddress ip;
35+
36+
REQUIRE(ip.toString().equals("0.0.0.0") ==true);
37+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp