Skip to content

Commit 7dd1342

Browse files
Update Testcases
1 parent fc6395b commit 7dd1342

File tree

1 file changed

+27
-12
lines changed

1 file changed

+27
-12
lines changed

test_cases.py

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
noComment = 0
1515
hasBrief = False
1616
hasNewLine = True
17+
saveStatement = ""
1718

1819
for line in fin:
1920
i = i + 1
@@ -56,21 +57,40 @@
5657
state = 1
5758

5859
# --------------------------------------------------------------
60+
# Test case 9 is checking if there is '__'
61+
if line.find("__") != -1:
62+
print(file + " in line " + str(i) + ": not permitted use of '__' ")
63+
state = 1
64+
65+
# --------------------------------------------------------------
66+
# Divide statement and comment. Concatenate multi line statements.
5967

60-
# Search for comment ("//") and add one more slash character ("/") to the comment
61-
# block to make Doxygen detect it.
68+
# Search for comment ("//").
6269
matchComment = re.search("//", line)
6370
if matchComment is not None:
6471
statement = line[:matchComment.start()]
6572
comment = line[matchComment.end():]
6673
else:
6774
statement = line
6875
comment = ""
69-
76+
77+
# Add part of the statement from last line.
78+
statement = saveStatement + " " + statement
79+
saveStatement = ""
80+
7081
# New line is not necessary. Remove for a better output.
7182
statement = statement.replace("\n", "")
7283
comment = comment.replace("\n", "")
7384

85+
# Is statement complete
86+
matchSep = re.search(r"[{};]", statement)
87+
if matchSep is None:
88+
saveStatement = statement
89+
statement = ""
90+
else:
91+
saveStatement = statement[matchSep.end():]
92+
statement = statement[:matchSep.end()]
93+
7494
# --------------------------------------------------------------
7595
# Test case 6-8 camelcase for enums and check enum name?
7696

@@ -112,12 +132,6 @@ def convert(name):
112132
s1 = re.sub(r'(.)([A-Z][a-z]+)', r'\1_\2', name)
113133
return re.sub(r'([a-z0-9])([A-Z])', r'\1_\2', s1).upper()
114134

115-
# --------------------------------------------------------------
116-
# Test case 9 is checking if there is '__'
117-
if line.find("__") != -1:
118-
print(file + " in line " + str(i) + ": not permitted use of '__' ")
119-
state = 1
120-
121135
# --------------------------------------------------------------
122136
# Test case 10-12,18 check message name, field type and field name
123137
#
@@ -176,11 +190,11 @@ def convert(name):
176190

177191
# --------------------------------------------------------------
178192
# Test case 13-17 is checking comment
179-
if line.find("//") != -1:
193+
if matchComment is not None:
180194
noComment += 1;
181195
if comment.find("\\brief") != -1:
182196
hasBrief = True;
183-
else:
197+
elif len(saveStatement) == 0:
184198
# Test case 13 is checking if comment is min. 2 lines
185199
if noComment == 1:
186200
print(file + " in line " + str(i-1) + ": short comment - min. 2 lines.")
@@ -207,7 +221,8 @@ def convert(name):
207221
# Test case 17 every statement has a comment
208222
print(file + " in line " + str(i) + ": comment is missing for: '"+statement+"'")
209223
state = 1
210-
224+
225+
211226
noComment = 0
212227
hasBrief = False
213228

0 commit comments

Comments
 (0)