summaryrefslogtreecommitdiff
path: root/src/lib/strconv/atoi_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/strconv/atoi_test.go')
-rw-r--r--src/lib/strconv/atoi_test.go154
1 files changed, 77 insertions, 77 deletions
diff --git a/src/lib/strconv/atoi_test.go b/src/lib/strconv/atoi_test.go
index 166c2e433..a071b7435 100644
--- a/src/lib/strconv/atoi_test.go
+++ b/src/lib/strconv/atoi_test.go
@@ -10,102 +10,102 @@ import (
"testing"
)
-type Uint64Test struct {
+type Atoui64Test struct {
in string;
out uint64;
err *os.Error;
}
-var uint64tests = []Uint64Test {
- Uint64Test{ "", 0, os.EINVAL },
- Uint64Test{ "0", 0, nil },
- Uint64Test{ "1", 1, nil },
- Uint64Test{ "12345", 12345, nil },
- Uint64Test{ "012345", 0, os.EINVAL },
- Uint64Test{ "12345x", 0, os.EINVAL },
- Uint64Test{ "98765432100", 98765432100, nil },
- Uint64Test{ "18446744073709551615", 1<<64-1, nil },
- Uint64Test{ "18446744073709551616", 1<<64-1, os.ERANGE },
- Uint64Test{ "18446744073709551620", 1<<64-1, os.ERANGE },
+var atoui64tests = []Atoui64Test {
+ Atoui64Test{ "", 0, os.EINVAL },
+ Atoui64Test{ "0", 0, nil },
+ Atoui64Test{ "1", 1, nil },
+ Atoui64Test{ "12345", 12345, nil },
+ Atoui64Test{ "012345", 0, os.EINVAL },
+ 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 },
}
-type Int64Test struct {
+type Atoi64Test struct {
in string;
out int64;
err *os.Error;
}
-var int64tests = []Int64Test {
- Int64Test{ "", 0, os.EINVAL },
- Int64Test{ "0", 0, nil },
- Int64Test{ "-0", 0, nil },
- Int64Test{ "1", 1, nil },
- Int64Test{ "-1", -1, nil },
- Int64Test{ "12345", 12345, nil },
- Int64Test{ "-12345", -12345, nil },
- Int64Test{ "012345", 0, os.EINVAL },
- Int64Test{ "-012345", 0, os.EINVAL },
- Int64Test{ "12345x", 0, os.EINVAL },
- Int64Test{ "-12345x", 0, os.EINVAL },
- Int64Test{ "98765432100", 98765432100, nil },
- Int64Test{ "-98765432100", -98765432100, nil },
- Int64Test{ "9223372036854775807", 1<<63-1, nil },
- Int64Test{ "-9223372036854775807", -(1<<63-1), nil },
- Int64Test{ "9223372036854775808", 1<<63-1, os.ERANGE },
- Int64Test{ "-9223372036854775808", -1<<63, nil },
- Int64Test{ "9223372036854775809", 1<<63-1, os.ERANGE },
- Int64Test{ "-9223372036854775809", -1<<63, os.ERANGE },
+var atoi64test = []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", 0, os.EINVAL },
+ Atoi64Test{ "-012345", 0, os.EINVAL },
+ 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 },
}
-type Uint32Test struct {
+type Atoui32Test struct {
in string;
out uint32;
err *os.Error;
}
-var uint32tests = []Uint32Test {
- Uint32Test{ "", 0, os.EINVAL },
- Uint32Test{ "0", 0, nil },
- Uint32Test{ "1", 1, nil },
- Uint32Test{ "12345", 12345, nil },
- Uint32Test{ "012345", 0, os.EINVAL },
- Uint32Test{ "12345x", 0, os.EINVAL },
- Uint32Test{ "987654321", 987654321, nil },
- Uint32Test{ "4294967295", 1<<32-1, nil },
- Uint32Test{ "4294967296", 1<<32-1, os.ERANGE },
+var atoui32tests = []Atoui32Test {
+ Atoui32Test{ "", 0, os.EINVAL },
+ Atoui32Test{ "0", 0, nil },
+ Atoui32Test{ "1", 1, nil },
+ Atoui32Test{ "12345", 12345, nil },
+ Atoui32Test{ "012345", 0, os.EINVAL },
+ Atoui32Test{ "12345x", 0, os.EINVAL },
+ Atoui32Test{ "987654321", 987654321, nil },
+ Atoui32Test{ "4294967295", 1<<32-1, nil },
+ Atoui32Test{ "4294967296", 1<<32-1, os.ERANGE },
}
-type Int32Test struct {
+type Atoi32Test struct {
in string;
out int32;
err *os.Error;
}
-var int32tests = []Int32Test {
- Int32Test{ "", 0, os.EINVAL },
- Int32Test{ "0", 0, nil },
- Int32Test{ "-0", 0, nil },
- Int32Test{ "1", 1, nil },
- Int32Test{ "-1", -1, nil },
- Int32Test{ "12345", 12345, nil },
- Int32Test{ "-12345", -12345, nil },
- Int32Test{ "012345", 0, os.EINVAL },
- Int32Test{ "-012345", 0, os.EINVAL },
- Int32Test{ "12345x", 0, os.EINVAL },
- Int32Test{ "-12345x", 0, os.EINVAL },
- Int32Test{ "987654321", 987654321, nil },
- Int32Test{ "-987654321", -987654321, nil },
- Int32Test{ "2147483647", 1<<31-1, nil },
- Int32Test{ "-2147483647", -(1<<31-1), nil },
- Int32Test{ "2147483648", 1<<31-1, os.ERANGE },
- Int32Test{ "-2147483648", -1<<31, nil },
- Int32Test{ "2147483649", 1<<31-1, os.ERANGE },
- Int32Test{ "-2147483649", -1<<31, os.ERANGE },
+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", 0, os.EINVAL },
+ Atoi32Test{ "-012345", 0, os.EINVAL },
+ 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 },
}
export func TestAtoui64(t *testing.T) {
- for i := 0; i < len(uint64tests); i++ {
- test := &uint64tests[i];
+ for i := 0; i < len(atoui64tests); i++ {
+ test := &atoui64tests[i];
out, err := strconv.atoui64(test.in);
if test.out != out || test.err != err {
t.Errorf("strconv.atoui64(%v) = %v, %v want %v, %v\n",
@@ -115,8 +115,8 @@ export func TestAtoui64(t *testing.T) {
}
export func TestAtoi64(t *testing.T) {
- for i := 0; i < len(int64tests); i++ {
- test := &int64tests[i];
+ for i := 0; i < len(atoi64test); i++ {
+ test := &atoi64test[i];
out, err := strconv.atoi64(test.in);
if test.out != out || test.err != err {
t.Errorf("strconv.atoi64(%v) = %v, %v want %v, %v\n",
@@ -136,8 +136,8 @@ func IntSize1() uint {
export func TestAtoui(t *testing.T) {
switch IntSize1() {
case 32:
- for i := 0; i < len(uint32tests); i++ {
- test := &uint32tests[i];
+ for i := 0; i < len(atoui32tests); i++ {
+ test := &atoui32tests[i];
out, err := strconv.atoui(test.in);
if test.out != uint32(out) || test.err != err {
t.Errorf("strconv.atoui(%v) = %v, %v want %v, %v\n",
@@ -145,8 +145,8 @@ export func TestAtoui(t *testing.T) {
}
}
case 64:
- for i := 0; i < len(uint64tests); i++ {
- test := &uint64tests[i];
+ for i := 0; i < len(atoui64tests); i++ {
+ test := &atoui64tests[i];
out, err := strconv.atoui(test.in);
if test.out != uint64(out) || test.err != err {
t.Errorf("strconv.atoui(%v) = %v, %v want %v, %v\n",
@@ -159,8 +159,8 @@ export func TestAtoui(t *testing.T) {
export func TestAtoi(t *testing.T) {
switch IntSize1() {
case 32:
- for i := 0; i < len(int32tests); i++ {
- test := &int32tests[i];
+ for i := 0; i < len(atoi32tests); i++ {
+ test := &atoi32tests[i];
out, err := strconv.atoi(test.in);
if test.out != int32(out) || test.err != err {
t.Errorf("strconv.atoi(%v) = %v, %v want %v, %v\n",
@@ -168,8 +168,8 @@ export func TestAtoi(t *testing.T) {
}
}
case 64:
- for i := 0; i < len(int64tests); i++ {
- test := &int64tests[i];
+ for i := 0; i < len(atoi64test); i++ {
+ test := &atoi64test[i];
out, err := strconv.atoi(test.in);
if test.out != int64(out) || test.err != err {
t.Errorf("strconv.atoi(%v) = %v, %v want %v, %v\n",