-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.cpp
More file actions
75 lines (68 loc) · 1.98 KB
/
test.cpp
File metadata and controls
75 lines (68 loc) · 1.98 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
73
74
75
#include <iostream>
#ifdef _WIN32
#include <fxc/fxc>
#endif
#include <npl/npl>
#include <cvl/cvl>
#include <osl/lcs>
#include "gtest/gtest.h"
int main(int argc, char *argv[]) {
testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
//todo: merge everything below in gtest
auto arguments = osl::GetArgumentsVector<char>(argc, argv);
osl::log::setLogLevel(osl::log::info);
osl::log::setLogSink<std::string>(
[](int level, int key, auto log) {
std::cout << log << std::endl;
});
osl::log::setLogSink<std::wstring>(
[](int level, int key, auto log) {
std::wcout << log << std::endl;
});
npl::initialize_dispatcher();
auto ns = arguments[0];
#ifdef _WIN32
if (ns == "fxc") {
fxc::entry(arguments);
} else
#endif
if (ns == "npl") {
npl::entry(arguments);
} else if (ns == "cvl") {
cvl::entry(arguments);
} else if (ns == "osl") {
osl::lcs_tests();
} else {
std::cout << "test npl ftp <host> <port> <user> <pass>" << std::endl;
}
return 0;
}
#if defined(ENABLE_GTEST)
struct DispatcherFixture : public testing::Test {
protected:
std::shared_ptr<npl::dispatcher> d;
void SetUp() override {
#ifdef _WIN32
WSADATA wsaData;
auto rc = WSAStartup(MAKEWORD(2, 2), &wsaData);
ASSERT_EQ(0, rc);
#endif
// dispatcher needs to be a shared pointer
// for the subsequent weak_from_this to work
d = singleton<npl::dispatcher>::getInstance();
d->initialize_control();
}
void TearDown() override {
singleton<npl::dispatcher>::destroy();
#ifdef _WIN32
auto rc = WSACleanup();
ASSERT_EQ(0, rc);
#endif
}
};
TEST_F(DispatcherFixture, Construction) {
while (!d->has_control_initialized()) {}
ASSERT_EQ(d->has_control_initialized(), true);
}
#endif