1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102
|
# generated from the original tests.
# Henceforth it may be nicer to group tests into separate files.
-- in.cue --
import "net"
t1: net.FQDN & "foo.bar."
t2: net.FQDN("foo.bararararararararararararararararararararararararararararararararara")
t3: net.SplitHostPort("[::%lo0]:80")
t4: net.JoinHostPort("mod.test", "80")
t5: net.JoinHostPort("2001:db8::1", 80)
t6: net.JoinHostPort([192, 30, 4, 2], 80)
t7: net.JoinHostPort([192, 30, 4], 80)
t8: net.IP("23.23.23.23")
t9: net.IPv4 & "23.23.23.2333"
t10: net.IP("23.23.23.23")
t11: net.IP("2001:db8::1")
t12: net.IPv4("2001:db8::1")
t13: net.IPv4() & "ff02::1:3"
t14: net.LoopbackIP([127, 0, 0, 1])
t15: net.LoopbackIP("127.0.0.1")
t16: net.ToIP4("127.0.0.1")
t17: net.ToIP16("127.0.0.1")
t18: net.IPCIDR("192.168.1.0/24")
t19: net.IPCIDR("2001:db8:a0b:12f0::1/32")
t20: net.IPCIDR("172.16.12.3")
t21: net.PathEscape("foo/bar")
t22: net.PathUnescape("foo%2Fbar")
t23: net.QueryEscape("f%o")
t24: net.QueryUnescape("f%25o")
t25: net.IPv6 & "2001:db8::1234567"
t26: net.IPv6("2001:db8::1")
t27: net.IPv6() & "23.23.23.23"
t28: net.IP("0:0:0:0:0:0:23.23.23.23")
t29: net.URL & "/foo/bar"
t30: net.URL & "%"
t31: net.URL & "https://foo.com/bar"
t32: net.AbsURL & "/foo/bar"
t33: net.AbsURL & "https://foo.com/bar"
t34: net.AbsURL & "%"
-- out/net --
Errors:
t25: invalid value "2001:db8::1234567" (does not satisfy net.IPv6):
./in.cue:27:6
./in.cue:27:17
t30: invalid value "%" (does not satisfy net.URL): error in call to net.URL: parse "%": invalid URL escape "%":
./in.cue:32:6
./in.cue:32:16
t32: invalid value "/foo/bar" (does not satisfy net.AbsURL): error in call to net.AbsURL: URL is not absolute:
./in.cue:34:6
./in.cue:34:19
t34: invalid value "%" (does not satisfy net.AbsURL): error in call to net.AbsURL: parse "%": invalid URL escape "%":
./in.cue:36:6
./in.cue:36:19
t9: invalid value "23.23.23.2333" (does not satisfy net.IPv4):
./in.cue:11:6
./in.cue:11:17
t7: error in call to net.JoinHostPort: invalid host [192, 30, 4]:
./in.cue:9:6
t13: invalid value "ff02::1:3" (does not satisfy net.IPv4):
./in.cue:15:6
./in.cue:15:19
t20: error in call to net.IPCIDR: netip.ParsePrefix("172.16.12.3"): no '/':
./in.cue:22:6
t27: invalid value "23.23.23.23" (does not satisfy net.IPv6):
./in.cue:29:6
./in.cue:29:19
Result:
t1: "foo.bar."
t2: false
t3: ["::%lo0", "80"]
t4: "mod.test:80"
t5: "[2001:db8::1]:80"
t6: "192.30.4.2:80"
t7: _|_ // t7: error in call to net.JoinHostPort: invalid host [192, 30, 4]
t8: true
t9: _|_ // t9: invalid value "23.23.23.2333" (does not satisfy net.IPv4)
t10: true
t11: true
t12: false
t13: _|_ // t13: invalid value "ff02::1:3" (does not satisfy net.IPv4)
t14: true
t15: true
t16: [127, 0, 0, 1]
t17: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 127, 0, 0, 1]
t18: true
t19: true
t20: _|_ // t20: error in call to net.IPCIDR: netip.ParsePrefix("172.16.12.3"): no '/'
t21: "foo%2Fbar"
t22: "foo/bar"
t23: "f%25o"
t24: "f%o"
t25: _|_ // t25: invalid value "2001:db8::1234567" (does not satisfy net.IPv6)
t26: true
t27: _|_ // t27: invalid value "23.23.23.23" (does not satisfy net.IPv6)
t28: true
t29: "/foo/bar"
t30: _|_ // t30: invalid value "%" (does not satisfy net.URL): t30: error in call to net.URL: parse "%": invalid URL escape "%"
t31: "https://foo.com/bar"
t32: _|_ // t32: invalid value "/foo/bar" (does not satisfy net.AbsURL): t32: error in call to net.AbsURL: URL is not absolute
t33: "https://foo.com/bar"
t34: _|_ // t34: invalid value "%" (does not satisfy net.AbsURL): t34: error in call to net.AbsURL: parse "%": invalid URL escape "%"
|