mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
ipv4/ipv6 parsing and back to string.
This commit is contained in:
@@ -9,6 +9,25 @@ fn void test_ipv4() @test
|
||||
|
||||
}
|
||||
|
||||
fn void! test_ipv4_to_string() @test
|
||||
{
|
||||
InetAddress a = net::ipv4_from_str("127.0.0.1")?;
|
||||
assert(a.to_string()? == "127.0.0.1");
|
||||
}
|
||||
|
||||
fn void! test_ipv6_to_string() @test
|
||||
{
|
||||
InetAddress a = net::ipv6_from_str("2001:db8::2:1")?;
|
||||
a.to_string()?;
|
||||
assert(a.to_string()? == "2001:0db8:0000:0000:0000:0000:0002:0001");
|
||||
assert(net::ipv6_from_str("2001:db8::1").to_string()? == "2001:0db8:0000:0000:0000:0000:0000:0001");
|
||||
assert(net::ipv6_from_str("::1").to_string()? == "0000:0000:0000:0000:0000:0000:0000:0001");
|
||||
assert(net::ipv6_from_str("2001::1").to_string()? == "2001:0000:0000:0000:0000:0000:0000:0001");
|
||||
assert(net::ipv6_from_str("2001:db8:1234::").to_string()? == "2001:0db8:1234:0000:0000:0000:0000:0000");
|
||||
assert(net::ipv6_from_str("2001::").to_string()? == "2001:0000:0000:0000:0000:0000:0000:0000");
|
||||
assert(net::ipv6_from_str("::").to_string()? == "0000:0000:0000:0000:0000:0000:0000:0000");
|
||||
}
|
||||
|
||||
fn void! test_ipv4_parse() @test
|
||||
{
|
||||
InetAddress a = net::ipv4_from_str("127.0.0.1")?;
|
||||
|
||||
Reference in New Issue
Block a user