v / vlib / encoding / cbor / tests / cbor_wg / appA_mt7-float.edn
131 lines · 131 sloc · 3.1 KB · 468855eef1db0ff73c62be2d1bf176ffa0e1478e
Raw
1{
2 "title": "mt7-float",
3 "description": "Major type 7 (mt7) floats, from RFC 8949 appendix A",
4 "encodeOptions": {
5 "avoidInts": true,
6 },
7 "tests": [
8 {
9 "description": "Zero",
10 "encoded": h'f90000',
11 "decoded": 0.0,
12 },
13 {
14 "description": "Negative zero",
15 "encoded": h'f98000',
16 "decoded": -0.0,
17 },
18 {
19 "description": "One",
20 "encoded": h'f93c00',
21 "decoded": 1.0,
22 },
23 {
24 "description": "1.1 does not fit into a smaller float",
25 "encoded": h'fb3ff199999999999a',
26 "decoded": 1.1,
27 },
28 {
29 "description": "1.5 collapses to an f16"
30 "encoded": h'f93e00',
31 "decoded": 1.5,
32 },
33 {
34 "description": "Largest f16"
35 "encoded": h'f97bff',
36 "decoded": 65504.0,
37 },
38 {
39 "description": "100000"
40 "encoded": h'fa47c35000',
41 "decoded": 100000.0,
42 },
43 {
44 "description": "Largest f32"
45 "encoded": h'fa7f7fffff',
46 "decoded": 3.4028234663852886e+38,
47 },
48 {
49 "description": "Large round f64"
50 "encoded": h'fb7e37e43c8800759c',
51 "decoded": 1.0e+300,
52 },
53 {
54 "description": "Smallest subnormal f16"
55 "encoded": h'f90001',
56 "decoded": 5.960464477539063e-8,
57 },
58 {
59 "description": "Smallest normal f16"
60 "encoded": h'f90400',
61 "decoded": 0.00006103515625,
62 },
63 {
64 "description": "Negative f16"
65 "encoded": h'f9c400',
66 "decoded": -4.0,
67 },
68 {
69 "description": "-4.1 does not reduce"
70 "encoded": h'fbc010666666666666',
71 "decoded": -4.1,
72 },
73 {
74 "description": "Positive infinity"
75 "encoded": h'f97c00',
76 "decoded": Infinity,
77 },
78 {
79 "description": "Trivial NaN"
80 "encoded": h'f97e00',
81 "decoded": NaN,
82 },
83 {
84 "description": "Negative infinity"
85 "encoded": h'f9fc00',
86 "decoded": -Infinity,
87 },
88 {
89 "description": "Infinity coded as f32 instead of f16",
90 # Can't round-trip to non-preferred
91 "roundtrip": false,
92 "encoded": h'fa7f800000',
93 "decoded": Infinity,
94 },
95 {
96 "description": "Trivial NaN coded as f32 instead of f16",
97 # Can't round-trip to non-preferred
98 "roundtrip": false,
99 "encoded": h'fa7fc00000',
100 "decoded": NaN,
101 },
102 {
103 "description": "Negative Infinity coded as f32 instead of f16",
104 # Can't round-trip to non-preferred
105 "roundtrip": false,
106 "encoded": h'faff800000',
107 "decoded": -Infinity,
108 },
109 {
110 "description": "Infinity coded as f64 instead of f16",
111 # Can't round-trip to non-preferred
112 "roundtrip": false,
113 "encoded": h'fb7ff0000000000000',
114 "decoded": Infinity,
115 },
116 {
117 "description": "Trivial NaN coded as f64 instead of f16",
118 # Can't round-trip to non-preferred
119 "roundtrip": false,
120 "encoded": h'fb7ff8000000000000',
121 "decoded": NaN,
122 },
123 {
124 "description": "Negative Infinity coded as f64 instead of f16",
125 # Can't round-trip to non-preferred
126 "roundtrip": false,
127 "encoded": h'fbfff0000000000000',
128 "decoded": -Infinity,
129 },
130 ],
131}
132