forked from IntelRealSense/librealsense
-
Notifications
You must be signed in to change notification settings - Fork 0
/
unit-tests-main.cpp
50 lines (44 loc) · 1.25 KB
/
unit-tests-main.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
42
43
44
45
46
47
48
49
50
#define CATCH_CONFIG_RUNNER
#include "unit-tests-common.h"
#include <iostream>
int main(int argc, char* const argv[])
{
command_line_params::instance(argc, argv);
std::vector<char*> new_argvs;
std::cout << "Running tests with the following parameters: ";
for (auto i = 0; i < argc; i++)
{
std::string param(argv[i]);
std::cout << param << " ";
}
std::cout << std::endl;
for (auto i = 0; i < argc; i++)
{
std::string param(argv[i]);
if (param != "into" && param != "from")
{
new_argvs.push_back(argv[i]);
}
else
{
i++;
if (i < argc && param == "from")
{
auto filename = argv[i];
std::ifstream f(filename);
if (!f.good())
{
std::cout << "Could not load " << filename << "!" << std::endl;
return EXIT_FAILURE;
}
}
}
}
auto result = Catch::Session().run(static_cast<int>(new_argvs.size()), new_argvs.data());
if(!command_line_params::instance()._found_any_section)
{
std::cout << "Didn't run any tests!\n";
return EXIT_FAILURE;
}
return result;
}