mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
fmt: remove space in front of ? and ! (#14366)
This commit is contained in:
@@ -144,7 +144,7 @@ pub fn common_parse_int(_s string, base int, _bit_size int, error_on_non_digit b
|
||||
// un := parse_uint(s, base, bit_size) or {
|
||||
// return i64(0)
|
||||
// }
|
||||
un := common_parse_uint(s, base, bit_size, error_on_non_digit, error_on_high_digit) ?
|
||||
un := common_parse_uint(s, base, bit_size, error_on_non_digit, error_on_high_digit)?
|
||||
if un == 0 {
|
||||
return i64(0)
|
||||
}
|
||||
@@ -208,7 +208,7 @@ pub fn atoi(s string) ?int {
|
||||
return if s[0] == `-` { -n } else { n }
|
||||
}
|
||||
// Slow path for invalid, big, or underscored integers.
|
||||
int64 := parse_int(s, 10, 0) ?
|
||||
int64 := parse_int(s, 10, 0)?
|
||||
return int(int64)
|
||||
}
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import strconv
|
||||
|
||||
fn test_atoi() ? {
|
||||
assert strconv.atoi('16') ? == 16
|
||||
assert strconv.atoi('+16') ? == 16
|
||||
assert strconv.atoi('-16') ? == -16
|
||||
assert strconv.atoi('16')? == 16
|
||||
assert strconv.atoi('+16')? == 16
|
||||
assert strconv.atoi('-16')? == -16
|
||||
|
||||
// invalid strings
|
||||
if x := strconv.atoi('str') {
|
||||
@@ -28,19 +28,19 @@ fn test_atoi() ? {
|
||||
|
||||
fn test_parse_int() ? {
|
||||
// Different bases
|
||||
assert strconv.parse_int('16', 16, 0) ? == 0x16
|
||||
assert strconv.parse_int('16', 8, 0) ? == 0o16
|
||||
assert strconv.parse_int('11', 2, 0) ? == 3
|
||||
assert strconv.parse_int('16', 16, 0)? == 0x16
|
||||
assert strconv.parse_int('16', 8, 0)? == 0o16
|
||||
assert strconv.parse_int('11', 2, 0)? == 3
|
||||
// Different bit sizes
|
||||
assert strconv.parse_int('127', 10, 8) ? == 127
|
||||
assert strconv.parse_int('128', 10, 8) ? == 127
|
||||
assert strconv.parse_int('32767', 10, 16) ? == 32767
|
||||
assert strconv.parse_int('32768', 10, 16) ? == 32767
|
||||
assert strconv.parse_int('2147483647', 10, 32) ? == 2147483647
|
||||
assert strconv.parse_int('2147483648', 10, 32) ? == 2147483647
|
||||
assert strconv.parse_int('9223372036854775807', 10, 64) ? == 9223372036854775807
|
||||
assert strconv.parse_int('9223372036854775808', 10, 64) ? == 9223372036854775807
|
||||
assert strconv.parse_int('baobab', 36, 64) ? == 683058467
|
||||
assert strconv.parse_int('127', 10, 8)? == 127
|
||||
assert strconv.parse_int('128', 10, 8)? == 127
|
||||
assert strconv.parse_int('32767', 10, 16)? == 32767
|
||||
assert strconv.parse_int('32768', 10, 16)? == 32767
|
||||
assert strconv.parse_int('2147483647', 10, 32)? == 2147483647
|
||||
assert strconv.parse_int('2147483648', 10, 32)? == 2147483647
|
||||
assert strconv.parse_int('9223372036854775807', 10, 64)? == 9223372036854775807
|
||||
assert strconv.parse_int('9223372036854775808', 10, 64)? == 9223372036854775807
|
||||
assert strconv.parse_int('baobab', 36, 64)? == 683058467
|
||||
// Invalid bit sizes
|
||||
if x := strconv.parse_int('123', 10, -1) {
|
||||
println(x)
|
||||
|
||||
Reference in New Issue
Block a user