[openrtm-commit:02381] r930 - trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/tests/src/jp/go/aist/rtm/RTC/util
openrtm @ openrtm.org
openrtm @ openrtm.org
2017年 2月 6日 (月) 11:51:56 JST
Author: win-ei
Date: 2017-02-06 11:51:56 +0900 (Mon, 06 Feb 2017)
New Revision: 930
Modified:
trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/tests/src/jp/go/aist/rtm/RTC/util/StringUtilTests.java
Log:
[test] StringUtil tests added.
Modified: trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/tests/src/jp/go/aist/rtm/RTC/util/StringUtilTests.java
===================================================================
--- trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/tests/src/jp/go/aist/rtm/RTC/util/StringUtilTests.java 2017-02-05 10:19:11 UTC (rev 929)
+++ trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/tests/src/jp/go/aist/rtm/RTC/util/StringUtilTests.java 2017-02-06 02:51:56 UTC (rev 930)
@@ -1,9 +1,10 @@
package jp.go.aist.rtm.RTC.util;
+import junit.framework.TestCase;
+
import java.util.Vector;
import jp.go.aist.rtm.RTC.util.StringUtil;
-import junit.framework.TestCase;
/**
* 文字列操作クラス テスト
@@ -88,7 +89,6 @@
* </ul>
*/
public void test_unescape() {
-
final String[][] pairs = {
{"\\t", "\t"},
{"\\n", "\n"},
@@ -299,5 +299,81 @@
String expected = "normalizeteststring.";
assertEquals(expected, normalized);
}
+ /**
+ *
+ */
+ public void test_isIPv4() {
+ String addr = new String();
+ addr = "255.250.255.255"; // OK
+ assertEquals(StringUtil.isIPv4(addr), true);
+ addr = "0.0.0.0"; // OK
+ assertEquals(StringUtil.isIPv4(addr), true);
+ addr = "192.168.0.1"; // OK
+ assertEquals(StringUtil.isIPv4(addr), true);
+ addr = "192.168.100.0"; // OK
+ assertEquals(StringUtil.isIPv4(addr), true);
+ addr = "255.250.255"; // NG
+ assertEquals(StringUtil.isIPv4(addr), false);
+ addr = "255,250.255.0"; // NG
+ assertEquals(StringUtil.isIPv4(addr), false);
+ addr = "192.168.0.256"; // NG
+ assertEquals(StringUtil.isIPv4(addr), false);
+ addr = "ff.ff.ff.ff"; // NG
+ assertEquals(StringUtil.isIPv4(addr), false);
+ addr = "xx.yy.zz.00"; // NG
+ assertEquals(StringUtil.isIPv4(addr), false);
+
+ addr = "255.250.255.255:92183"; // OK
+ assertEquals(StringUtil.isIPv4(addr), true);
+ addr = "0.0.0.0:97763"; // OK
+ assertEquals(StringUtil.isIPv4(addr), true);
+ addr = "192.168.0.1:98657"; // OK
+ assertEquals(StringUtil.isIPv4(addr), true);
+ addr = "192.168.100.0:4689"; // OK
+ assertEquals(StringUtil.isIPv4(addr), true);
+
+ addr = "255.250.255:8686"; // NG
+ assertEquals(StringUtil.isIPv4(addr), false);
+ addr = "255,250.255.0:86545"; // NG
+ assertEquals(StringUtil.isIPv4(addr), false);
+ addr = "1293:192.168.0.1"; // NG
+ assertEquals(StringUtil.isIPv4(addr), false);
+ addr = "ff.ff.ff.ff.ff:9763"; // NG
+ assertEquals(StringUtil.isIPv4(addr), false);
+ addr = "xx.yy.zz.00:98767"; // NG
+ assertEquals(StringUtil.isIPv4(addr), false);
+ }
+
+ /**
+ *
+ */
+ public void test_isIPv6() {
+ String addr = new String();
+ addr = "fe80:0:0:0:21c:42ff:fe87:d3d4"; // OK
+ assertEquals(StringUtil.isIPv6(addr), true);
+ addr = "::1"; // OK
+ assertEquals(StringUtil.isIPv6(addr), true);
+ addr = "fe80::21c:42ff:fe87:d3d4"; // OK
+ assertEquals(StringUtil.isIPv6(addr), true);
+
+ addr = "fe80::21c:42ff:fe87:1ffff"; // NG
+ assertEquals(StringUtil.isIPv6(addr), false);
+ addr = "ffe80::21c:42ff:fe87:d3d4"; // NG
+ assertEquals(StringUtil.isIPv6(addr), false);
+
+ addr = "[fe80:0:0:0:21c:42ff:fe87:d3d4]"; // OK
+ assertEquals(StringUtil.isIPv6(addr), true);
+ addr = "[::1]:9679"; // OK
+ assertEquals(StringUtil.isIPv6(addr), true);
+ addr = "[fe80::21c:42ff:fe87:d3d4]:7657"; // OK
+ assertEquals(StringUtil.isIPv6(addr), true);
+
+ addr = "[ffe80::21c:42ff:fe87:d3d4]:5678"; // NG
+ assertEquals(StringUtil.isIPv6(addr), false);
+ addr = "fe80::21c:42ff:fe87:d3d4]:87654"; // NG
+ assertEquals(StringUtil.isIPv6(addr), false);
+
+ }
+
}
More information about the openrtm-commit
mailing list