GCC Code Coverage Report | |||||||||||||||||||||
|
|||||||||||||||||||||
Line | Branch | Exec | Source |
1 |
// Copyright 2010 Thomas Moulard. |
||
2 |
// |
||
3 |
|||
4 |
#include <dynamic-graph/entity.h> |
||
5 |
#include <dynamic-graph/exception-factory.h> |
||
6 |
#include <dynamic-graph/factory.h> |
||
7 |
#include <dynamic-graph/pool.h> |
||
8 |
|||
9 |
#include <sstream> |
||
10 |
|||
11 |
#define BOOST_TEST_MODULE customEntity |
||
12 |
|||
13 |
#if BOOST_VERSION >= 105900 |
||
14 |
#include <boost/test/tools/output_test_stream.hpp> |
||
15 |
#else |
||
16 |
#include <boost/test/output_test_stream.hpp> |
||
17 |
#endif |
||
18 |
#include <boost/test/unit_test.hpp> |
||
19 |
|||
20 |
using boost::test_tools::output_test_stream; |
||
21 |
|||
22 |
struct CustomEntity : public dynamicgraph::Entity { |
||
23 |
static const std::string CLASS_NAME; |
||
24 |
|||
25 |
1 |
virtual const std::string &getClassName() const { return CLASS_NAME; } |
|
26 |
|||
27 |
2 |
explicit CustomEntity(const std::string &n) : Entity(n) {} |
|
28 |
|||
29 |
8 |
virtual ~CustomEntity() {} |
|
30 |
|||
31 |
1 |
void display(std::ostream &os) const { os << "custom entity"; } |
|
32 |
}; |
||
33 |
|||
34 |
✓✗ | 2 |
DYNAMICGRAPH_FACTORY_ENTITY_PLUGIN(CustomEntity, "CustomEntity"); |
35 |
|||
36 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗ |
4 |
BOOST_AUTO_TEST_CASE(constructor) { |
37 |
✓✗✓✗ ✓✗✗✓ |
2 |
BOOST_CHECK_EQUAL(CustomEntity::CLASS_NAME, "CustomEntity"); |
38 |
|||
39 |
dynamicgraph::Entity *entity = |
||
40 |
✓✗✓✗ ✓✗ |
2 |
dynamicgraph::FactoryStorage::getInstance()->newEntity("CustomEntity", |
41 |
"my-entity"); |
||
42 |
✓✗✓✗ ✓✗✗✓ |
2 |
BOOST_CHECK_EQUAL(entity->getName(), "my-entity"); |
43 |
✓✗✓✗ ✓✗✗✓ |
2 |
BOOST_CHECK_EQUAL(entity->Entity::getClassName(), "Entity"); |
44 |
✓✗✓✗ ✓✗✗✓ |
2 |
BOOST_CHECK_EQUAL(entity->getClassName(), CustomEntity::CLASS_NAME); |
45 |
|||
46 |
// CustomEntity entity2 (""); |
||
47 |
// Deregister entities before destroying them |
||
48 |
2 |
dynamicgraph::PoolStorage::destroy(); |
|
49 |
2 |
} |
|
50 |
|||
51 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗ |
4 |
BOOST_AUTO_TEST_CASE(display) { |
52 |
dynamicgraph::Entity *entity = |
||
53 |
✓✗✓✗ ✓✗✓✗ |
2 |
dynamicgraph::FactoryStorage::getInstance()->newEntity("CustomEntity", |
54 |
"my-entity"); |
||
55 |
|||
56 |
✓✗✓✗ |
4 |
output_test_stream output; |
57 |
|||
58 |
✓✗ | 2 |
entity->display(output); |
59 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✓ |
2 |
BOOST_CHECK(output.is_equal("custom entity")); |
60 |
// Deregister entities before destroying them |
||
61 |
✓✗ | 2 |
dynamicgraph::PoolStorage::destroy(); |
62 |
2 |
} |
Generated by: GCOVR (Version 4.2) |