forked from DigitalDynamicsLab/fmu_tools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_parseFmuChecker.cpp
41 lines (36 loc) · 1.21 KB
/
test_parseFmuChecker.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#include <iostream>
#include <fstream>
#include <regex>
#include <string>
int main() {
std::cout << "Opening fmuChecker log: " << FMUCHECKER_LOG << std::endl;
std::cout << "-> status: ";
std::ifstream file(FMUCHECKER_LOG);
if (!file.is_open()) {
std::cerr << "ERROR" << std::endl;
return 1;
}
std::cout << " SUCCESS" << std::endl;
std::regex errorRegex(R"(\[ERROR\](.*))");
std::regex warningRegex(R"(\[WARNING\](.*))");
std::string line;
std::cout << "Parsing fmuChecker log..." << std::endl;
unsigned int errorCount = 0;
unsigned int warningCount = 0;
while (std::getline(file, line)) {
std::smatch match;
if (std::regex_search(line, match, errorRegex)) {
std::cout << "ERROR: " << match[1] << std::endl;
errorCount++;
}
else if (std::regex_search(line, match, warningRegex)) {
std::cout << "WARNING: " << match[1] << std::endl;
warningCount++;
}
}
file.close();
std::cout << "Parsing completed with:" << std::endl;
std::cout << "- errors: " << errorCount << std::endl;
std::cout << "- warnings: " << warningCount << std::endl;
return errorCount>0;
}