-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathlib-tests.nix
More file actions
139 lines (138 loc) · 2.53 KB
/
Copy pathlib-tests.nix
File metadata and controls
139 lines (138 loc) · 2.53 KB
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
{ lib, emptyFile }:
let
inherit (import ./lib.nix { inherit lib; })
hostHexetsFromMacAddress
leftShift
mkIpv6Address
mkUlaNetwork
networkMaskHextets
parseIpv6Network
power
;
assertions = map ({ assertion, message }: lib.assertMsg assertion message) [
{
assertion = power 2 2 == 4;
message = "pow(2, 2) == 4";
}
{
assertion = leftShift 1 8 == 256;
message = "1<<8 == 256";
}
{
assertion =
networkMaskHextets 64 == [
65535
65535
65535
65535
0
0
0
0
];
message = "simple network mask";
}
{
assertion =
mkUlaNetwork [
0
0
0
0
0
0
0
0
] 64 == "fc00:0000:0000:0000:0000:0000:0000:0000/64";
message = "simple ULA network";
}
{
assertion =
mkUlaNetwork [
65535
0
0
0
0
0
0
0
] 64 == "fdff:0000:0000:0000:0000:0000:0000:0000/64";
message = "less simple ULA network";
}
{
assertion =
(parseIpv6Network "2001:db8::/48") == {
hextets = [
8193
3512
0
0
0
0
0
0
];
prefixLength = 48;
};
message = "parse simple IPv6 network";
}
{
assertion =
(parseIpv6Network "2001:db8:ffff::ffff/33") == {
hextets = [
8193
3512
32768
0
0
0
0
0
];
prefixLength = 33;
};
message = "parse IPv6 network with leftover bits in host portion";
}
{
assertion =
mkIpv6Address
[
8193
3512
0
0
0
0
0
0
]
[
0
0
0
0
0
0
0
1
] == "2001:0db8:0000:0000:0000:0000:0000:0001";
message = "make simple IPv6 address";
}
{
assertion =
hostHexetsFromMacAddress "b9:20:42:35:6b:5f" == [
0
0
0
0
47904
17151
65077
27487
];
message = "parse MAC address into host IPv6 hextets";
}
];
in
builtins.deepSeq assertions emptyFile