Skip to content

Commit d46f3c9

Browse files
kunaltyagityagikunal
authored andcommitted
Added tests for PR #5
1 parent ba2ad93 commit d46f3c9

File tree

1 file changed

+34
-11
lines changed

1 file changed

+34
-11
lines changed

rules/RULE_3_2_H_do_not_use_underbars_for_cpp_filename.py

+34-11
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,16 @@
66
== Vilolation ==
77
88
/testdir/test_1.cpp <== Violation. - is used.
9-
/testdir1/_test1.cpp <== Violation. _ is used
9+
/testdir1/_test1.cxx <== Violation. _ is used
10+
/testdir/test_1.cc <== Violation. - is used.
11+
/testdir1/_test1.mm <== Violation. _ is used
1012
1113
== Good ==
1214
13-
testdir/test.cpp
15+
testdir/test.cpp
16+
testdir/test.cxx
17+
testdir/test.cc
18+
testdir/test.mm
1419
testdir1/test_1.c <== Don't care. it's c file.
1520
"""
1621

@@ -19,8 +24,8 @@
1924
from nsiqcppstyle_rulemanager import *
2025

2126
def RunRule(lexer, filename, dirname) :
22-
if Search("[_]", filename) and filename[filename.rfind("."):] in (".cpp", ".cxx", "cc", "mm") :
23-
nsiqcppstyle_reporter.Error(DummyToken(lexer.filename, "", 0,0), __name__,
27+
if Search("[_]", filename) and filename[filename.rfind("."):] in (".cpp", ".cxx", ".cc", ".mm") :
28+
nsiqcppstyle_reporter.Error(DummyToken(lexer.filename, "", 0,0), __name__,
2429
"Do not use underbar for cpp file name (%s)." % filename)
2530

2631
ruleManager.AddFileStartRule(RunRule)
@@ -40,15 +45,33 @@ def RunRule(lexer, filename, dirname) :
4045
class testRule(nct):
4146
def setUpRule(self):
4247
ruleManager.AddFileStartRule(RunRule)
43-
48+
4449
def test1(self):
45-
self.Analyze("test/this_file.cpp", "")
46-
assert CheckErrorContent(__name__)
47-
def test2(self):
4850
self.Analyze("test/thisfile.cpp", "")
4951
assert not CheckErrorContent(__name__)
50-
51-
def test3(self):
52+
def test2(self):
5253
self.Analyze("test/this_file.c", "")
5354
assert not CheckErrorContent(__name__)
54-
55+
def test3(self):
56+
self.Analyze("test/thisfile.cxx", "")
57+
assert not CheckErrorContent(__name__)
58+
def test4(self):
59+
self.Analyze("test/thisfile.cc", "")
60+
assert not CheckErrorContent(__name__)
61+
def test5(self):
62+
self.Analyze("test/thisfile.mm", "")
63+
assert not CheckErrorContent(__name__)
64+
65+
def test6(self):
66+
self.Analyze("test/this_file.cxx", "")
67+
assert CheckErrorContent(__name__)
68+
def test7(self):
69+
self.Analyze("test/this_file.cpp", "")
70+
assert CheckErrorContent(__name__)
71+
def test8(self):
72+
self.Analyze("test/this_file.cc", "")
73+
assert CheckErrorContent(__name__)
74+
def test9(self):
75+
self.Analyze("test/this_file.mm", "")
76+
assert CheckErrorContent(__name__)
77+

0 commit comments

Comments
 (0)