-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTest.cpp
41 lines (36 loc) · 1.15 KB
/
Test.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 "FormulaParser.hpp"
#include "Exceptions.hpp"
void test(std::string testName, std::string expr)
{
std::cout << testName << ": ";
try {
FormulaToStandardFormPolynomialParser::parse(expr);
}
catch (Exception& e) {
std::cout << e.what() << std::endl;
}
}
struct TestCase {
std::string testName;
std::string expr;
};
const static std::vector<TestCase> redTestCases = {
{"No left side", "= 1*X^1"},
{"No right side", "1*X^1 ="},
{"Two equality signs", "1*X^1 == 1*X^1"},
{"Minus sign before equality sign", "1*X^1 - = 1*X^1"},
{"Wrong monomial form - 0 at the left side", "0 = 1*X^1"},
{"Wrong monomial form - 0 at the right side", "1*X^1 = 0"},
{"No coefficient", "*X^1 = 1*X^1"},
{"Double mul sign", "1**X^1 = 1*X^1"},
{"Double X sign", "1*XX^1 = 1*X^1"},
{"Double ^ sign", "1*X^^1 = 1*X^1"},
{"Unknown symbol", "1*X$^1 = 1*X^1"},
};
int main()
{
std::for_each(redTestCases.begin(), redTestCases.end(),
[](const TestCase &testCase) { test(testCase.testName, testCase.expr); });
return 0;
}