summaryrefslogtreecommitdiff
path: root/bin/tests/test_string.cpp
diff options
context:
space:
mode:
authorRémi Verschelde <remi@verschelde.fr>2016-10-26 14:32:51 +0200
committerGitHub <noreply@github.com>2016-10-26 14:32:51 +0200
commitc67e3a485dedae96b82c3356d5f45ab0509d7759 (patch)
tree748ab44c8ec645a8eee950991210bf6c620651d1 /bin/tests/test_string.cpp
parentc7f9d853e206c15981330af46cfd0a0fc43fc5ef (diff)
parent80e911647c5df21c5b6a06876f1d48e21cd1f5fc (diff)
Merge pull request #6925 from godotengine/ipv6
Adding IPv6 support
Diffstat (limited to 'bin/tests/test_string.cpp')
-rw-r--r--bin/tests/test_string.cpp58
1 files changed, 58 insertions, 0 deletions
diff --git a/bin/tests/test_string.cpp b/bin/tests/test_string.cpp
index be37ce118f..2e8f5c3494 100644
--- a/bin/tests/test_string.cpp
+++ b/bin/tests/test_string.cpp
@@ -32,6 +32,7 @@
#include <stdio.h>
#include "os/os.h"
#include "drivers/nrex/regex.h"
+#include "core/io/ip_address.h"
#include "test_string.h"
@@ -843,6 +844,62 @@ bool test_28() {
return state;
}
+bool test_29() {
+
+ bool error = false;
+ bool state = true;
+ bool success = false;
+
+ IP_Address ip0("2001:0db8:85a3:0000:0000:8a2e:0370:7334");
+ OS::get_singleton()->print("ip0 is %ls\n", String(ip0).c_str());
+
+ IP_Address ip(0x0123, 0x4567, 0x89ab, 0xcdef, IP_Address::TYPE_IPV6);
+ OS::get_singleton()->print("ip6 is %ls\n", String(ip).c_str());
+
+ IP_Address ip2("fe80::52e5:49ff:fe93:1baf");
+ OS::get_singleton()->print("ip6 is %ls\n", String(ip2).c_str());
+
+ IP_Address ip3("::ffff:192.168.0.1");
+ OS::get_singleton()->print("ip6 is %ls\n", String(ip3).c_str());
+
+ 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);
TestFunc test_funcs[] = {
@@ -875,6 +932,7 @@ TestFunc test_funcs[] = {
test_26,
test_27,
test_28,
+ test_29,
0
};