File tree Expand file tree Collapse file tree 1 file changed +43
-0
lines changed Expand file tree Collapse file tree 1 file changed +43
-0
lines changed Original file line number Diff line number Diff line change @@ -6,6 +6,49 @@ use "std/conv"
6
6
use "std/encoding"
7
7
use "std/strings"
8
8
use "std/testing"
9
+ use "std/unsafe"
10
+
11
+ #test
12
+ fn testDecodeNumber(t: &testing::T) {
13
+ numbers := [
14
+ "0",
15
+ "1",
16
+ "-1",
17
+ "100",
18
+ "-100",
19
+ "0.5",
20
+ "-0.5",
21
+ "123.456",
22
+ "-123.456",
23
+ "1e3",
24
+ "1E3",
25
+ "1e+3",
26
+ "1e-3",
27
+ "-1e3",
28
+ "-1E3",
29
+ "-1e+3",
30
+ "-1e-3",
31
+ "1.23e4",
32
+ "1.23E4",
33
+ "1.23e+4",
34
+ "1.23e-4",
35
+ "-1.23e4",
36
+ "-1.23E4",
37
+ "-1.23e+4",
38
+ "-1.23e-4",
39
+ "0.0",
40
+ "1.0",
41
+ "2.0e5",
42
+ "2.0E5",
43
+ ]
44
+ for i, n in numbers {
45
+ mut f := f64(0)
46
+ Decode(unsafe::StrBytes(n), f) else {
47
+ t.Errorf("#{} test failed", i)
48
+ continue
49
+ }
50
+ }
51
+ }
9
52
10
53
#test
11
54
fn testDecodeStr(t: &testing::T) {
You can’t perform that action at this time.
0 commit comments