[openrtm-commit:02350] r2901 - branches/FSM4RTC/OpenRTM-aist/src/lib/coil/tests/stringutil
openrtm @ openrtm.org
openrtm @ openrtm.org
2017年 1月 28日 (土) 23:42:19 JST
Author: n-ando
Date: 2017-01-28 23:42:19 +0900 (Sat, 28 Jan 2017)
New Revision: 2901
Modified:
branches/FSM4RTC/OpenRTM-aist/src/lib/coil/tests/stringutil/stringutilTests.cpp
Log:
[coil,test] coil::stringutils tests added.
Modified: branches/FSM4RTC/OpenRTM-aist/src/lib/coil/tests/stringutil/stringutilTests.cpp
===================================================================
--- branches/FSM4RTC/OpenRTM-aist/src/lib/coil/tests/stringutil/stringutilTests.cpp 2017-01-28 14:41:29 UTC (rev 2900)
+++ branches/FSM4RTC/OpenRTM-aist/src/lib/coil/tests/stringutil/stringutilTests.cpp 2017-01-28 14:42:19 UTC (rev 2901)
@@ -53,6 +53,8 @@
CPPUNIT_TEST(test_toBool);
CPPUNIT_TEST(test_isAbsolutePath);
CPPUNIT_TEST(test_isURL);
+ CPPUNIT_TEST(test_isIPv4);
+ CPPUNIT_TEST(test_isIPv6);
CPPUNIT_TEST(test_otos);
CPPUNIT_TEST(test_stringTo);
CPPUNIT_TEST(test_stringToBool);
@@ -136,6 +138,76 @@
void test_isURL()
{
}
+ void test_isIPv4()
+ {
+ std::string addr;
+ addr = "255.250.255.255"; // OK
+ CPPUNIT_ASSERT_EQUAL(coil::isIPv4(addr), true);
+ addr = "0.0.0.0"; // OK
+ CPPUNIT_ASSERT_EQUAL(coil::isIPv4(addr), true);
+ addr = "192.168.0.1"; // OK
+ CPPUNIT_ASSERT_EQUAL(coil::isIPv4(addr), true);
+ addr = "192.168.100.0"; // OK
+ CPPUNIT_ASSERT_EQUAL(coil::isIPv4(addr), true);
+
+ addr = "255.250.255"; // NG
+ CPPUNIT_ASSERT_EQUAL(coil::isIPv4(addr), false);
+ addr = "255,250.255.0"; // NG
+ CPPUNIT_ASSERT_EQUAL(coil::isIPv4(addr), false);
+ addr = "192.168.0.256"; // NG
+ CPPUNIT_ASSERT_EQUAL(coil::isIPv4(addr), false);
+ addr = "ff.ff.ff.ff"; // NG
+ CPPUNIT_ASSERT_EQUAL(coil::isIPv4(addr), false);
+ addr = "xx.yy.zz.00"; // NG
+ CPPUNIT_ASSERT_EQUAL(coil::isIPv4(addr), false);
+
+ addr = "255.250.255.255:92183"; // OK
+ CPPUNIT_ASSERT_EQUAL(coil::isIPv4(addr), true);
+ addr = "0.0.0.0:97763"; // OK
+ CPPUNIT_ASSERT_EQUAL(coil::isIPv4(addr), true);
+ addr = "192.168.0.1:98657"; // OK
+ CPPUNIT_ASSERT_EQUAL(coil::isIPv4(addr), true);
+ addr = "192.168.100.0:4689"; // OK
+ CPPUNIT_ASSERT_EQUAL(coil::isIPv4(addr), true);
+
+ addr = "255.250.255:8686"; // NG
+ CPPUNIT_ASSERT_EQUAL(coil::isIPv4(addr), false);
+ addr = "255,250.255.0:86545"; // NG
+ CPPUNIT_ASSERT_EQUAL(coil::isIPv4(addr), false);
+ addr = "1293:192.168.0.1"; // NG
+ CPPUNIT_ASSERT_EQUAL(coil::isIPv4(addr), false);
+ addr = "ff.ff.ff.ff.ff:9763"; // NG
+ CPPUNIT_ASSERT_EQUAL(coil::isIPv4(addr), false);
+ addr = "xx.yy.zz.00:98767"; // NG
+ CPPUNIT_ASSERT_EQUAL(coil::isIPv4(addr), false);
+ }
+ void test_isIPv6()
+ {
+ std::string addr;
+ addr = "fe80:0:0:0:21c:42ff:fe87:d3d4"; // OK
+ CPPUNIT_ASSERT_EQUAL(coil::isIPv6(addr), true);
+ addr = "::1"; // OK
+ CPPUNIT_ASSERT_EQUAL(coil::isIPv6(addr), true);
+ addr = "fe80::21c:42ff:fe87:d3d4"; // OK
+ CPPUNIT_ASSERT_EQUAL(coil::isIPv6(addr), true);
+
+ addr = "fe80::21c:42ff:fe87:1ffff"; // NG
+ CPPUNIT_ASSERT_EQUAL(coil::isIPv6(addr), false);
+ addr = "ffe80::21c:42ff:fe87:d3d4"; // NG
+ CPPUNIT_ASSERT_EQUAL(coil::isIPv6(addr), false);
+
+ addr = "[fe80:0:0:0:21c:42ff:fe87:d3d4]"; // OK
+ CPPUNIT_ASSERT_EQUAL(coil::isIPv6(addr), true);
+ addr = "[::1]:9679"; // OK
+ CPPUNIT_ASSERT_EQUAL(coil::isIPv6(addr), true);
+ addr = "[fe80::21c:42ff:fe87:d3d4]:7657"; // OK
+ CPPUNIT_ASSERT_EQUAL(coil::isIPv6(addr), true);
+
+ addr = "[ffe80::21c:42ff:fe87:d3d4]:5678"; // NG
+ CPPUNIT_ASSERT_EQUAL(coil::isIPv6(addr), false);
+ addr = "fe80::21c:42ff:fe87:d3d4]:87654"; // NG
+ CPPUNIT_ASSERT_EQUAL(coil::isIPv6(addr), false);
+ }
void test_otos()
{
}
More information about the openrtm-commit
mailing list