diff options
author | Ondřej Surý <ondrej@sury.org> | 2011-01-17 12:40:45 +0100 |
---|---|---|
committer | Ondřej Surý <ondrej@sury.org> | 2011-01-17 12:40:45 +0100 |
commit | 3e45412327a2654a77944249962b3652e6142299 (patch) | |
tree | bc3bf69452afa055423cbe0c5cfa8ca357df6ccf /src/pkg/strconv/atoi_test.go | |
parent | c533680039762cacbc37db8dc7eed074c3e497be (diff) | |
download | golang-upstream/2011.01.12.tar.gz |
Imported Upstream version 2011.01.12upstream/2011.01.12
Diffstat (limited to 'src/pkg/strconv/atoi_test.go')
-rw-r--r-- | src/pkg/strconv/atoi_test.go | 204 |
1 files changed, 102 insertions, 102 deletions
diff --git a/src/pkg/strconv/atoi_test.go b/src/pkg/strconv/atoi_test.go index 7df930342..0b9f29553 100644 --- a/src/pkg/strconv/atoi_test.go +++ b/src/pkg/strconv/atoi_test.go @@ -18,37 +18,37 @@ type atoui64Test struct { } var atoui64tests = []atoui64Test{ - atoui64Test{"", 0, os.EINVAL}, - atoui64Test{"0", 0, nil}, - atoui64Test{"1", 1, nil}, - atoui64Test{"12345", 12345, nil}, - atoui64Test{"012345", 12345, nil}, - atoui64Test{"12345x", 0, os.EINVAL}, - atoui64Test{"98765432100", 98765432100, nil}, - atoui64Test{"18446744073709551615", 1<<64 - 1, nil}, - atoui64Test{"18446744073709551616", 1<<64 - 1, os.ERANGE}, - atoui64Test{"18446744073709551620", 1<<64 - 1, os.ERANGE}, + {"", 0, os.EINVAL}, + {"0", 0, nil}, + {"1", 1, nil}, + {"12345", 12345, nil}, + {"012345", 12345, nil}, + {"12345x", 0, os.EINVAL}, + {"98765432100", 98765432100, nil}, + {"18446744073709551615", 1<<64 - 1, nil}, + {"18446744073709551616", 1<<64 - 1, os.ERANGE}, + {"18446744073709551620", 1<<64 - 1, os.ERANGE}, } var btoui64tests = []atoui64Test{ - atoui64Test{"", 0, os.EINVAL}, - atoui64Test{"0", 0, nil}, - atoui64Test{"1", 1, nil}, - atoui64Test{"12345", 12345, nil}, - atoui64Test{"012345", 012345, nil}, - atoui64Test{"0x12345", 0x12345, nil}, - atoui64Test{"0X12345", 0x12345, nil}, - atoui64Test{"12345x", 0, os.EINVAL}, - atoui64Test{"98765432100", 98765432100, nil}, - atoui64Test{"18446744073709551615", 1<<64 - 1, nil}, - atoui64Test{"18446744073709551616", 1<<64 - 1, os.ERANGE}, - atoui64Test{"18446744073709551620", 1<<64 - 1, os.ERANGE}, - atoui64Test{"0xFFFFFFFFFFFFFFFF", 1<<64 - 1, nil}, - atoui64Test{"0x10000000000000000", 1<<64 - 1, os.ERANGE}, - atoui64Test{"01777777777777777777777", 1<<64 - 1, nil}, - atoui64Test{"01777777777777777777778", 0, os.EINVAL}, - atoui64Test{"02000000000000000000000", 1<<64 - 1, os.ERANGE}, - atoui64Test{"0200000000000000000000", 1 << 61, nil}, + {"", 0, os.EINVAL}, + {"0", 0, nil}, + {"1", 1, nil}, + {"12345", 12345, nil}, + {"012345", 012345, nil}, + {"0x12345", 0x12345, nil}, + {"0X12345", 0x12345, nil}, + {"12345x", 0, os.EINVAL}, + {"98765432100", 98765432100, nil}, + {"18446744073709551615", 1<<64 - 1, nil}, + {"18446744073709551616", 1<<64 - 1, os.ERANGE}, + {"18446744073709551620", 1<<64 - 1, os.ERANGE}, + {"0xFFFFFFFFFFFFFFFF", 1<<64 - 1, nil}, + {"0x10000000000000000", 1<<64 - 1, os.ERANGE}, + {"01777777777777777777777", 1<<64 - 1, nil}, + {"01777777777777777777778", 0, os.EINVAL}, + {"02000000000000000000000", 1<<64 - 1, os.ERANGE}, + {"0200000000000000000000", 1 << 61, nil}, } type atoi64Test struct { @@ -58,47 +58,47 @@ type atoi64Test struct { } var atoi64tests = []atoi64Test{ - atoi64Test{"", 0, os.EINVAL}, - atoi64Test{"0", 0, nil}, - atoi64Test{"-0", 0, nil}, - atoi64Test{"1", 1, nil}, - atoi64Test{"-1", -1, nil}, - atoi64Test{"12345", 12345, nil}, - atoi64Test{"-12345", -12345, nil}, - atoi64Test{"012345", 12345, nil}, - atoi64Test{"-012345", -12345, nil}, - atoi64Test{"98765432100", 98765432100, nil}, - atoi64Test{"-98765432100", -98765432100, nil}, - atoi64Test{"9223372036854775807", 1<<63 - 1, nil}, - atoi64Test{"-9223372036854775807", -(1<<63 - 1), nil}, - atoi64Test{"9223372036854775808", 1<<63 - 1, os.ERANGE}, - atoi64Test{"-9223372036854775808", -1 << 63, nil}, - atoi64Test{"9223372036854775809", 1<<63 - 1, os.ERANGE}, - atoi64Test{"-9223372036854775809", -1 << 63, os.ERANGE}, + {"", 0, os.EINVAL}, + {"0", 0, nil}, + {"-0", 0, nil}, + {"1", 1, nil}, + {"-1", -1, nil}, + {"12345", 12345, nil}, + {"-12345", -12345, nil}, + {"012345", 12345, nil}, + {"-012345", -12345, nil}, + {"98765432100", 98765432100, nil}, + {"-98765432100", -98765432100, nil}, + {"9223372036854775807", 1<<63 - 1, nil}, + {"-9223372036854775807", -(1<<63 - 1), nil}, + {"9223372036854775808", 1<<63 - 1, os.ERANGE}, + {"-9223372036854775808", -1 << 63, nil}, + {"9223372036854775809", 1<<63 - 1, os.ERANGE}, + {"-9223372036854775809", -1 << 63, os.ERANGE}, } var btoi64tests = []atoi64Test{ - atoi64Test{"", 0, os.EINVAL}, - atoi64Test{"0", 0, nil}, - atoi64Test{"-0", 0, nil}, - atoi64Test{"1", 1, nil}, - atoi64Test{"-1", -1, nil}, - atoi64Test{"12345", 12345, nil}, - atoi64Test{"-12345", -12345, nil}, - atoi64Test{"012345", 012345, nil}, - atoi64Test{"-012345", -012345, nil}, - atoi64Test{"0x12345", 0x12345, nil}, - atoi64Test{"-0X12345", -0x12345, nil}, - atoi64Test{"12345x", 0, os.EINVAL}, - atoi64Test{"-12345x", 0, os.EINVAL}, - atoi64Test{"98765432100", 98765432100, nil}, - atoi64Test{"-98765432100", -98765432100, nil}, - atoi64Test{"9223372036854775807", 1<<63 - 1, nil}, - atoi64Test{"-9223372036854775807", -(1<<63 - 1), nil}, - atoi64Test{"9223372036854775808", 1<<63 - 1, os.ERANGE}, - atoi64Test{"-9223372036854775808", -1 << 63, nil}, - atoi64Test{"9223372036854775809", 1<<63 - 1, os.ERANGE}, - atoi64Test{"-9223372036854775809", -1 << 63, os.ERANGE}, + {"", 0, os.EINVAL}, + {"0", 0, nil}, + {"-0", 0, nil}, + {"1", 1, nil}, + {"-1", -1, nil}, + {"12345", 12345, nil}, + {"-12345", -12345, nil}, + {"012345", 012345, nil}, + {"-012345", -012345, nil}, + {"0x12345", 0x12345, nil}, + {"-0X12345", -0x12345, nil}, + {"12345x", 0, os.EINVAL}, + {"-12345x", 0, os.EINVAL}, + {"98765432100", 98765432100, nil}, + {"-98765432100", -98765432100, nil}, + {"9223372036854775807", 1<<63 - 1, nil}, + {"-9223372036854775807", -(1<<63 - 1), nil}, + {"9223372036854775808", 1<<63 - 1, os.ERANGE}, + {"-9223372036854775808", -1 << 63, nil}, + {"9223372036854775809", 1<<63 - 1, os.ERANGE}, + {"-9223372036854775809", -1 << 63, os.ERANGE}, } type atoui32Test struct { @@ -108,15 +108,15 @@ type atoui32Test struct { } var atoui32tests = []atoui32Test{ - atoui32Test{"", 0, os.EINVAL}, - atoui32Test{"0", 0, nil}, - atoui32Test{"1", 1, nil}, - atoui32Test{"12345", 12345, nil}, - atoui32Test{"012345", 12345, nil}, - atoui32Test{"12345x", 0, os.EINVAL}, - atoui32Test{"987654321", 987654321, nil}, - atoui32Test{"4294967295", 1<<32 - 1, nil}, - atoui32Test{"4294967296", 1<<32 - 1, os.ERANGE}, + {"", 0, os.EINVAL}, + {"0", 0, nil}, + {"1", 1, nil}, + {"12345", 12345, nil}, + {"012345", 12345, nil}, + {"12345x", 0, os.EINVAL}, + {"987654321", 987654321, nil}, + {"4294967295", 1<<32 - 1, nil}, + {"4294967296", 1<<32 - 1, os.ERANGE}, } type atoi32Test struct { @@ -126,25 +126,25 @@ type atoi32Test struct { } var atoi32tests = []atoi32Test{ - atoi32Test{"", 0, os.EINVAL}, - atoi32Test{"0", 0, nil}, - atoi32Test{"-0", 0, nil}, - atoi32Test{"1", 1, nil}, - atoi32Test{"-1", -1, nil}, - atoi32Test{"12345", 12345, nil}, - atoi32Test{"-12345", -12345, nil}, - atoi32Test{"012345", 12345, nil}, - atoi32Test{"-012345", -12345, nil}, - atoi32Test{"12345x", 0, os.EINVAL}, - atoi32Test{"-12345x", 0, os.EINVAL}, - atoi32Test{"987654321", 987654321, nil}, - atoi32Test{"-987654321", -987654321, nil}, - atoi32Test{"2147483647", 1<<31 - 1, nil}, - atoi32Test{"-2147483647", -(1<<31 - 1), nil}, - atoi32Test{"2147483648", 1<<31 - 1, os.ERANGE}, - atoi32Test{"-2147483648", -1 << 31, nil}, - atoi32Test{"2147483649", 1<<31 - 1, os.ERANGE}, - atoi32Test{"-2147483649", -1 << 31, os.ERANGE}, + {"", 0, os.EINVAL}, + {"0", 0, nil}, + {"-0", 0, nil}, + {"1", 1, nil}, + {"-1", -1, nil}, + {"12345", 12345, nil}, + {"-12345", -12345, nil}, + {"012345", 12345, nil}, + {"-012345", -12345, nil}, + {"12345x", 0, os.EINVAL}, + {"-12345x", 0, os.EINVAL}, + {"987654321", 987654321, nil}, + {"-987654321", -987654321, nil}, + {"2147483647", 1<<31 - 1, nil}, + {"-2147483647", -(1<<31 - 1), nil}, + {"2147483648", 1<<31 - 1, os.ERANGE}, + {"-2147483648", -1 << 31, nil}, + {"2147483649", 1<<31 - 1, os.ERANGE}, + {"-2147483649", -1 << 31, os.ERANGE}, } func init() { @@ -193,7 +193,7 @@ func TestAtoui64(t *testing.T) { test := &atoui64tests[i] out, err := Atoui64(test.in) if test.out != out || !reflect.DeepEqual(test.err, err) { - t.Errorf("Atoui64(%q) = %v, %v want %v, %v\n", + t.Errorf("Atoui64(%q) = %v, %v want %v, %v", test.in, out, err, test.out, test.err) } } @@ -204,7 +204,7 @@ func TestBtoui64(t *testing.T) { test := &btoui64tests[i] out, err := Btoui64(test.in, 0) if test.out != out || !reflect.DeepEqual(test.err, err) { - t.Errorf("Btoui64(%q) = %v, %v want %v, %v\n", + t.Errorf("Btoui64(%q) = %v, %v want %v, %v", test.in, out, err, test.out, test.err) } } @@ -215,7 +215,7 @@ func TestAtoi64(t *testing.T) { test := &atoi64tests[i] out, err := Atoi64(test.in) if test.out != out || !reflect.DeepEqual(test.err, err) { - t.Errorf("Atoi64(%q) = %v, %v want %v, %v\n", + t.Errorf("Atoi64(%q) = %v, %v want %v, %v", test.in, out, err, test.out, test.err) } } @@ -226,7 +226,7 @@ func TestBtoi64(t *testing.T) { test := &btoi64tests[i] out, err := Btoi64(test.in, 0) if test.out != out || !reflect.DeepEqual(test.err, err) { - t.Errorf("Btoi64(%q) = %v, %v want %v, %v\n", + t.Errorf("Btoi64(%q) = %v, %v want %v, %v", test.in, out, err, test.out, test.err) } } @@ -239,7 +239,7 @@ func TestAtoui(t *testing.T) { test := &atoui32tests[i] out, err := Atoui(test.in) if test.out != uint32(out) || !reflect.DeepEqual(test.err, err) { - t.Errorf("Atoui(%q) = %v, %v want %v, %v\n", + t.Errorf("Atoui(%q) = %v, %v want %v, %v", test.in, out, err, test.out, test.err) } } @@ -248,7 +248,7 @@ func TestAtoui(t *testing.T) { test := &atoui64tests[i] out, err := Atoui(test.in) if test.out != uint64(out) || !reflect.DeepEqual(test.err, err) { - t.Errorf("Atoui(%q) = %v, %v want %v, %v\n", + t.Errorf("Atoui(%q) = %v, %v want %v, %v", test.in, out, err, test.out, test.err) } } @@ -262,7 +262,7 @@ func TestAtoi(t *testing.T) { test := &atoi32tests[i] out, err := Atoi(test.in) if test.out != int32(out) || !reflect.DeepEqual(test.err, err) { - t.Errorf("Atoi(%q) = %v, %v want %v, %v\n", + t.Errorf("Atoi(%q) = %v, %v want %v, %v", test.in, out, err, test.out, test.err) } } @@ -271,7 +271,7 @@ func TestAtoi(t *testing.T) { test := &atoi64tests[i] out, err := Atoi(test.in) if test.out != int64(out) || !reflect.DeepEqual(test.err, err) { - t.Errorf("Atoi(%q) = %v, %v want %v, %v\n", + t.Errorf("Atoi(%q) = %v, %v want %v, %v", test.in, out, err, test.out, test.err) } } |