aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/string_test.go
diff options
context:
space:
mode:
authorMichael Pratt <mpratt@google.com>2025-05-14 15:53:58 -0400
committerGopher Robot <gobot@golang.org>2025-05-19 12:46:19 -0700
commit76e7bfbb4e3a6114a33c7dba666fdd26698bedc5 (patch)
treea3c5738900dba5ff5e40f43ddda7dcb14b9ddae2 /src/runtime/string_test.go
parentd93bea0e59e51c2d85e69f28f09726b5c9fc81d2 (diff)
downloadgo-76e7bfbb4e3a6114a33c7dba666fdd26698bedc5.tar.xz
runtime: move atoi to internal/runtime/strconv
Moving to a smaller package allows its use in other internal/runtime packages. This isn't internal/strconvlite since it can't be used directly by strconv. For #73193. Change-Id: I6a6a636c9c8b3f06b5fd6c07fe9dd5a7a37d1429 Reviewed-on: https://go-review.googlesource.com/c/go/+/672697 Reviewed-by: Michael Knyszek <mknyszek@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Michael Pratt <mpratt@google.com>
Diffstat (limited to 'src/runtime/string_test.go')
-rw-r--r--src/runtime/string_test.go92
1 files changed, 0 insertions, 92 deletions
diff --git a/src/runtime/string_test.go b/src/runtime/string_test.go
index cfc0ad7cde..522a502a1c 100644
--- a/src/runtime/string_test.go
+++ b/src/runtime/string_test.go
@@ -390,98 +390,6 @@ func TestString2Slice(t *testing.T) {
const intSize = 32 << (^uint(0) >> 63)
-type atoi64Test struct {
- in string
- out int64
- ok bool
-}
-
-var atoi64tests = []atoi64Test{
- {"", 0, false},
- {"0", 0, true},
- {"-0", 0, true},
- {"1", 1, true},
- {"-1", -1, true},
- {"12345", 12345, true},
- {"-12345", -12345, true},
- {"012345", 12345, true},
- {"-012345", -12345, true},
- {"12345x", 0, false},
- {"-12345x", 0, false},
- {"98765432100", 98765432100, true},
- {"-98765432100", -98765432100, true},
- {"20496382327982653440", 0, false},
- {"-20496382327982653440", 0, false},
- {"9223372036854775807", 1<<63 - 1, true},
- {"-9223372036854775807", -(1<<63 - 1), true},
- {"9223372036854775808", 0, false},
- {"-9223372036854775808", -1 << 63, true},
- {"9223372036854775809", 0, false},
- {"-9223372036854775809", 0, false},
-}
-
-func TestAtoi(t *testing.T) {
- switch intSize {
- case 32:
- for i := range atoi32tests {
- test := &atoi32tests[i]
- out, ok := runtime.Atoi(test.in)
- if test.out != int32(out) || test.ok != ok {
- t.Errorf("atoi(%q) = (%v, %v) want (%v, %v)",
- test.in, out, ok, test.out, test.ok)
- }
- }
- case 64:
- for i := range atoi64tests {
- test := &atoi64tests[i]
- out, ok := runtime.Atoi(test.in)
- if test.out != int64(out) || test.ok != ok {
- t.Errorf("atoi(%q) = (%v, %v) want (%v, %v)",
- test.in, out, ok, test.out, test.ok)
- }
- }
- }
-}
-
-type atoi32Test struct {
- in string
- out int32
- ok bool
-}
-
-var atoi32tests = []atoi32Test{
- {"", 0, false},
- {"0", 0, true},
- {"-0", 0, true},
- {"1", 1, true},
- {"-1", -1, true},
- {"12345", 12345, true},
- {"-12345", -12345, true},
- {"012345", 12345, true},
- {"-012345", -12345, true},
- {"12345x", 0, false},
- {"-12345x", 0, false},
- {"987654321", 987654321, true},
- {"-987654321", -987654321, true},
- {"2147483647", 1<<31 - 1, true},
- {"-2147483647", -(1<<31 - 1), true},
- {"2147483648", 0, false},
- {"-2147483648", -1 << 31, true},
- {"2147483649", 0, false},
- {"-2147483649", 0, false},
-}
-
-func TestAtoi32(t *testing.T) {
- for i := range atoi32tests {
- test := &atoi32tests[i]
- out, ok := runtime.Atoi32(test.in)
- if test.out != out || test.ok != ok {
- t.Errorf("atoi32(%q) = (%v, %v) want (%v, %v)",
- test.in, out, ok, test.out, test.ok)
- }
- }
-}
-
func TestParseByteCount(t *testing.T) {
for _, test := range []struct {
in string