@@ -105,4 +105,42 @@ func TestCheckOptionMatch(t *testing.T) {
105105 if ! checkOptionMatch ("/thisisdir/one.go" , fi , opts ) {
106106 t .Errorf ("invalid logic: renotmatchdir is not ignore" )
107107 }
108+
109+ t .Run ("--match option" , func (t * testing.T ) {
110+ opts = & ClocOptions {
111+ ReMatch : regexp .MustCompile ("app.py" ),
112+ }
113+ fi = MockFileInfo {FileName : "app.py" , IsDirectory : false }
114+ if ! checkOptionMatch ("test_dir/app.py" , fi , opts ) {
115+ t .Errorf ("invalid logic: match is not ignore" )
116+ }
117+ })
118+
119+ t .Run ("--match option with --fullpath option" , func (t * testing.T ) {
120+ opts = & ClocOptions {
121+ ReMatch : regexp .MustCompile ("test_dir/app.py" ),
122+ Fullpath : true ,
123+ }
124+ fi = MockFileInfo {FileName : "app.py" , IsDirectory : false }
125+ if ! checkOptionMatch ("test_dir/app.py" , fi , opts ) {
126+ t .Errorf ("invalid logic: match(with fullpath) is not ignore" )
127+ }
128+ if checkOptionMatch ("app.py" , fi , opts ) {
129+ t .Errorf ("invalid logic: match(with fullpath) is ignore" )
130+ }
131+ })
132+
133+ t .Run ("--not-match option with --fullpath option" , func (t * testing.T ) {
134+ opts = & ClocOptions {
135+ ReNotMatch : regexp .MustCompile ("test_dir/app.py" ),
136+ Fullpath : true ,
137+ }
138+ fi = MockFileInfo {FileName : "app.py" , IsDirectory : false }
139+ if checkOptionMatch ("test_dir/app.py" , fi , opts ) {
140+ t .Errorf ("invalid logic: not-match(with fullpath) is ignore" )
141+ }
142+ if ! checkOptionMatch ("app.py" , fi , opts ) {
143+ t .Errorf ("invalid logic: not-match(with fullpath) is not ignore" )
144+ }
145+ })
108146}
0 commit comments