MCPcopy Create free account
hub / github.com/goadesign/goa / TestNameScope_Unique

Function TestNameScope_Unique

codegen/scope_test.go:9–40  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

7)
8
9func TestNameScope_Unique(t *testing.T) {
10 sequence := []struct {
11 Input string
12 Suffix []string
13 Expected string
14 }{
15 {Input: "a", Expected: "a"},
16 {Input: "a", Expected: "a2"},
17 {Input: "a", Expected: "a3"},
18 {Input: "a", Expected: "a4"},
19 {Input: "b", Expected: "b"},
20 {Input: "c", Expected: "c"},
21 {Input: "hel", Expected: "hel"},
22 {Input: "hel", Suffix: []string{"lo"}, Expected: "hello"},
23 {Input: "hello", Expected: "hello2"},
24 {Input: "hello", Suffix: []string{"1"}, Expected: "hello1"},
25 {Input: "hello", Suffix: []string{"1"}, Expected: "hello12"},
26 {Input: "hello", Suffix: []string{"2"}, Expected: "hello22"},
27 {Input: "hello", Suffix: []string{"2"}, Expected: "hello23"},
28 {Input: "hello,world", Expected: "hello,world"},
29 {Input: "hello,world1", Expected: "hello,world1"},
30 {Input: "hello,world2", Expected: "hello,world2"},
31 {Input: "hello", Suffix: []string{",world"}, Expected: "hello,world3"},
32 }
33
34 scope := NewNameScope()
35 for i, v := range sequence {
36 if got := scope.Unique(v.Input, v.Suffix...); v.Expected != got {
37 t.Errorf("#%v, expected %v, got %v", i, v.Expected, got)
38 }
39 }
40}
41
42func TestNameScope_GoFullTypeName_UsesScopedNameWhenQualified(t *testing.T) {
43 scope := NewNameScope()

Callers

nothing calls this directly

Calls 2

UniqueMethod · 0.95
NewNameScopeFunction · 0.85

Tested by

no test coverage detected