Statistics
| Branch: | Tag: | Revision:

humotion / test / server.cpp @ 82c7616e

History | View | Annotate | Download (1.787 KB)

1
// Bring in my package's API, which is what I'm testing
2
#include "server.h"
3
#include <gtest/gtest.h>
4
#include <string>
5
#include <cstdio>
6
using namespace std;
7

    
8
namespace {
9

    
10
//the fixture for testing class Foo.
11
class server_Test : public ::testing::Test {
12
protected:
13
        server_Test() {
14
                //set-up work for EACH test here
15
                s = new Server();
16

    
17
        }
18
        
19
        virtual ~server_Test() {
20
                //clean-up work that doesn't throw exceptions here
21
                delete(s);
22
                s = NULL;
23
        }
24
        
25
        //if the constructor and destructor are not enough for setting up
26
        //and cleaning up each test, you can define the following methods:
27
        virtual void SetUp() {
28
                //code here will be called immediately after the constructor (right before each test).
29
        }
30

    
31
        virtual void TearDown() {
32
                //code here will be called immediately after each test (right
33
                //before the destructor).
34
        }
35

    
36
        //ojects declared here can be used by all tests in the test case for Foo
37
        Server *s;
38
};
39

    
40
void dump_incoming_data(Server *s){
41
        SCOPED_TRACE("dump incoming data");
42
        
43
        //make sure it is not null
44
        if (s == NULL){
45
                SCOPED_TRACE("server ptr NULL?");
46
                FAIL();
47
        }
48
        
49
        //make sure we are connected
50
        EXPECT_EQ(s->ok(), true);
51
        
52
        for(int i=0; i<100000; i++){
53
                s->tick();
54
        }
55
}
56

    
57

    
58
// Tests that the Foo::Bar() method does Abc.
59
TEST_F(server_Test, dump_incoming_data) {
60
        //connected?
61
        dump_incoming_data(s);
62
//   const string input_filepath = "this/package/testdata/myinputfile.dat";
63
//   const string output_filepath = "this/package/testdata/myoutputfile.dat";
64
//   Foo f;
65
//   EXPECT_EQ(0, f.Bar(input_filepath, output_filepath));
66
}
67

    
68
// Tests that Foo does Xyz.
69
// TEST_F(xsc3_client_cpp_Test, DoesXyz) {
70
//         CheckConnection(xsc3_client);
71
// }
72

    
73
}  // namespace
74

    
75
// Run all the tests that were declared with TEST()
76
int main(int argc, char **argv){
77
        testing::InitGoogleTest(&argc, argv);
78
        return RUN_ALL_TESTS();
79
}