summaryrefslogtreecommitdiffstats
path: root/tests/014/in6addr-str.tl
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2020-07-24 19:59:13 -0700
committerKaz Kylheku <kaz@kylheku.com>2020-07-24 19:59:13 -0700
commitccf6309c1716a221c881d610af8b3c11d363f5f3 (patch)
tree713f5a3e1ac5b59762970f5f052019f1e782f2eb /tests/014/in6addr-str.tl
parente0092558ad119f9a3c16b9f357e7ca0dcdf1044c (diff)
downloadtxr-ccf6309c1716a221c881d610af8b3c11d363f5f3.tar.gz
txr-ccf6309c1716a221c881d610af8b3c11d363f5f3.tar.bz2
txr-ccf6309c1716a221c881d610af8b3c11d363f5f3.zip
New inaddr-str and in6addr-str functions.
* lisplib.c (sock_set_entries): Register autoload entries for inaddr-str and in6addr-str. Register prefix symbol to be interned. * share/txr/stdlib/socket.tl (sockaddr-in, sockaddr-in6): Both structs get a new member, prefix, defaulting to the respective number of bits in the address. (inaddr-str, in6addr-str): New functions. * tests/014/iaddr-str, tests/014/inaddr-str.expected, tests/014/in6addr-str.tl, tests/014/in6addr-str.expected: New files * txr.1: Documented.
Diffstat (limited to 'tests/014/in6addr-str.tl')
-rw-r--r--tests/014/in6addr-str.tl120
1 files changed, 120 insertions, 0 deletions
diff --git a/tests/014/in6addr-str.tl b/tests/014/in6addr-str.tl
new file mode 100644
index 00000000..a85da416
--- /dev/null
+++ b/tests/014/in6addr-str.tl
@@ -0,0 +1,120 @@
+(load "../common.tl")
+
+(test (in6addr-str "junk") :error)
+
+(test (in6addr-str "0:0:0:0:0:0:0:0:0") :error)
+(test (in6addr-str "0:0:0:0:0:0") :error)
+(test (in6addr-str "0:0:0:0") :error)
+(test (in6addr-str "") :error)
+
+(test (in6addr-str "0:0:0:0:0:0:0:x:0") :error)
+
+(test (in6addr-str ":0:0:0:0:0:0:0:0:0") :error)
+(test (in6addr-str "0:0:0:0:0:0:0:0:0:") :error)
+
+(test (in6addr-str "0:0:0:0:0:0:0:0:FFFFF") :error)
+(test (in6addr-str "0:0:0:0:0:0:0:FFFFF:0") :error)
+(test (in6addr-str "0:0:0:0:0:0:FFFFF:0:0") :error)
+(test (in6addr-str "0:0:0:0:0:FFFFF:0:0:0") :error)
+(test (in6addr-str "0:0:0:0:FFFFF:0:0:0:0") :error)
+(test (in6addr-str "0:0:0:FFFFF:0:0:0:0:0") :error)
+(test (in6addr-str "0:0:FFFFF:0:0:0:0:0:0") :error)
+(test (in6addr-str "0:FFFFF:0:0:0:0:0:0:0") :error)
+(test (in6addr-str "FFFFF:0:0:0:0:0:0:0:0") :error)
+
+(test (in6addr-str "0:0:0:0:0:0:0:0/") :error)
+(test (in6addr-str "0:0:0:0:0:0:0:0/129") :error)
+(test (in6addr-str "[0:0:0:0:0:0:0:0]:") :error)
+(test (in6addr-str "[0:0:0:0:0:0:0:0]:65536") :error)
+
+(test (in6addr-str "0:0:0:0:0:0:0:0")
+ #S(sockaddr-in6 addr 0
+ port 0 flow-info 0 scope-id 0 prefix 128))
+(test (in6addr-str "1111:2222:3333:4444:5555:6666:7777:8888")
+ #S(sockaddr-in6 addr 22685837286468424649968941046919825544
+ port 0 flow-info 0 scope-id 0 prefix 128))
+(test (in6addr-str "FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF")
+ #S(sockaddr-in6 addr 340282366920938463463374607431768211455
+ port 0 flow-info 0 scope-id 0 prefix 128))
+
+(test (in6addr-str "[0:0:0:0:0:0:0:0]:42")
+ #S(sockaddr-in6 addr 0
+ port 42 flow-info 0 scope-id 0 prefix 128))
+(test (in6addr-str "[1111:2222:3333:4444:5555:6666:7777:8888]:42")
+ #S(sockaddr-in6 addr 22685837286468424649968941046919825544
+ port 42 flow-info 0 scope-id 0 prefix 128))
+(test (in6addr-str "[FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF]:42")
+ #S(sockaddr-in6 addr 340282366920938463463374607431768211455
+ port 42 flow-info 0 scope-id 0 prefix 128))
+
+(test (in6addr-str "0:0:0:0:0:0:0:0/16")
+ #S(sockaddr-in6 addr 0
+ port 0 flow-info 0 scope-id 0 prefix 16))
+(test (in6addr-str "1111:2222:3333:4444:5555:6666:7777:8888/16")
+ #S(sockaddr-in6 addr 22685144974938661909049738462362599424
+ port 0 flow-info 0 scope-id 0 prefix 16))
+(test (in6addr-str "FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF/16")
+ #S(sockaddr-in6 addr 340277174624079928635746076935438991360
+ port 0 flow-info 0 scope-id 0 prefix 16))
+(test (in6addr-str "ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff/16")
+ #S(sockaddr-in6 addr 340277174624079928635746076935438991360
+ port 0 flow-info 0 scope-id 0 prefix 16))
+
+(test (in6addr-str "[0:0:0:0:0:0:0:0/16]:42")
+ #S(sockaddr-in6 addr 0
+ port 42 flow-info 0 scope-id 0 prefix 16))
+(test (in6addr-str "[1111:2222:3333:4444:5555:6666:7777:8888/16]:42")
+ #S(sockaddr-in6 addr 22685144974938661909049738462362599424
+ port 42 flow-info 0 scope-id 0 prefix 16))
+(test (in6addr-str "[FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF/16]:42")
+ #S(sockaddr-in6 addr 340277174624079928635746076935438991360
+ port 42 flow-info 0 scope-id 0 prefix 16))
+
+(test (in6addr-str "1:2:3:4:5:6::7:8:9") :error)
+(test (in6addr-str "1:2:3:4:5:6::7:8:9") :error)
+(test (in6addr-str "1:2:3:4:5:6::7:8") :error)
+
+(test (in6addr-str "::1")
+ #S(sockaddr-in6 addr 1
+ port 0 flow-info 0 scope-id 0 prefix 128))
+
+(test (in6addr-str "1::")
+ #S(sockaddr-in6 addr 5192296858534827628530496329220096
+ port 0 flow-info 0 scope-id 0 prefix 128))
+
+(test (in6addr-str "1::1")
+ #S(sockaddr-in6 addr 5192296858534827628530496329220097
+ port 0 flow-info 0 scope-id 0 prefix 128))
+
+(test (in6addr-str "1:2::3:4")
+ #S(sockaddr-in6 addr 5192455314859856157205683417317380
+ port 0 flow-info 0 scope-id 0 prefix 128))
+
+(test (in6addr-str "::ffff:1.2.3.4.5") :error)
+(test (in6addr-str "::ffff:1.2.3.4:5") :error)
+(test (in6addr-str "::ffff:1.2.3") :error)
+(test (in6addr-str "::ffff:1.2.3:4") :error)
+
+(test (in6addr-str "::ffff:1.2.3.4")
+ #S(sockaddr-in6 addr 281470698652420
+ port 0 flow-info 0 scope-id 0 prefix 128))
+
+(test (in6addr-str "::FFFF:1.2.3.4")
+ #S(sockaddr-in6 addr 281470698652420
+ port 0 flow-info 0 scope-id 0 prefix 128))
+
+(test (in6addr-str "::FfFf:1.2.3.4")
+ #S(sockaddr-in6 addr 281470698652420
+ port 0 flow-info 0 scope-id 0 prefix 128))
+
+(test (in6addr-str "::FFFF:1.2.3.4/96")
+ #S(sockaddr-in6 addr 281470681743360
+ port 0 flow-info 0 scope-id 0 prefix 96))
+
+(test (in6addr-str "[::ffff:1.2.3.4]:42")
+ #S(sockaddr-in6 addr 281470698652420
+ port 42 flow-info 0 scope-id 0 prefix 128))
+
+(test (in6addr-str "[::FFFF:1.2.3.4/96]:42")
+ #S(sockaddr-in6 addr 281470681743360
+ port 42 flow-info 0 scope-id 0 prefix 96))