-
Notifications
You must be signed in to change notification settings - Fork 22
/
datarate_test.go
48 lines (42 loc) · 2.61 KB
/
datarate_test.go
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
package unit
import (
"testing"
)
func TestDatarate(t *testing.T) {
// base 10 (SI prefixes)
assertFloatEqual(t, 1e0, (1 * BitPerSecond).BitsPerSecond())
assertFloatEqual(t, 1e-3, (1 * BitPerSecond).KilobitsPerSecond())
assertFloatEqual(t, 1e-3, (1 * KilobitPerSecond).MegabitsPerSecond())
assertFloatEqual(t, 1e-3, (1 * MegabitPerSecond).GigabitsPerSecond())
assertFloatEqual(t, 1e-3, (1 * GigabitPerSecond).TerabitsPerSecond())
assertFloatEqual(t, 1e-3, (1 * TerabitPerSecond).PetabitsPerSecond())
assertFloatEqual(t, 1e-3, (1 * PetabitPerSecond).ExabitsPerSecond())
assertFloatEqual(t, 1e-3, (1 * ExabitPerSecond).ZettabitsPerSecond())
assertFloatEqual(t, 1e-3, (1 * ZettabitPerSecond).YottabitsPerSecond())
assertFloatEqual(t, 1e0, (1 * BytePerSecond).BytesPerSecond())
assertFloatEqual(t, 1e-3, (1 * BytePerSecond).KilobytesPerSecond())
assertFloatEqual(t, 1e-3, (1 * KilobytePerSecond).MegabytesPerSecond())
assertFloatEqual(t, 1e-3, (1 * MegabytePerSecond).GigabytesPerSecond())
assertFloatEqual(t, 1e-3, (1 * GigabytePerSecond).TerabytesPerSecond())
assertFloatEqual(t, 1e-3, (1 * TerabytePerSecond).PetabytesPerSecond())
assertFloatEqual(t, 1e-3, (1 * PetabytePerSecond).ExabytesPerSecond())
assertFloatEqual(t, 1e-3, (1 * ExabytePerSecond).ZettabytesPerSecond())
assertFloatEqual(t, 1e-3, (1 * ZettabytePerSecond).YottabytesPerSecond())
// base 2 (IEC prefixes)
assertFloatEqual(t, 0.0009765625, (1 * BitPerSecond).KibibitsPerSecond())
assertFloatEqual(t, 0.0009765625, (1 * KibibitPerSecond).MebibitsPerSecond())
assertFloatEqual(t, 0.0009765625, (1 * MebibitPerSecond).GibibitsPerSecond())
assertFloatEqual(t, 0.0009765625, (1 * GibibitPerSecond).TebibitsPerSecond())
assertFloatEqual(t, 0.0009765625, (1 * TebibitPerSecond).PebibitsPerSecond())
assertFloatEqual(t, 0.0009765625, (1 * PebibitPerSecond).ExbibitsPerSecond())
assertFloatEqual(t, 0.0009765625, (1 * ExbibitPerSecond).ZebibitsPerSecond())
assertFloatEqual(t, 0.0009765625, (1 * ZebibitPerSecond).YobibitsPerSecond())
assertFloatEqual(t, 0.0009765625, (1 * BytePerSecond).KibibytesPerSecond())
assertFloatEqual(t, 0.0009765625, (1 * KibibytePerSecond).MebibytesPerSecond())
assertFloatEqual(t, 0.0009765625, (1 * MebibytePerSecond).GibibytesPerSecond())
assertFloatEqual(t, 0.0009765625, (1 * GibibytePerSecond).TebibytesPerSecond())
assertFloatEqual(t, 0.0009765625, (1 * TebibytePerSecond).PebibytesPerSecond())
assertFloatEqual(t, 0.0009765625, (1 * PebibytePerSecond).ExbibytesPerSecond())
assertFloatEqual(t, 0.0009765625, (1 * ExbibytePerSecond).ZebibytesPerSecond())
assertFloatEqual(t, 0.0009765625, (1 * ZebibytePerSecond).YobibytesPerSecond())
}