1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
|
// Copyright 2013 Google Inc. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package getopt
import (
"testing"
)
var breakupTests = []struct {
in string
max int
out []string
}{
{"", 8, []string{}},
{"a fox", 8, []string{"a fox"}},
{"a foxhound is sly", 2, []string{"a", "foxhound", "is", "sly"}},
{"a foxhound is sly", 5, []string{"a", "foxhound", "is", "sly"}},
{"a foxhound is sly", 6, []string{"a", "foxhound", "is sly"}},
{"a foxhound is sly", 7, []string{"a", "foxhound", "is sly"}},
{"a foxhound is sly", 8, []string{"a", "foxhound", "is sly"}},
{"a foxhound is sly", 9, []string{"a", "foxhound", "is sly"}},
{"a foxhound is sly", 10, []string{"a foxhound", "is sly"}},
}
func TestBreakup(t *testing.T) {
for x, tt := range breakupTests {
out := breakup(tt.in, tt.max)
if badSlice(out, tt.out) {
t.Errorf("#%d: got %v, want %v", x, out, tt.out)
}
}
}
|