-
Notifications
You must be signed in to change notification settings - Fork 35
Expand file tree
/
Copy pathmain.cpp
More file actions
72 lines (60 loc) · 1.2 KB
/
main.cpp
File metadata and controls
72 lines (60 loc) · 1.2 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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#include <vector>
#include <functional>
#include <iostream>
#include "tests.h"
//массив всех тестов, который мы заполняем в функции initTests
static std::vector<std::function<bool()>> tests;
//тест 1
bool test1()
{
//пример какого-то теста
return 42 == (41 + 1); //passed
}
//тест 2
bool test2()
{
//пример какого-то теста
return 42 != (41 + 1); //failed
}
//тест 3
bool test3()
{
Candle candle{ 0.0, 3.0, 3.0, 3.0 };
//пример какого-то теста
return candle.high == 3.0;
}
void initTests()
{
tests.push_back(test1);
tests.push_back(test2);
tests.push_back(test3);
//tests.push_back(test4);
//tests.push_back(test5);
}
int launchTests()
{
int total = 0;
int passed = 0;
for (const auto& test : tests)
{
std::cout << "test #" << (total + 1);
if (test())
{
passed += 1;
std::cout << " passed\n";
}
else
{
std::cout << " failed\n";
}
total += 1;
}
std::cout << "\ntests " << passed << "/" << total << " passed!" << std::endl;
//0 = success
return total - passed;
}
int main()
{
initTests();
return launchTests();
}