...
1 package denco_test
2
3 import (
4 "reflect"
5 "testing"
6
7 "github.com/go-openapi/runtime/middleware/denco"
8 )
9
10 func TestNextSeparator(t *testing.T) {
11 for _, testcase := range []struct {
12 path string
13 start int
14 expected interface{}
15 }{
16 {"/path/to/route", 0, 0},
17 {"/path/to/route", 1, 5},
18 {"/path/to/route", 9, 14},
19 {"/path.html", 1, 10},
20 {"/foo/bar.html", 1, 4},
21 {"/foo/bar.html/baz.png", 5, 13},
22 {"/foo/bar.html/baz.png", 14, 21},
23 {"path#", 0, 4},
24 } {
25 actual := denco.NextSeparator(testcase.path, testcase.start)
26 expected := testcase.expected
27 if !reflect.DeepEqual(actual, expected) {
28 t.Errorf("path = %q, start = %v expect %v, but %v", testcase.path, testcase.start, expected, actual)
29 }
30 }
31 }
32
View as plain text