diff options
Diffstat (limited to 'skate/reduce_test.go')
-rw-r--r-- | skate/reduce_test.go | 87 |
1 files changed, 56 insertions, 31 deletions
diff --git a/skate/reduce_test.go b/skate/reduce_test.go index 4db0687..99c0ed7 100644 --- a/skate/reduce_test.go +++ b/skate/reduce_test.go @@ -34,37 +34,6 @@ func TestLineColumn(t *testing.T) { } } -func TestCutBatch(t *testing.T) { - var cases = []struct { - lines []string - column int - result []string - }{ - { - []string{}, - 1, - nil, - }, - { - []string{}, - 9, - nil, - }, - { - []string{"1\t2\n", "3\t4\n"}, - 2, - []string{"2", "4"}, - }, - } - for _, c := range cases { - result := CutBatch(c.lines, c.column) - if !reflect.DeepEqual(result, c.result) { - t.Fatalf("got %v (%d), want %v (%d)", - result, len(result), c.result, len(c.result)) - } - } -} - func TestUniqueMatches(t *testing.T) { var cases = []struct { about string @@ -453,3 +422,59 @@ func tempWriteFile(buf *bytes.Buffer) (string, error) { } return f.Name(), nil } + +func TestCutBatch(t *testing.T) { + var cases = []struct { + lines []string + column int + result []string + }{ + { + []string{}, + 1, + nil, + }, + { + []string{}, + 9, + nil, + }, + { + []string{"1\t2\n", "3\t4\n"}, + 2, + []string{"2", "4"}, + }, + } + for _, c := range cases { + result := CutBatch(c.lines, c.column) + if !reflect.DeepEqual(result, c.result) { + t.Fatalf("got %v (%d), want %v (%d)", + result, len(result), c.result, len(c.result)) + } + } +} + +func TestCutSep(t *testing.T) { + var cases = []struct { + line string + sep string + column int + result string + }{ + {"", "\t", 1, ""}, + {"", "\t", 2, ""}, + {"a\tb", "\t", 1, "a"}, + {"a\tb", "\t", 2, "b"}, + {"a\tb", "\t", 3, ""}, + {"a\t\tb", "\t", 1, "a"}, + {"a\t\tb", "\t", 2, ""}, + {"a\t\tb", "\t", 3, "b"}, + {"\tb", "\t", 1, ""}, + } + for _, c := range cases { + result := CutSep(c.line, c.sep, c.column) + if !reflect.DeepEqual(result, c.result) { + t.Fatalf("got %v, want %v", result, c.result) + } + } +} |