summaryrefslogtreecommitdiff
path: root/libgo/go/strconv/atoi_test.go
diff options
context:
space:
mode:
authorian <ian@138bc75d-0d04-0410-961f-82ee72b054a4>2015-10-31 00:59:47 +0000
committerian <ian@138bc75d-0d04-0410-961f-82ee72b054a4>2015-10-31 00:59:47 +0000
commit4a3da3a8a45d5496118798146de1fa4e5798ed5a (patch)
tree13beeaed3698c61903fe93fb1ce70bd9b18d4e7f /libgo/go/strconv/atoi_test.go
parentcd529f4d86a17a3e8959f2cb5ac7132a841ab6f1 (diff)
downloadgcc-4a3da3a8a45d5496118798146de1fa4e5798ed5a.tar.gz
runtime: Remove now unnecessary pad field from ParFor.
It is not needed due to the removal of the ctx field. Reviewed-on: https://go-review.googlesource.com/16525 git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@229616 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libgo/go/strconv/atoi_test.go')
-rw-r--r--libgo/go/strconv/atoi_test.go83
1 files changed, 60 insertions, 23 deletions
diff --git a/libgo/go/strconv/atoi_test.go b/libgo/go/strconv/atoi_test.go
index 94075730788..bd6a6a01fa1 100644
--- a/libgo/go/strconv/atoi_test.go
+++ b/libgo/go/strconv/atoi_test.go
@@ -33,12 +33,16 @@ var atoui64tests = []atoui64Test{
var btoui64tests = []atoui64Test{
{"", 0, ErrSyntax},
{"0", 0, nil},
+ {"0x", 0, ErrSyntax},
+ {"0X", 0, ErrSyntax},
{"1", 1, nil},
{"12345", 12345, nil},
{"012345", 012345, nil},
{"0x12345", 0x12345, nil},
{"0X12345", 0x12345, nil},
{"12345x", 0, ErrSyntax},
+ {"0xabcdefg123", 0, ErrSyntax},
+ {"123456789abc", 0, ErrSyntax},
{"98765432100", 98765432100, nil},
{"18446744073709551615", 1<<64 - 1, nil},
{"18446744073709551616", 1<<64 - 1, ErrRange},
@@ -77,28 +81,61 @@ var atoi64tests = []atoi64Test{
{"-9223372036854775809", -1 << 63, ErrRange},
}
-var btoi64tests = []atoi64Test{
- {"", 0, ErrSyntax},
- {"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, ErrSyntax},
- {"-12345x", 0, ErrSyntax},
- {"98765432100", 98765432100, nil},
- {"-98765432100", -98765432100, nil},
- {"9223372036854775807", 1<<63 - 1, nil},
- {"-9223372036854775807", -(1<<63 - 1), nil},
- {"9223372036854775808", 1<<63 - 1, ErrRange},
- {"-9223372036854775808", -1 << 63, nil},
- {"9223372036854775809", 1<<63 - 1, ErrRange},
- {"-9223372036854775809", -1 << 63, ErrRange},
+type btoi64Test struct {
+ in string
+ base int
+ out int64
+ err error
+}
+
+var btoi64tests = []btoi64Test{
+ {"", 0, 0, ErrSyntax},
+ {"0", 0, 0, nil},
+ {"-0", 0, 0, nil},
+ {"1", 0, 1, nil},
+ {"-1", 0, -1, nil},
+ {"12345", 0, 12345, nil},
+ {"-12345", 0, -12345, nil},
+ {"012345", 0, 012345, nil},
+ {"-012345", 0, -012345, nil},
+ {"0x12345", 0, 0x12345, nil},
+ {"-0X12345", 0, -0x12345, nil},
+ {"12345x", 0, 0, ErrSyntax},
+ {"-12345x", 0, 0, ErrSyntax},
+ {"98765432100", 0, 98765432100, nil},
+ {"-98765432100", 0, -98765432100, nil},
+ {"9223372036854775807", 0, 1<<63 - 1, nil},
+ {"-9223372036854775807", 0, -(1<<63 - 1), nil},
+ {"9223372036854775808", 0, 1<<63 - 1, ErrRange},
+ {"-9223372036854775808", 0, -1 << 63, nil},
+ {"9223372036854775809", 0, 1<<63 - 1, ErrRange},
+ {"-9223372036854775809", 0, -1 << 63, ErrRange},
+
+ // other bases
+ {"g", 17, 16, nil},
+ {"10", 25, 25, nil},
+ {"holycow", 35, (((((17*35+24)*35+21)*35+34)*35+12)*35+24)*35 + 32, nil},
+ {"holycow", 36, (((((17*36+24)*36+21)*36+34)*36+12)*36+24)*36 + 32, nil},
+
+ // base 2
+ {"0", 2, 0, nil},
+ {"-1", 2, -1, nil},
+ {"1010", 2, 10, nil},
+ {"1000000000000000", 2, 1 << 15, nil},
+ {"111111111111111111111111111111111111111111111111111111111111111", 2, 1<<63 - 1, nil},
+ {"1000000000000000000000000000000000000000000000000000000000000000", 2, 1<<63 - 1, ErrRange},
+ {"-1000000000000000000000000000000000000000000000000000000000000000", 2, -1 << 63, nil},
+ {"-1000000000000000000000000000000000000000000000000000000000000001", 2, -1 << 63, ErrRange},
+
+ // base 8
+ {"-10", 8, -8, nil},
+ {"57635436545", 8, 057635436545, nil},
+ {"100000000", 8, 1 << 24, nil},
+
+ // base 16
+ {"10", 16, 16, nil},
+ {"-123456789abcdef", 16, -0x123456789abcdef, nil},
+ {"7fffffffffffffff", 16, 1<<63 - 1, nil},
}
type atoui32Test struct {
@@ -234,7 +271,7 @@ func TestParseInt64(t *testing.T) {
func TestParseInt64Base(t *testing.T) {
for i := range btoi64tests {
test := &btoi64tests[i]
- out, err := ParseInt(test.in, 0, 64)
+ out, err := ParseInt(test.in, test.base, 64)
if test.out != out || !reflect.DeepEqual(test.err, err) {
t.Errorf("ParseInt(%q) = %v, %v want %v, %v",
test.in, out, err, test.out, test.err)