forked from goadesign/goa
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscope_test.go
38 lines (35 loc) · 1.15 KB
/
scope_test.go
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
35
36
37
38
package codegen
import (
"testing"
)
func TestNameScope_Unique(t *testing.T) {
sequence := []struct {
Input string
Suffix []string
Expected string
}{
{Input: "a", Expected: "a"},
{Input: "a", Expected: "a2"},
{Input: "a", Expected: "a3"},
{Input: "a", Expected: "a4"},
{Input: "b", Expected: "b"},
{Input: "c", Expected: "c"},
{Input: "hel", Expected: "hel"},
{Input: "hel", Suffix: []string{"lo"}, Expected: "hello"},
{Input: "hello", Expected: "hello2"},
{Input: "hello", Suffix: []string{"1"}, Expected: "hello1"},
{Input: "hello", Suffix: []string{"1"}, Expected: "hello12"},
{Input: "hello", Suffix: []string{"2"}, Expected: "hello22"},
{Input: "hello", Suffix: []string{"2"}, Expected: "hello23"},
{Input: "hello,world", Expected: "hello,world"},
{Input: "hello,world1", Expected: "hello,world1"},
{Input: "hello,world2", Expected: "hello,world2"},
{Input: "hello", Suffix: []string{",world"}, Expected: "hello,world3"},
}
scope := NewNameScope()
for i, v := range sequence {
if got := scope.Unique(v.Input, v.Suffix...); v.Expected != got {
t.Errorf("#%v, expected %v, got %v", i, v.Expected, got)
}
}
}