-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathdev_test.cpp
83 lines (62 loc) · 2.38 KB
/
dev_test.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
/***************************************************************************
tag: Peter Soetens Mon Jan 10 15:59:51 CET 2005 dev_test.cpp
dev_test.cpp - description
-------------------
begin : Mon January 10 2005
copyright : (C) 2005 Peter Soetens
email : [email protected]
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#include "unit.hpp"
#include "dev_test.hpp"
#include "FakeAnalogDevice.hpp"
#include "FakeDigitalDevice.hpp"
#include <extras/dev/AnalogInput.hpp>
#include <extras/dev/AnalogOutput.hpp>
#include <extras/dev/DigitalInput.hpp>
#include <extras/dev/DigitalOutput.hpp>
#include <iostream>
using namespace std;
using namespace RTT;
void
DevTest::setUp()
{
}
void
DevTest::tearDown()
{
}
BOOST_FIXTURE_TEST_SUITE( DevTestSuite, DevTest )
BOOST_AUTO_TEST_CASE( testClasses)
{
DigitalInput din(true, false); // init, invert
DigitalOutput dout(false); // init.
AnalogInput ain(0,0);
AnalogOutput aout(0,0);
BOOST_CHECK( din.isOn() );
BOOST_CHECK( dout.isOn() == false);
dout.setBit(true);
BOOST_CHECK( dout.isOn() == true);
dout.setBit(false);
BOOST_CHECK( dout.isOn() == false);
}
BOOST_AUTO_TEST_CASE( testNaming)
{
FakeAnalogDevice fad;
FakeDigitalDevice fdd;
AnalogInInterface* aii = AnalogInInterface::nameserver.getObject("FakeAnalogDevice");
AnalogOutInterface* aoi = AnalogOutInterface::nameserver.getObject("FakeAnalogDevice");
DigitalInInterface* dii = DigitalInInterface::nameserver.getObject("FakeDigitalDevice");
DigitalOutInterface* doi = DigitalOutInterface::nameserver.getObject("FakeDigitalDevice");
BOOST_CHECK( aii );
BOOST_CHECK( aoi );
BOOST_CHECK( dii );
BOOST_CHECK( doi );
}
BOOST_AUTO_TEST_SUITE_END()