icub-test
ExampleTest.cpp
1 /*
2  * iCub Robot Unit Tests (Robot Testing Framework)
3  *
4  * Copyright (C) 2015-2019 Istituto Italiano di Tecnologia (IIT)
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19  */
20 
21 #include "ExampleTest.h"
22 #include <robottestingframework/dll/Plugin.h>
23 #include <robottestingframework/TestAssert.h>
24 
25 using namespace std;
26 using namespace robottestingframework;
27 using namespace yarp::os;
28 
29 // prepare the plugin
30 ROBOTTESTINGFRAMEWORK_PREPARE_PLUGIN(ExampleTest)
31 
32 ExampleTest::ExampleTest() : yarp::robottestingframework::TestCase("ExampleTest") {
33 }
34 
35 ExampleTest::~ExampleTest() { }
36 
37 bool ExampleTest::setup(yarp::os::Property &property) {
38 
39  // initialization goes here ...
40  //updating the test name
41  if(property.check("name"))
42  setName(property.find("name").asString());
43 
44  string example = property.check("example", Value("default value")).asString();
45 
46  ROBOTTESTINGFRAMEWORK_TEST_REPORT(Asserter::format("Use '%s' for the example param!",
47  example.c_str()));
48  return true;
49 }
50 
51 void ExampleTest::tearDown() {
52  // finalization goes her ...
53 }
54 
55 void ExampleTest::run() {
56 
57  int a = 5; int b = 3;
58  ROBOTTESTINGFRAMEWORK_TEST_CHECK(a<b, "a smaller then b");
59  ROBOTTESTINGFRAMEWORK_TEST_CHECK(a>b, "a bigger then b");
60  ROBOTTESTINGFRAMEWORK_TEST_CHECK(a==b, "a equal to b");
61 
62  // add more
63  // ...
64 }
65 
This is just an example test, use it as a reference to implement new tests.
Definition: ExampleTest.h:41