# 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")

// Regression test for https://cuelang.org/issue/2431.
// StrictDomainName was not being applied due to an upstream bug.
t48: net.FQDN("hello world")
t49: net.FQDN("foo bar.")
t50: net.FQDN("valid.example.com.")
t51: net.FQDN("under_score.example.com.")
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")
t20b: 123 & net.IPCIDR
t20c: 123 & net.IP
t20d: 123 & net.IPv4
t20e: 123 & net.IPv6
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 & "%"
t35: net.AddIP("127.0.0.1", 1)
t36: net.AddIP("127.0.0.1/8", 2)
t37: net.AddIP("2001:db8::", 1)
t38: net.AddIP("2001:db8::/64", 2)
t39: net.AddIP("invalid ip", 1)
t40: net.AddIP("0.0.0.0", -1)
t41: net.AddIP("255.255.255.255", 1)
t42: net.AddIP("::ffff:127.0.0.1", 1)
t43: net.AddIPCIDR("192.168.0.0/23", 1)
t44: net.AddIPCIDR("2001:db8:1111:2222::/64", 1)
t45: net.AddIPCIDR("192.168.0.0", 1)
t46: net.AddIPCIDR("10.0.0.0/8", -11)
t47: net.AddIPCIDR("255.0.0.0/8", 1)
-- out/net-v3 --
Errors:
t20b: invalid value 123 (does not satisfy net.IPCIDR): invalid type int for IP CIDR:
    ./in.cue:30:7
t20c: invalid value 123 (does not satisfy net.IP): invalid type int for IP address:
    ./in.cue:31:7
t20d: invalid value 123 (does not satisfy net.IPv4): invalid type int for IP address:
    ./in.cue:32:7
t20e: invalid value 123 (does not satisfy net.IPv6): invalid type int for IP address:
    ./in.cue:33:7
t25: invalid value "2001:db8::1234567" (does not satisfy net.IPv6): ParseAddr("2001:db8::1234567"): each group must have 4 or less digits (at "1234567"):
    ./in.cue:38:6
    ./in.cue:38:17
t30: invalid value "%" (does not satisfy net.URL): parse "%": invalid URL escape "%":
    ./in.cue:43:6
    ./in.cue:43:16
t32: invalid value "/foo/bar" (does not satisfy net.AbsURL): URL is not absolute:
    ./in.cue:45:6
    ./in.cue:45:19
t34: invalid value "%" (does not satisfy net.AbsURL): parse "%": invalid URL escape "%":
    ./in.cue:47:6
    ./in.cue:47:19
t9: invalid value "23.23.23.2333" (does not satisfy net.IPv4): ParseAddr("23.23.23.2333"): IPv4 field has value >255:
    ./in.cue:18:6
    ./in.cue:18:17
t7: error in call to net.JoinHostPort: invalid host [192, 30, 4]:
    ./in.cue:16:6
t13: invalid value "ff02::1:3" (does not satisfy net.IPv4):
    ./in.cue:22:6
    ./in.cue:22:19
t20: error in call to net.IPCIDR: netip.ParsePrefix("172.16.12.3"): no '/':
    ./in.cue:29:6
t27: invalid value "23.23.23.23" (does not satisfy net.IPv6):
    ./in.cue:40:6
    ./in.cue:40:19
t39: error in call to net.AddIP: ParseAddr("invalid ip"): unable to parse IP:
    ./in.cue:52:6
t40: error in call to net.AddIP: IP address arithmetic resulted in out-of-range address (underflow):
    ./in.cue:53:6
t41: error in call to net.AddIP: IP address arithmetic resulted in out-of-range address (overflow):
    ./in.cue:54:6
t45: error in call to net.AddIPCIDR: netip.ParsePrefix("192.168.0.0"): no '/':
    ./in.cue:58:6
t46: error in call to net.AddIPCIDR: IP address arithmetic resulted in out-of-range address (underflow):
    ./in.cue:59:6
t47: error in call to net.AddIPCIDR: IP address arithmetic resulted in out-of-range address (overflow):
    ./in.cue:60:6

Result:
t1: "foo.bar."
t2: false

// Regression test for https://cuelang.org/issue/2431.
// StrictDomainName was not being applied due to an upstream bug.
t48: false
t49: false
t50: true
t51: 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): ParseAddr("23.23.23.2333"): IPv4 field has value >255
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 '/'
t20b: _|_ // t20b: invalid value 123 (does not satisfy net.IPCIDR): invalid type int for IP CIDR
t20c: _|_ // t20c: invalid value 123 (does not satisfy net.IP): invalid type int for IP address
t20d: _|_ // t20d: invalid value 123 (does not satisfy net.IPv4): invalid type int for IP address
t20e: _|_ // t20e: invalid value 123 (does not satisfy net.IPv6): invalid type int for IP address
t21:  "foo%2Fbar"
t22:  "foo/bar"
t23:  "f%25o"
t24:  "f%o"
t25:  _|_ // t25: invalid value "2001:db8::1234567" (does not satisfy net.IPv6): ParseAddr("2001:db8::1234567"): each group must have 4 or less digits (at "1234567")
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): parse "%": invalid URL escape "%"
t31:  "https://foo.com/bar"
t32:  _|_ // t32: invalid value "/foo/bar" (does not satisfy net.AbsURL): URL is not absolute
t33:  "https://foo.com/bar"
t34:  _|_ // t34: invalid value "%" (does not satisfy net.AbsURL): parse "%": invalid URL escape "%"
t35:  "127.0.0.2"
t36:  "127.0.0.3/8"
t37:  "2001:db8::1"
t38:  "2001:db8::2/64"
t39:  _|_ // t39: error in call to net.AddIP: ParseAddr("invalid ip"): unable to parse IP
t40:  _|_ // t40: error in call to net.AddIP: IP address arithmetic resulted in out-of-range address (underflow)
t41:  _|_ // t41: error in call to net.AddIP: IP address arithmetic resulted in out-of-range address (overflow)
t42:  "::ffff:127.0.0.2"
t43:  "192.168.2.0/23"
t44:  "2001:db8:1111:2223::/64"
t45:  _|_ // t45: error in call to net.AddIPCIDR: netip.ParsePrefix("192.168.0.0"): no '/'
t46:  _|_ // t46: error in call to net.AddIPCIDR: IP address arithmetic resulted in out-of-range address (underflow)
t47:  _|_ // t47: error in call to net.AddIPCIDR: IP address arithmetic resulted in out-of-range address (overflow)
