humotion / test / server.cpp @ bfe17564
History | View | Annotate | Download (1.894 KB)
1 |
// Bring in my package's API, which is what I'm testing
|
---|---|
2 |
#include "humotion/server/server.h" |
3 |
#include <gtest/gtest.h> |
4 |
#include <string> |
5 |
#include <cstdio> |
6 |
using namespace std; |
7 |
using namespace humotion; |
8 |
using namespace humotion::server; |
9 |
|
10 |
namespace {
|
11 |
|
12 |
//the fixture for testing class Foo.
|
13 |
class server_Test : public ::testing::Test { |
14 |
protected:
|
15 |
server_Test() { |
16 |
//set-up work for EACH test here
|
17 |
s = new Server("test", "ROS", NULL); |
18 |
|
19 |
} |
20 |
|
21 |
virtual ~server_Test() {
|
22 |
//clean-up work that doesn't throw exceptions here
|
23 |
delete(s);
|
24 |
s = NULL;
|
25 |
} |
26 |
|
27 |
//if the constructor and destructor are not enough for setting up
|
28 |
//and cleaning up each test, you can define the following methods:
|
29 |
virtual void SetUp() { |
30 |
//code here will be called immediately after the constructor (right before each test).
|
31 |
} |
32 |
|
33 |
virtual void TearDown() { |
34 |
//code here will be called immediately after each test (right
|
35 |
//before the destructor).
|
36 |
} |
37 |
|
38 |
//ojects declared here can be used by all tests in the test case for Foo
|
39 |
Server *s; |
40 |
}; |
41 |
|
42 |
void dump_incoming_data(Server *s){
|
43 |
SCOPED_TRACE("dump incoming data");
|
44 |
|
45 |
//make sure it is not null
|
46 |
if (s == NULL){ |
47 |
SCOPED_TRACE("server ptr NULL?");
|
48 |
FAIL(); |
49 |
} |
50 |
|
51 |
//make sure we are connected
|
52 |
EXPECT_EQ(s->ok(), true);
|
53 |
|
54 |
for(int i=0; i<100000; i++){ |
55 |
//s->tick();
|
56 |
} |
57 |
} |
58 |
|
59 |
|
60 |
// Tests that the Foo::Bar() method does Abc.
|
61 |
TEST_F(server_Test, dump_incoming_data) { |
62 |
//connected?
|
63 |
dump_incoming_data(s); |
64 |
// const string input_filepath = "this/package/testdata/myinputfile.dat";
|
65 |
// const string output_filepath = "this/package/testdata/myoutputfile.dat";
|
66 |
// Foo f;
|
67 |
// EXPECT_EQ(0, f.Bar(input_filepath, output_filepath));
|
68 |
} |
69 |
|
70 |
// Tests that Foo does Xyz.
|
71 |
// TEST_F(xsc3_client_cpp_Test, DoesXyz) {
|
72 |
// CheckConnection(xsc3_client);
|
73 |
// }
|
74 |
|
75 |
} // namespace
|
76 |
|
77 |
// Run all the tests that were declared with TEST()
|
78 |
int main(int argc, char **argv){ |
79 |
testing::InitGoogleTest(&argc, argv); |
80 |
return RUN_ALL_TESTS();
|
81 |
} |