-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
39 lines (34 loc) · 1.03 KB
/
main.cpp
File metadata and controls
39 lines (34 loc) · 1.03 KB
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
#include "library.h"
#include <iostream>
#include <string>
#include <sstream>
template <typename Func, typename... Args>
void run_test(const std::string& testname, int expected, Func func, Args... args)
{
const int actual = func(args...);
std::cout << testname << " ";
if (expected == actual) {
std::cout << "PASSED\n";
} else {
std::cout << "FAILED, expected " << expected << ", got " << actual << "\n";
}
}
void test1(const std::string& testname_prefix, int expected, int a, int b)
{
run_test(testname_prefix, expected, function1, a, b);
}
void test2(const std::string& testname_prefix, int expected, int a, int b, int c)
{
run_test(testname_prefix, expected, function2, a, b, c);
}
int main()
{
test1("Test 1", 3, 5, 2);
test1("Test 2", 1, 1, 2);
test2("Test 3", 4, -1, -2, 5);
test2("Test 4", -4, -1, 2, -3);
test2("Test 5", 4, 1, 2, 3);
test2("Test 6", -4, -1, 2, 2);
test2("Test 7", -4, 4, 4, 0);
test2("Test 8", 2, -2, -2, -3);
}