@@ -30,44 +30,44 @@ test "IpV6Address.from_slice()" {
30
30
}
31
31
32
32
test "IpV6Address.is_unspecified()" {
33
- testing .expect (IpV6Address .init (0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ).is_unspecified () == true );
33
+ testing .expect (IpV6Address .init (0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ).is_unspecified ());
34
34
testing .expect (IpV6Address .init (0 , 0 , 0 , 0 , 0 , 0xffff , 0xc00a , 0x2ff ).is_unspecified () == false );
35
35
}
36
36
37
37
test "IpV6Address.is_loopback()" {
38
- testing .expect (IpV6Address .init (0 , 0 , 0 , 0 , 0 , 0 , 0 , 0x1 ).is_loopback () == true );
38
+ testing .expect (IpV6Address .init (0 , 0 , 0 , 0 , 0 , 0 , 0 , 0x1 ).is_loopback ());
39
39
testing .expect (IpV6Address .init (0 , 0 , 0 , 0 , 0 , 0xffff , 0xc00a , 0x2ff ).is_loopback () == false );
40
40
}
41
41
42
42
test "IpV6Address.is_multicast()" {
43
- testing .expect (IpV6Address .init (0xff00 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ).is_multicast () == true );
43
+ testing .expect (IpV6Address .init (0xff00 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ).is_multicast ());
44
44
testing .expect (IpV6Address .init (0 , 0 , 0 , 0 , 0 , 0xffff , 0xc00a , 0x2ff ).is_multicast () == false );
45
45
}
46
46
47
47
test "IpV6Address.is_documentation()" {
48
- testing .expect (IpV6Address .init (0x2001 , 0xdb8 , 0 , 0 , 0 , 0 , 0 , 0 ).is_documentation () == true );
48
+ testing .expect (IpV6Address .init (0x2001 , 0xdb8 , 0 , 0 , 0 , 0 , 0 , 0 ).is_documentation ());
49
49
testing .expect (IpV6Address .init (0 , 0 , 0 , 0 , 0 , 0xffff , 0xc00a , 0x2ff ).is_documentation () == false );
50
50
}
51
51
52
52
test "IpV6Address.is_multicast_link_local()" {
53
53
var arr = []u8 { 0xff , 0x02 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0x02 };
54
54
55
- testing .expect (IpV6Address .from_slice (& arr ).is_multicast_link_local () == true );
55
+ testing .expect (IpV6Address .from_slice (& arr ).is_multicast_link_local ());
56
56
testing .expect (IpV6Address .init (0 , 0 , 0 , 0 , 0 , 0xffff , 0xc00a , 0x2ff ).is_multicast_link_local () == false );
57
57
}
58
58
59
59
test "IpV6Address.is_unicast_site_local()" {
60
- testing .expect (IpV6Address .init (0xfec2 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ).is_unicast_site_local () == true );
60
+ testing .expect (IpV6Address .init (0xfec2 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ).is_unicast_site_local ());
61
61
testing .expect (IpV6Address .init (0 , 0 , 0 , 0 , 0 , 0xffff , 0xc00a , 0x2ff ).is_unicast_site_local () == false );
62
62
}
63
63
64
64
test "IpV6Address.is_unicast_link_local()" {
65
- testing .expect (IpV6Address .init (0xfe8a , 0 , 0 , 0 , 0 , 0 , 0 , 0 ).is_unicast_link_local () == true );
65
+ testing .expect (IpV6Address .init (0xfe8a , 0 , 0 , 0 , 0 , 0 , 0 , 0 ).is_unicast_link_local ());
66
66
testing .expect (IpV6Address .init (0 , 0 , 0 , 0 , 0 , 0xffff , 0xc00a , 0x2ff ).is_unicast_link_local () == false );
67
67
}
68
68
69
69
test "IpV6Address.is_unique_local()" {
70
- testing .expect (IpV6Address .init (0xfc02 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ).is_unique_local () == true );
70
+ testing .expect (IpV6Address .init (0xfc02 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ).is_unique_local ());
71
71
testing .expect (IpV6Address .init (0 , 0 , 0 , 0 , 0 , 0xffff , 0xc00a , 0x2ff ).is_unique_local () == false );
72
72
}
73
73
@@ -79,13 +79,13 @@ test "IpV6Address.multicast_scope()" {
79
79
}
80
80
81
81
test "IpV6Address.is_globally_routable()" {
82
- testing .expect (IpV6Address .init (0 , 0 , 0 , 0 , 0 , 0xffff , 0xc00a , 0x2ff ).is_globally_routable () == true );
83
- testing .expect (IpV6Address .init (0 , 0 , 0x1c9 , 0 , 0 , 0xafc8 , 0 , 0x1 ).is_globally_routable () == true );
82
+ testing .expect (IpV6Address .init (0 , 0 , 0 , 0 , 0 , 0xffff , 0xc00a , 0x2ff ).is_globally_routable ());
83
+ testing .expect (IpV6Address .init (0 , 0 , 0x1c9 , 0 , 0 , 0xafc8 , 0 , 0x1 ).is_globally_routable ());
84
84
testing .expect (IpV6Address .init (0 , 0 , 0 , 0 , 0 , 0 , 0 , 0x1 ).is_globally_routable () == false );
85
85
}
86
86
87
87
test "IpV6Address.is_unicast_global()" {
88
- testing .expect (IpV6Address .init (0 , 0 , 0 , 0 , 0 , 0xffff , 0xc00a , 0x2ff ).is_unicast_global () == true );
88
+ testing .expect (IpV6Address .init (0 , 0 , 0 , 0 , 0 , 0xffff , 0xc00a , 0x2ff ).is_unicast_global ());
89
89
testing .expect (IpV6Address .init (0x2001 , 0xdb8 , 0 , 0 , 0 , 0 , 0 , 0 ).is_unicast_global () == false );
90
90
}
91
91
@@ -99,14 +99,14 @@ test "IpV6Address.to_ipv4()" {
99
99
}
100
100
101
101
test "IpV6Address.equals()" {
102
- testing .expect (IpV6Address .init (0 , 0 , 0 , 0 , 0 , 0 , 0 , 1 ).equals (IpV6Address .Localhost ) == true );
102
+ testing .expect (IpV6Address .init (0 , 0 , 0 , 0 , 0 , 0 , 0 , 1 ).equals (IpV6Address .Localhost ));
103
103
}
104
104
105
105
test "IpV6Address.to_host_byte_order()" {
106
106
const addr = IpV6Address .init (0x1020 , 0x3040 , 0x5060 , 0x7080 , 0x90A0 , 0xB0C0 , 0xD0E0 , 0xF00D );
107
107
const expected : u128 = 0x102030405060708090A0B0C0D0E0F00D ;
108
108
109
- testing .expect ( addr .to_host_byte_order () == expected );
109
+ testing .expectEqual ( expected , addr .to_host_byte_order ());
110
110
}
111
111
112
112
test "IpV6Address.from_host_byte_order()" {
@@ -122,7 +122,7 @@ fn test_format_ipv6_address(address: IpV6Address, expected: []const u8) !void {
122
122
123
123
const result = try fmt .bufPrint (buf , "{}" , address );
124
124
125
- testing .expect ( mem . eql ( u8 , result , expected ) );
125
+ testing .expectEqualSlices ( u8 , expected , result );
126
126
}
127
127
128
128
test "IpV6Address.format()" {
@@ -143,11 +143,7 @@ test "IpV6Address.format()" {
143
143
}
144
144
145
145
fn testIpV6ParseError (addr : []const u8 , expected_error : ParseError ) void {
146
- if (IpV6Address .parse (addr )) | _ | {
147
- @panic ("parse success, expected failure" );
148
- } else | e | {
149
- testing .expect (e == expected_error );
150
- }
146
+ testing .expectError (expected_error , IpV6Address .parse (addr ));
151
147
}
152
148
153
149
fn testIpV6Format (addr : IpV6Address , expected : []const u8 ) ! void {
@@ -156,7 +152,7 @@ fn testIpV6Format(addr: IpV6Address, expected: []const u8) !void {
156
152
157
153
const result = try fmt .bufPrint (buf , "{}" , addr );
158
154
159
- testing .expect ( mem . eql ( u8 , result , expected ) );
155
+ testing .expectEqualSlices ( u8 , expected , result );
160
156
}
161
157
162
158
fn testIpV6ParseAndBack (addr : []const u8 , expectedIp : IpV6Address ) ! void {
0 commit comments