aboutsummaryrefslogtreecommitdiff
path: root/src/pkg/bytes/bytes_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/pkg/bytes/bytes_test.go')
-rw-r--r--src/pkg/bytes/bytes_test.go27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/pkg/bytes/bytes_test.go b/src/pkg/bytes/bytes_test.go
index dddaf5064e..3e737cb376 100644
--- a/src/pkg/bytes/bytes_test.go
+++ b/src/pkg/bytes/bytes_test.go
@@ -361,3 +361,30 @@ func TestAddByte(t *testing.T) {
}
}
}
+
+type RepeatTest struct {
+ in, out string;
+ count int;
+}
+
+var RepeatTests = []RepeatTest{
+ RepeatTest{"", "", 0},
+ RepeatTest{"", "", 1},
+ RepeatTest{"", "", 2},
+ RepeatTest{"-", "", 0},
+ RepeatTest{"-", "-", 1},
+ RepeatTest{"-", "----------", 10},
+ RepeatTest{"abc ", "abc abc abc ", 3},
+}
+
+func TestRepeat(t *testing.T) {
+ for _, tt := range RepeatTests {
+ tin := strings.Bytes(tt.in);
+ tout := strings.Bytes(tt.out);
+ a := Repeat(tin, tt.count);
+ if !Equal(a, tout) {
+ t.Errorf("Repeat(%q, %d) = %q; want %q", tin, tt.count, a, tout);
+ continue;
+ }
+ }
+}