humotion / test / client.cpp @ 3d980d8f
History | View | Annotate | Download (1.613 KB)
| 1 | 8c6c1163 | Simon Schulz | // Bring in my package's API, which is what I'm testing
|
|---|---|---|---|
| 2 | #include "client.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 client_Test : public ::testing::Test { |
||
| 12 | protected:
|
||
| 13 | client_Test() {
|
||
| 14 | //set-up work for EACH test here
|
||
| 15 | s = new client();
|
||
| 16 | |||
| 17 | } |
||
| 18 | |||
| 19 | virtual ~client_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 | client *s; |
||
| 38 | }; |
||
| 39 | |||
| 40 | // Tests that the Foo::Bar() method does Abc.
|
||
| 41 | TEST_F(client_Test, send_mouth_data) {
|
||
| 42 | |||
| 43 | MouthState m; |
||
| 44 | for(int i=0; i<100; i++){ |
||
| 45 | m.opening_left = 12.0; |
||
| 46 | m.opening_center = 12.0; |
||
| 47 | m.opening_right = 12.0; |
||
| 48 | m.position_left = 10+(20.0*i)/100.0; |
||
| 49 | m.position_center = 10+(20.0*i)/100.0; |
||
| 50 | m.position_right = 10+(20.0*i)/100.0; |
||
| 51 | |||
| 52 | s->update_mouth_target(m, true);
|
||
| 53 | } |
||
| 54 | |||
| 55 | SUCCEED(); |
||
| 56 | } |
||
| 57 | |||
| 58 | // Tests that Foo does Xyz.
|
||
| 59 | // TEST_F(xsc3_client_cpp_Test, DoesXyz) {
|
||
| 60 | // CheckConnection(xsc3_client);
|
||
| 61 | // }
|
||
| 62 | |||
| 63 | } // namespace
|
||
| 64 | |||
| 65 | // Run all the tests that were declared with TEST()
|
||
| 66 | int main(int argc, char **argv){ |
||
| 67 | testing::InitGoogleTest(&argc, argv); |
||
| 68 | return RUN_ALL_TESTS();
|
||
| 69 | } |