Fixed up testing etc
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -4,3 +4,4 @@ build
|
|||||||
stats
|
stats
|
||||||
*.swp
|
*.swp
|
||||||
*.png
|
*.png
|
||||||
|
*krakout*
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ int findPerenEnd(std::string str, int i);
|
|||||||
std::vector<std::string> split(const std::string &str, char delim);
|
std::vector<std::string> split(const std::string &str, char delim);
|
||||||
std::string join(const std::vector<std::string> &strVec, std::string joinStr);
|
std::string join(const std::vector<std::string> &strVec, std::string joinStr);
|
||||||
std::string readFile(std::istream &file);
|
std::string readFile(std::istream &file);
|
||||||
|
std::string padWithSpaces(std::string str, int padTo);
|
||||||
|
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
|
|||||||
10
main.cpp
10
main.cpp
@@ -40,12 +40,18 @@ int main(int argc, char* argv[]) {
|
|||||||
std::string testResults, line;
|
std::string testResults, line;
|
||||||
int passed = 0, failed = 0;
|
int passed = 0, failed = 0;
|
||||||
Tester test(argv[0], "../krakenGrammer.kgm");
|
Tester test(argv[0], "../krakenGrammer.kgm");
|
||||||
|
// find the max length so we can pad the string and align the results
|
||||||
|
unsigned int maxLineLength = 0;
|
||||||
|
for (int i = 2; i < argc; i++) {
|
||||||
|
int strLen = std::string(argv[i]).length();
|
||||||
|
maxLineLength = maxLineLength < strLen ? strLen : maxLineLength;
|
||||||
|
}
|
||||||
for (int i = 2; i < argc; i++) {
|
for (int i = 2; i < argc; i++) {
|
||||||
bool result = test.run(argv[i]);
|
bool result = test.run(argv[i]);
|
||||||
if (result)
|
if (result)
|
||||||
line = std::string(argv[i]) + "\t\tpassed!\n", passed++;
|
line = padWithSpaces(std::string(argv[i]), maxLineLength) + "\t\tpassed!\n", passed++;
|
||||||
else
|
else
|
||||||
line = std::string(argv[i]) + "\t\tFAILED!\n", failed++;
|
line = padWithSpaces(std::string(argv[i]), maxLineLength) + "\t\tFAILED!!!!\n", failed++;
|
||||||
std::cout << line << std::endl;
|
std::cout << line << std::endl;
|
||||||
testResults += line;
|
testResults += line;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -61,8 +61,5 @@ bool Tester::compareFiles(std::string file1Path, std::string file2Path) {
|
|||||||
std::string file1contents = readFile(file1);
|
std::string file1contents = readFile(file1);
|
||||||
std::string file2contents = readFile(file2);
|
std::string file2contents = readFile(file2);
|
||||||
|
|
||||||
// std::cout << "file1: " << file1contents << std::endl;
|
|
||||||
// std::cout << "file2: " << file2contents << std::endl;
|
|
||||||
// std::cout << "comp: " << file1contents.compare(file2contents) << std::endl;
|
|
||||||
return file1contents.compare(file2contents) == 0;
|
return file1contents.compare(file2contents) == 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -80,4 +80,9 @@ std::string readFile(std::istream &file) {
|
|||||||
return contents;
|
return contents;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string padWithSpaces(std::string str, int padTo) {
|
||||||
|
while(str.length() < padTo)
|
||||||
|
str += " ";
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ testDir="."
|
|||||||
ext=${2:-"krak"}
|
ext=${2:-"krak"}
|
||||||
|
|
||||||
fileList=""
|
fileList=""
|
||||||
for dir in `find ${testDir} -type f -name "*.${ext}"`; do
|
for dir in `find ${testDir} -type f -name "test_*.${ext}"`; do
|
||||||
filename=$(basename ${dir})
|
filename=$(basename ${dir})
|
||||||
filename="${filename%.*}"
|
filename="${filename%.*}"
|
||||||
fileList+=\ $testDir\/$filename
|
fileList+=\ $testDir\/$filename
|
||||||
|
|||||||
Reference in New Issue
Block a user