summaryrefslogtreecommitdiff
path: root/src/lib/strings_test.go
diff options
context:
space:
mode:
authorRob Pike <r@golang.org>2009-05-05 17:05:39 -0700
committerRob Pike <r@golang.org>2009-05-05 17:05:39 -0700
commitb6708b2dad4af458e69fde7fc596ecdce03280d0 (patch)
tree11cfc1b980ecce9cb0eec06f49cc53ce05faf350 /src/lib/strings_test.go
parent658b10477a16151de7e4d51657993f95445f11ee (diff)
downloadgolang-b6708b2dad4af458e69fde7fc596ecdce03280d0.tar.gz
directory-per-package step 1: move files from lib/X.go to lib/X/X.go
no substantive changes except: - new Makefiles, all auto-generated - go/src/lib/Makefile has been extensively edited R=rsc OCL=28310 CL=28310
Diffstat (limited to 'src/lib/strings_test.go')
-rw-r--r--src/lib/strings_test.go81
1 files changed, 0 insertions, 81 deletions
diff --git a/src/lib/strings_test.go b/src/lib/strings_test.go
deleted file mode 100644
index 2cbf70b93..000000000
--- a/src/lib/strings_test.go
+++ /dev/null
@@ -1,81 +0,0 @@
-// 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 strings
-
-import (
- "strings";
- "testing";
-)
-
-func eq(a, b []string) bool {
- if len(a) != len(b) {
- return false;
- }
- for i := 0; i < len(a); i++ {
- if a[i] != b[i] {
- return false;
- }
- }
- return true;
-}
-
-var abcd = "abcd";
-var faces = "☺☻☹";
-var commas = "1,2,3,4";
-var dots = "1....2....3....4";
-
-type ExplodeTest struct {
- s string;
- a []string;
-}
-var explodetests = []ExplodeTest {
- ExplodeTest{ abcd, []string{"a", "b", "c", "d"} },
- ExplodeTest{ faces, []string{"☺", "☻", "☹" } },
-}
-func TestExplode(t *testing.T) {
- for i := 0; i < len(explodetests); i++ {
- tt := explodetests[i];
- a := Explode(tt.s);
- if !eq(a, tt.a) {
- t.Errorf("Explode(%q) = %v; want %v", tt.s, a, tt.a);
- continue;
- }
- s := Join(a, "");
- if s != tt.s {
- t.Errorf(`Join(Explode(%q), "") = %q`, tt.s, s);
- }
- }
-}
-
-type SplitTest struct {
- s string;
- sep string;
- a []string;
-}
-var splittests = []SplitTest {
- SplitTest{ abcd, "a", []string{"", "bcd"} },
- SplitTest{ abcd, "z", []string{"abcd"} },
- SplitTest{ abcd, "", []string{"a", "b", "c", "d"} },
- SplitTest{ commas, ",", []string{"1", "2", "3", "4"} },
- SplitTest{ dots, "...", []string{"1", ".2", ".3", ".4"} },
- SplitTest{ faces, "☹", []string{"☺☻", ""} },
- SplitTest{ faces, "~", []string{faces} },
- SplitTest{ faces, "", []string{"☺", "☻", "☹"} },
-}
-func TestSplit(t *testing.T) {
- for i := 0; i < len(splittests); i++ {
- tt := splittests[i];
- a := Split(tt.s, tt.sep);
- if !eq(a, tt.a) {
- t.Errorf("Split(%q, %q) = %v; want %v", tt.s, tt.sep, a, tt.a);
- continue;
- }
- s := Join(a, tt.sep);
- if s != tt.s {
- t.Errorf("Join(Split(%q, %q), %q) = %q", tt.s, tt.sep, tt.sep, s);
- }
- }
-}
-