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