@@ -27,50 +27,3 @@ func TestElementMatcher_FindMatches(t *testing.T) {
2727 assert .ElementsMatch (t , []string {"flag" , "flag1" }, matcher .FindMatches ("flag1" ))
2828 })
2929}
30-
31- func Test_MatchElement (t * testing.T ) {
32- const FLAG_KEY = "testflag"
33-
34- testFlagDelimitedFlags := map [string ][]string {"testflag" : {"\" testflag\" " , "\" testflag'" , "\" testflag`" , "'testflag\" " , "'testflag'" , "'testflag`" , "`testflag\" " , "`testflag'" , "`testflag`" }}
35-
36- differentFlagDelimitedFlags := map [string ][]string {"different-flag" : {"\" different-flag\" " , "\" different-flag'" , "\" different-flag`" , "'different-flag\" " , "'different-flag'" , "'different-flag`" , "`different-flag\" " , "`different-flag'" , "`different-flag`" }}
37-
38- specs := []struct {
39- name string
40- expected bool
41- line string
42- matcher Matcher
43- }{
44- {
45- name : "match found - no delimiters" ,
46- expected : true ,
47- line : "var flagKey = 'testflag'" ,
48- matcher : Matcher {Delimiters : "" },
49- },
50- {
51- name : "match found - with delimters" ,
52- expected : true ,
53- line : "var flagKey = 'testflag'" ,
54- matcher : Matcher {Delimiters : defaultDelims , Elements : []ElementMatcher {{DelimitedFlags : differentFlagDelimitedFlags }, {DelimitedFlags : testFlagDelimitedFlags }}},
55- },
56- {
57- name : "no match found - no delimiters" ,
58- expected : false ,
59- line : "var flagKey = 'another-flag'" ,
60- matcher : Matcher {Delimiters : "" },
61- },
62- {
63- name : "no match found - with delimiters" ,
64- expected : false ,
65- line : "var flagKey = 'another-flag'" ,
66- matcher : Matcher {Delimiters : defaultDelims , Elements : []ElementMatcher {{DelimitedFlags : differentFlagDelimitedFlags }, {DelimitedFlags : testFlagDelimitedFlags }}},
67- },
68- }
69-
70- for _ , tt := range specs {
71- tt := tt
72- t .Run (tt .name , func (t * testing.T ) {
73- require .Equal (t , tt .expected , tt .matcher .MatchElement (tt .line , FLAG_KEY ))
74- })
75- }
76- }
0 commit comments