diff options
Diffstat (limited to 'ip/ip_test.pl')
-rw-r--r-- | ip/ip_test.pl | 33 |
1 files changed, 20 insertions, 13 deletions
diff --git a/ip/ip_test.pl b/ip/ip_test.pl index 39a0abb..b2812f6 100644 --- a/ip/ip_test.pl +++ b/ip/ip_test.pl @@ -4,56 +4,63 @@ :- use_module(library(format)). test("ip4", ( - ip4(127, 0, 0, 1, A), - A =:= (127 * 2**24 + 1) + make_ip4(127, 0, 0, 1, Addr), + Addr =:= 127*2^24 + 1 )). test("ip_format", ( - ip_format(ip4(127, 0, 0, 1, _), Str), + make_ip4(127, 0, 0, 1, Addr), + ip_format(ip4(Addr), Str), Str == "127.0.0.1" )). test("ip_format #2", ( - Ip = ip4_range(ip4(192, 168, 0, 0, _), 24), + make_ip4(192, 168, 0, 0, Addr), + Ip = ip4_range(Addr, 24), ip_format(Ip, Str), Str == "192.168.0.0/24" )). test("ip4_parse #1", ( + make_ip4(1, 2, 3, 4, Addr), ip4_parse("1.2.3.4", Ip), - Ip == ip4(1, 2, 3, 4) + Ip == ip4(Addr) )). test("ip4_range_parse", ( + make_ip4(1, 2, 3, 4, Addr), ip4_range_parse("1.2.3.4/24", Ip), - A #= 2^24 + 2 * 2^16 + 3 * 2^8 + 4, - Ip == ip4_range(ip4(1, 2, 3, 4, A), 24) + Ip == ip4_range(Addr, 24) )). test("ip6_parse", ( + make_ip6(1, 2, 3, 4, 5, 6, 10, 11, Addr), ip6_parse("1:2:3:4:5:6:a:b", Ip), - Ip == ip6(1, 2, 3, 4, 5, 6, 10, 11) + Ip == ip6(Addr) )). test("ip6_parse #2", ( + make_ip6(0, 2, 3, 4, 5, 6, 10, 11, Addr), ip6_parse("0:2:3:4:5:6:a:b", Ip), - Ip == ip6(0, 2, 3, 4, 5, 6, 10, 11) + Ip == ip6(Addr) )). test("ip_parse #1", ( + make_ip4(127, 0, 0, 1, Addr), ip_parse("127.0.0.1", Ip), - Ip == ip4(127, 0, 0, 1) + Ip == ip4(Addr) )). test("ip_parse #2", ( ip_parse("192.168.10.4/24", R), - make_ip4(192, 168, 10, 4, Ip), - R == ip4_range(Ip, 24) + make_ip4(192, 168, 10, 4, Addr), + R == ip4_range(Addr, 24) )). test("ip_parse #3", ( + make_ip6(0, 2, 3, 4, 5, 6, 10, 11, Addr), ip_parse("0:2:3:4:5:6:a:b", Ip), - Ip == ip6(0, 2, 3, 4, 5, 6, 10, 11) + Ip == ip6(Addr) )). main :- |