@@ -53,3 +53,64 @@ test "parse_int64_uncovered_lines" {
53
53
assert_eq! (parse_as_result (t .0 , base = t .1 ), t .2 )
54
54
}
55
55
}
56
+ test "@strconv.parse_int64/base_parsing" {
57
+ // Test different bases
58
+ inspect! (@strconv .parse_int64! ("1010" , base = 2 ), content = "10" )
59
+ inspect! (@strconv .parse_int64! ("777" , base = 8 ), content = "511" )
60
+ inspect! (@strconv .parse_int64! ("ff" , base = 16 ), content = "255" )
61
+ // Test auto-detection of base
62
+ inspect! (@strconv .parse_int64! ("0xFF" ), content = "255" )
63
+ inspect! (@strconv .parse_int64! ("0b1010" ), content = "10" )
64
+ inspect! (@strconv .parse_int64! ("0o777" ), content = "511" )
65
+ }
66
+
67
+ test "panic @strconv.parse_int64/invalid_input" {
68
+ // Empty string
69
+ ignore (@strconv .parse_int64! ("" ))
70
+ // Invalid characters for given base
71
+ ignore (@strconv .parse_int64! ("2" , base = 2 ))
72
+ // Invalid base
73
+ ignore (@strconv .parse_int64! ("123" , base = 37 ))
74
+ }
75
+
76
+ test "@strconv.parse_int64/boundary_values" {
77
+ // Test minimum and maximum values
78
+ inspect! (
79
+ @strconv .parse_int64! ("-9223372036854775808" ),
80
+ content = "-9223372036854775808" ,
81
+ )
82
+ inspect! (
83
+ @strconv .parse_int64! ("9223372036854775807" ),
84
+ content = "9223372036854775807" ,
85
+ )
86
+ // Test with underscores
87
+ inspect! (
88
+ @strconv .parse_int64! ("922_3372_0368_5477_5807" ),
89
+ content = "9223372036854775807" ,
90
+ )
91
+ // Test with different sign prefixes
92
+ inspect! (@strconv .parse_int64! ("+42" ), content = "42" )
93
+ inspect! (@strconv .parse_int64! ("-42" ), content = "-42" )
94
+ }
95
+
96
+ test "@moonbitlang/core/strconv.parse_int64/base10" {
97
+ inspect! (@moonbitlang/core/strconv .parse_int64! ("12345" ), content = "12345" )
98
+ inspect! (@moonbitlang/core/strconv .parse_int64! ("-12345" ), content = "-12345" )
99
+ inspect! (@moonbitlang/core/strconv .parse_int64! ("0" ), content = "0" )
100
+ inspect! (@moonbitlang/core/strconv .parse_int64! ("-0" ), content = "0" )
101
+ }
102
+
103
+ test "@moonbitlang/core/strconv.parse_int64/boundary_cases" {
104
+ inspect! (
105
+ @moonbitlang/core/strconv .parse_int64! ("9223372036854775807" ),
106
+ content = "9223372036854775807" ,
107
+ )
108
+ inspect! (
109
+ @moonbitlang/core/strconv .parse_int64! ("-9223372036854775808" ),
110
+ content = "-9223372036854775808" ,
111
+ )
112
+ }
113
+
114
+ test "panic @moonbitlang/core/strconv.parse_int64/invalid_base" {
115
+ ignore (@moonbitlang/core/strconv .parse_int64! ("12345x" ))
116
+ }
0 commit comments