Skip to content

Commit d0a1f26

Browse files
author
Desperationis
committed
Fixed bugs and added unit tests
1 parent 07ea260 commit d0a1f26

File tree

3 files changed

+111
-15
lines changed

3 files changed

+111
-15
lines changed

RobotCDocs/FileScanner.py

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,11 @@ class FileScanner(Reader):
1010
def __init__(self, file):
1111
super().__init__(file)
1212

13-
# Given a directory (E.x. \Desktop\File.h), only save
14-
# the name of the file (E.x. "File")
15-
self.categoryName = self.fileName.split('\\')[-1].split('.')[0]
13+
# Given a directory (E.x. \Desktop\File.h), only save the actual file name (File.h)
14+
self.docFileName = self.fileName.split('\\')[-1]
15+
16+
# The name of the file (E.x. "File")
17+
self.categoryName = self.docFileName.split('.')[0]
1618
self.docs = []
1719

1820
try:
@@ -56,6 +58,15 @@ def Parse(self):
5658
line = line.replace(' * ', "")
5759
line = line.replace(' *', "")
5860

61+
if '@' in line:
62+
63+
# Split the line into words, then get the name of the category.
64+
words = line.split(' ')
65+
for word in words:
66+
if '@' in word:
67+
doc.category = word.split('@')[-1].capitalize()
68+
break
69+
5970
# Join sentences together to make one long string.
6071
doc.description += line
6172

@@ -66,16 +77,8 @@ def Parse(self):
6677
doc.description += ' '
6778

6879
elif '/*' not in line and '*/' not in line:
69-
print('FileScanner.py: Warning: Line %s of %s is missing a \' *\'' % (self.currentLine - 1, self.fileName))
70-
71-
if '@' in line:
80+
print('FileScanner.py: Warning: Line %s of %s is missing a \' *\'; Line will be skipped.' % (self.currentLine + 1, self.docFileName))
7281

73-
# Split the line into words, then get the name of the category.
74-
words = line.split(' ')
75-
for word in words:
76-
if '@' in word:
77-
doc.category = word.split('@')[-1].capitalize()
78-
break
7982

8083

8184
if '*/' in line:
@@ -84,7 +87,7 @@ def Parse(self):
8487
if ';' in doc.declaration:
8588
self.docs.append(doc)
8689
else:
87-
print('FileScanner.py: Warning: Line %s of %s was skipped due to missing a declaration.' % (self.currentLine - 1, self.fileName))
90+
print('FileScanner.py: Warning: Line %s of %s was skipped due to missing a declaration.' % (self.currentLine + 1, self.docFileName))
8891

8992
doc = Doc()
9093
doc.category = self.categoryName

RobotCDocs/Unit Test/main.c

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
2+
3+
4+
// Here's a nunch of space to test the accruacy of my error logger.
5+
6+
7+
8+
9+
10+
11+
12+
13+
14+
15+
16+
17+
/*
18+
* Test 1.
19+
* This line should have a space between this and the last period.
20+
* This line should also have a space.
21+
* The function below me should have all of types removed.
22+
*/
23+
void Test1(tMotor motorPort, byte speed, bool reversed);
24+
25+
26+
/*
27+
* @test
28+
*
29+
* Test 2. The function below this should have all pointers removed and be visible.
30+
* This function should be listed below the "Test" category.
31+
*/
32+
void* Test2(tMotor* motorPort, byte speed, bool* reversed);
33+
34+
/*
35+
* @test
36+
*
37+
* Test 2_2. The function should not be visible at all. There's wayy to many spaces.
38+
*/
39+
void* Test2_2 (tMotor* motorPort, byte speed, bool* reversed);
40+
41+
/*
42+
@sensor
43+
*
44+
* Test 3. Neither the attribute or the next line should work.
45+
* This function should be listed in "Main".
46+
This line should be ignored.
47+
*/
48+
bool test3;
49+
50+
/*
51+
* @sensor
52+
* @test
53+
* This should be under the "Test" category, as it's the most recent.
54+
*/
55+
void test4;
56+
57+
/*
58+
* @sensor @test
59+
* This should be under the "Sensor" category, as it's the leftmost attribute.
60+
* The variable below this should have its pointer removed.
61+
*/
62+
tMotor* test5;
63+
64+
65+
/*
66+
* This comment should not work.
67+
*/
68+
69+
bool test6Failed.
70+
71+
/*
72+
* @test7
73+
* This should be under the "Test7" category.
74+
* This line should still be visible.
75+
*/
76+
int* test7;
77+
78+
79+
task main() {
80+
81+
82+
83+
}
84+
85+
// Define the functions. This is required.
86+
87+
void Test1(tMotor motorPort, byte speed, bool reversed) {
88+
89+
}
90+
91+
void* Test2(tMotor* motorPort, byte speed, bool* reversed) {
92+
93+
}

RobotCDocs/setup.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
> Library Name
2-
Diego's Custom Library
2+
Unit Test
33

44
> Where to look for files
5-
C:\Users\smart\Desktop\RobotCLibrary
5+
Unit Test
66

77
> Where to output BuiltInVariables.txt
88
C:\Program Files (x86)\Robomatter Inc\ROBOTC Development Environment 4.X\Includes\

0 commit comments

Comments
 (0)