-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.cpp
More file actions
40 lines (33 loc) · 898 Bytes
/
test.cpp
File metadata and controls
40 lines (33 loc) · 898 Bytes
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
#include "test.hpp"
int f(int a, int b){
return a + b;
}
bool gt5(int a){
return a > 5;
}
test::TestSuite<f> f_tests(){
test::TestSuite<f> tests("f tests");
tests.addTest({{3, 3}, gt5});
tests.addComparativeTest({{2, 2}, 4});
//tests.addComparativeTest({{2, 2}, 5});
return tests;
}
double g(double a, double b, double c){
return a * b / c;
}
bool custom_comparison(double a, double b){
return abs(a - b) < 1e-6;
}
test::TestSuite<g> g_tests(){
test::TestSuite<g> tests("g tests");
tests.addComparativeTest({{1.0, 2.0, 3.0}, 0.66666667, custom_comparison});
tests.addComparativeTest({{1.0, 2.0, 3.0}, 0.66666667, test::epsilon_comparison(1e-6)});
return tests;
}
int main(){
FunctionTraits<decltype(f)>::ReturnType a;
auto f_test_suite = f_tests();
f_test_suite.run();
auto g_test_suite = g_tests();
g_test_suite.run();
}