summaryrefslogtreecommitdiff
path: root/src/lib/strconv/itoa_test.go
diff options
context:
space:
mode:
authorRob Pike <r@golang.org>2008-11-19 19:11:01 -0800
committerRob Pike <r@golang.org>2008-11-19 19:11:01 -0800
commit58f7022b3ac96b1478c544c4f1892abd9b4803b9 (patch)
tree81b27c09f43aede65a97648aa943b2901e9f2c3b /src/lib/strconv/itoa_test.go
parente49f6f5647fbdbe74d7679d7cf0539fdfcd6b213 (diff)
downloadgolang-58f7022b3ac96b1478c544c4f1892abd9b4803b9.tar.gz
change naming convention for tests from
test*.go to *test.go R=rsc DELTA=1747 (864 added, 855 deleted, 28 changed) OCL=19666 CL=19666
Diffstat (limited to 'src/lib/strconv/itoa_test.go')
-rw-r--r--src/lib/strconv/itoa_test.go77
1 files changed, 77 insertions, 0 deletions
diff --git a/src/lib/strconv/itoa_test.go b/src/lib/strconv/itoa_test.go
new file mode 100644
index 000000000..89a97339e
--- /dev/null
+++ b/src/lib/strconv/itoa_test.go
@@ -0,0 +1,77 @@
+// Copyright 2009 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package strconv
+
+import (
+ "fmt";
+ "os";
+ "strconv";
+ "testing";
+)
+
+type Int64Test struct {
+ in int64;
+ out string;
+}
+
+// TODO: should be called int64tests
+
+var xint64tests = []Int64Test {
+ Int64Test{ 0, "0" },
+ Int64Test{ 1, "1" },
+ Int64Test{ -1, "-1" },
+ Int64Test{ 12345678, "12345678" },
+ Int64Test{ -987654321, "-987654321" },
+ Int64Test{ 1<<31-1, "2147483647" },
+ Int64Test{ -1<<31+1, "-2147483647" },
+ Int64Test{ 1<<31, "2147483648" },
+ Int64Test{ -1<<31, "-2147483648" },
+ Int64Test{ 1<<31+1, "2147483649" },
+ Int64Test{ -1<<31-1, "-2147483649" },
+ Int64Test{ 1<<32-1, "4294967295" },
+ Int64Test{ -1<<32+1, "-4294967295" },
+ Int64Test{ 1<<32, "4294967296" },
+ Int64Test{ -1<<32, "-4294967296" },
+ Int64Test{ 1<<32+1, "4294967297" },
+ Int64Test{ -1<<32-1, "-4294967297" },
+ Int64Test{ 1<<50, "1125899906842624" },
+ Int64Test{ 1<<63-1, "9223372036854775807" },
+ Int64Test{ -1<<63+1, "-9223372036854775807" },
+ Int64Test{ -1<<63, "-9223372036854775808" },
+}
+
+export func TestItoa(t *testing.T) {
+ for i := 0; i < len(xint64tests); i++ {
+ test := xint64tests[i];
+ s := strconv.itoa64(test.in);
+ if s != test.out {
+ t.Error("strconv.itoa64(%v) = %v want %v\n",
+ test.in, s, test.out);
+ }
+ if int64(int(test.in)) == test.in {
+ s := strconv.itoa(int(test.in));
+ if s != test.out {
+ t.Error("strconv.itoa(%v) = %v want %v\n",
+ test.in, s, test.out);
+ }
+ }
+ }
+}
+
+// TODO: Use once there is a strconv.uitoa
+type Uint64Test struct {
+ in uint64;
+ out string;
+}
+
+// TODO: should be able to call this uint64tests.
+var xuint64tests = []Uint64Test {
+ Uint64Test{ 1<<63-1, "9223372036854775807" },
+ Uint64Test{ 1<<63, "9223372036854775808" },
+ Uint64Test{ 1<<63+1, "9223372036854775809" },
+ Uint64Test{ 1<<64-2, "18446744073709551614" },
+ Uint64Test{ 1<<64-1, "18446744073709551615" },
+}
+