From 1d45f35a4a190360fea74e51b66457efe44d3177 Mon Sep 17 00:00:00 2001 From: Ariel Manzur Date: Wed, 19 Oct 2016 18:32:36 -0300 Subject: fixed some byte order and parsing problems --- bin/tests/test_string.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'bin/tests/test_string.cpp') diff --git a/bin/tests/test_string.cpp b/bin/tests/test_string.cpp index be37ce118f..b11bc9c333 100644 --- a/bin/tests/test_string.cpp +++ b/bin/tests/test_string.cpp @@ -32,6 +32,7 @@ #include #include "os/os.h" #include "drivers/nrex/regex.h" +#include "core/io/ip_address.h" #include "test_string.h" @@ -843,6 +844,23 @@ bool test_28() { return state; } +bool test_29() { + + IP_Address ip0("2001:0db8:85a3:0000:0000:8a2e:0370:7334"); + printf("ip0 is %ls\n", String(ip0).c_str()); + + IP_Address ip(0x0123, 0x4567, 0x89ab, 0xcdef, IP_Address::TYPE_IPV6); + printf("ip6 is %ls\n", String(ip).c_str()); + + IP_Address ip2("fe80::52e5:49ff:fe93:1baf"); + printf("ip6 is %ls\n", String(ip2).c_str()); + + IP_Address ip3("::ffff:192.168.0.1"); + printf("ip6 is %ls\n", String(ip3).c_str()); + + return true; +}; + typedef bool (*TestFunc)(void); TestFunc test_funcs[] = { @@ -875,6 +893,7 @@ TestFunc test_funcs[] = { test_26, test_27, test_28, + test_29, 0 }; -- cgit v1.2.3 From a3131a6b5bf5357e5c70ba6fea4a0963f4b341b4 Mon Sep 17 00:00:00 2001 From: Ariel Manzur Date: Thu, 20 Oct 2016 09:58:00 -0300 Subject: added implementation of is_valid_ip_address() --- bin/tests/test_string.cpp | 49 ++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 44 insertions(+), 5 deletions(-) (limited to 'bin/tests/test_string.cpp') diff --git a/bin/tests/test_string.cpp b/bin/tests/test_string.cpp index b11bc9c333..2e8f5c3494 100644 --- a/bin/tests/test_string.cpp +++ b/bin/tests/test_string.cpp @@ -846,19 +846,58 @@ bool test_28() { bool test_29() { + bool error = false; + bool state = true; + bool success = false; + IP_Address ip0("2001:0db8:85a3:0000:0000:8a2e:0370:7334"); - printf("ip0 is %ls\n", String(ip0).c_str()); + OS::get_singleton()->print("ip0 is %ls\n", String(ip0).c_str()); IP_Address ip(0x0123, 0x4567, 0x89ab, 0xcdef, IP_Address::TYPE_IPV6); - printf("ip6 is %ls\n", String(ip).c_str()); + OS::get_singleton()->print("ip6 is %ls\n", String(ip).c_str()); IP_Address ip2("fe80::52e5:49ff:fe93:1baf"); - printf("ip6 is %ls\n", String(ip2).c_str()); + OS::get_singleton()->print("ip6 is %ls\n", String(ip2).c_str()); IP_Address ip3("::ffff:192.168.0.1"); - printf("ip6 is %ls\n", String(ip3).c_str()); + OS::get_singleton()->print("ip6 is %ls\n", String(ip3).c_str()); - return true; + String ip4 = "192.168.0.1"; + success = ip4.is_valid_ip_address(); + OS::get_singleton()->print("Is valid ipv4: %ls, %s\n", ip4.c_str(), success ? "OK" : "FAIL"); + if (!success) state = false; + + ip4 = "192.368.0.1"; + success = (!ip4.is_valid_ip_address()); + OS::get_singleton()->print("Is invalid ipv4: %ls, %s\n", ip4.c_str(), success ? "OK" : "FAIL"); + if (!success) state = false; + + String ip6 = "2001:0db8:85a3:0000:0000:8a2e:0370:7334"; + success = ip6.is_valid_ip_address(); + OS::get_singleton()->print("Is valid ipv6: %ls, %s\n", ip6.c_str(), success ? "OK" : "FAIL"); + if (!success) state = false; + + ip6 = "2001:0db8:85j3:0000:0000:8a2e:0370:7334"; + success = (!ip6.is_valid_ip_address()); + OS::get_singleton()->print("Is invalid ipv6: %ls, %s\n", ip6.c_str(), success ? "OK" : "FAIL"); + if (!success) state = false; + + ip6 = "2001:0db8:85f345:0000:0000:8a2e:0370:7334"; + success = (!ip6.is_valid_ip_address()); + OS::get_singleton()->print("Is invalid ipv6: %ls, %s\n", ip6.c_str(), success ? "OK" : "FAIL"); + if (!success) state = false; + + ip6 = "2001:0db8::0:8a2e:370:7334"; + success = (ip6.is_valid_ip_address()); + OS::get_singleton()->print("Is valid ipv6: %ls, %s\n", ip6.c_str(), success ? "OK" : "FAIL"); + if (!success) state = false; + + ip6 = "::ffff:192.168.0.1"; + success = (ip6.is_valid_ip_address()); + OS::get_singleton()->print("Is valid ipv6: %ls, %s\n", ip6.c_str(), success ? "OK" : "FAIL"); + if (!success) state = false; + + return state; }; typedef bool (*TestFunc)(void); -- cgit v1.2.3 From 439d43932133d32dcabd482f11842072d52b41e1 Mon Sep 17 00:00:00 2001 From: Zher Huei Lee Date: Sun, 23 Oct 2016 01:22:48 +0100 Subject: RegEx re-implemented as a module Re-wrote nrex as a module using godot-specific parts and new features: * Added string substitutions. * Named groups are now supported. * Removed use of mutable variables in RegEx. RegExMatch is returned instead. --- bin/tests/test_string.cpp | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) (limited to 'bin/tests/test_string.cpp') diff --git a/bin/tests/test_string.cpp b/bin/tests/test_string.cpp index 2e8f5c3494..4990c58896 100644 --- a/bin/tests/test_string.cpp +++ b/bin/tests/test_string.cpp @@ -31,7 +31,6 @@ //#include "math_funcs.h" #include #include "os/os.h" -#include "drivers/nrex/regex.h" #include "core/io/ip_address.h" #include "test_string.h" @@ -462,18 +461,8 @@ bool test_25() { bool test_26() { - OS::get_singleton()->print("\n\nTest 26: RegEx\n"); - RegEx regexp("(.*):(.*)"); - - int res = regexp.find("name:password"); - printf("\tmatch: %s\n", (res>=0)?"true":"false"); - - printf("\t%i captures:\n", regexp.get_capture_count()); - for (int i = 0; i=0); + //TODO: Do replacement RegEx test + return true; }; struct test_27_data { -- cgit v1.2.3