[Positioner] tests: review and update (100% pass)

Review and fix all the tests so that 100% of the tests pass.
This commit is contained in:
Matteo Cypriani 2013-06-22 17:10:38 -04:00 committed by Matteo Cypriani
parent 13f8847f65
commit 1eac9bb718
27 changed files with 368 additions and 196 deletions

View File

@ -222,3 +222,11 @@ add_custom_target(semistatic DEPENDS ${OWLPS_SEMISTATIC_TARGETS})
# The OWLPS_STATIC_TARGET is defined in subdirectories
add_custom_target(static DEPENDS ${OWLPS_STATIC_TARGETS})
### Tests ###
add_custom_target(test
COMMAND ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/test_positioner
DEPENDS test_positioner)

View File

@ -132,6 +132,15 @@ To display all the available targets, type:
``` make help
= Running the tests =
To run the unit tests, use the ``test`` target:
``` make test
Currently, only OwlPS Positioner has unit tests.
= Compiling for OpenWrt =
== The OpenWrt toolchain ==

View File

@ -183,8 +183,6 @@ Work to do in OwlPS
- With autocalibration on, all the CPs declared in listeners.csv must
be in coverage or the reference points will not be generated.
- Unit tests are currently unmaintained. Do not try to run them.
== Algorithms ==
@ -295,16 +293,44 @@ Work to do in OwlPS
== Unit tests ==
- Update (rewrite?) tests.
- Classes with incomplete tests:
- InterlinkNetworks: compute()
- Measurement: average, variance, standard deviation, operations
- MinMax: trilaterate_2d()
- OutputCSV: write(ResultList)
- Point3D: distance & angle operations
- PosUtil: most functions
- ReferencePoint: operations
- Stock: a lot of functions
- Unfinished tests:
- InputDataReader
- Classes without tests or with mock test files (possibly untestable or
not worth testing, to be checked):
- Autocalibration
- CapturePointsReaderCSV
- CartographyAlgorithm
- CSVStringReader
- FBCM
- FRBHMBasic
- Input
- InputDataReader
- InputLogMedium
- InputMedium
- InputUDPSocket
- MobilesReaderCSV
- NSS
- Output
- OutputMedium
- OutputNetworkSocket
- OutputTCPSocketEvAAL
- OutputUDPSocket
- Positioning
- PositioningAlgorithm
- ResultList
- TrilaterationAlgorithm
- TrilaterationMethod
- Test InterlinkNetworks::compute() ?
- Timestamp: there is a probability of 10^-6 that the value in
nanoseconds and the rounded value in milliseconds are identical, in
which case some tests can fail.
which case one of the tests can fail. This could be fixed by retrying
the same test a couple of times.

View File

@ -161,7 +161,6 @@ set(TESTS_SRC_FILES
${TESTS_DIR}/textfilewriter_test.hh
${TESTS_DIR}/timestamp_test.hh
${TESTS_DIR}/topologyreadercsv_test.hh
${TESTS_DIR}/userinterface_test.hh
${TESTS_DIR}/waypoint_test.hh
${TESTS_DIR}/wifidevice_test.hh
)

View File

@ -8,11 +8,9 @@ public:
void test_constructors(void)
{
// Default constructor
CalibrationRequest calibrationrequest00 ;
std::vector<int> vi1 ;
CalibrationRequest calibrationrequest01(Request(), NULL) ;
TS_ASSERT_EQUALS(calibrationrequest00, calibrationrequest01) ;
// We can't test the default constructor with two different objects
// like we usually do because the reception time is initialised by
// the Request constructor.
// Copy constructor
Mobile mobile1 ;
@ -25,7 +23,14 @@ public:
TS_ASSERT_EQUALS(calibrationrequest1, calibrationrequest2) ;
// Request copy constructor
CalibrationRequest calibrationrequest3(request1) ;
/* We must force the request type to be the same in the Request and
* in the CalibrationRequest, because by default it is set to
* OWL_REQUEST_UNDEFINED for the Request and to
* OWL_REQUEST_AUTOCALIBRATION for the CalibrationRequest. */
request1.set_type(OWL_REQUEST_CALIBRATION) ;
CalibrationRequest
calibrationrequest3(request1, &referencepoint1, Direction(1),
OWL_REQUEST_CALIBRATION) ;
TS_ASSERT_EQUALS(request1, calibrationrequest3) ;
}
@ -40,10 +45,13 @@ public:
Timestamp timestamp1 ;
timestamp1.now() ;
Request request1(&mobile1, timestamp1) ;
Direction direction1(1) ;
ReferencePoint referencepoint1(1,2,3) ;
CalibrationRequest calibrationrequest1(request1, &referencepoint1) ;
CalibrationRequest
calibrationrequest1(request1, &referencepoint1, direction1) ;
TS_ASSERT_EQUALS(calibrationrequest1.get_mobile(), &mobile1) ;
TS_ASSERT_EQUALS(calibrationrequest1.get_time_sent(), timestamp1) ;
TS_ASSERT_EQUALS(calibrationrequest1.get_direction(), direction1) ;
TS_ASSERT_EQUALS(calibrationrequest1.get_reference_point(),
&referencepoint1) ;
@ -56,6 +64,10 @@ public:
calibrationrequest1.set_time_sent(timestamp1) ;
TS_ASSERT_EQUALS(calibrationrequest1.get_time_sent(), timestamp1) ;
Direction direction2(2) ;
calibrationrequest1.set_direction(direction2) ;
TS_ASSERT_EQUALS(calibrationrequest1.get_direction(), direction2) ;
ReferencePoint referencepoint2(4,3,2) ;
calibrationrequest1.set_reference_point(&referencepoint2) ;
TS_ASSERT_EQUALS(calibrationrequest1.get_reference_point(),
@ -63,6 +75,7 @@ public:
calibrationrequest1.clear() ;
CalibrationRequest calibrationrequest2 ;
calibrationrequest2.clear() ;
TS_ASSERT_EQUALS(calibrationrequest1, calibrationrequest2) ;
}
@ -74,16 +87,37 @@ public:
Timestamp timestamp1 ;
timestamp1.now() ;
Request request1(&mobile1, timestamp1) ;
Direction direction1(1) ;
ReferencePoint referencepoint1 ;
CalibrationRequest calibrationrequest1(request1, &referencepoint1) ;
CalibrationRequest calibrationrequest2(request1, &referencepoint1) ;
CalibrationRequest
calibrationrequest1(request1, &referencepoint1,
direction1, OWL_REQUEST_CALIBRATION) ;
CalibrationRequest
calibrationrequest2(request1, &referencepoint1,
direction1, OWL_REQUEST_CALIBRATION) ;
TS_ASSERT_EQUALS(calibrationrequest1, calibrationrequest2) ;
// != and ==
Direction direction2(2) ;
calibrationrequest2.set_direction(direction2) ;
TS_ASSERT(calibrationrequest1 != calibrationrequest2) ;
calibrationrequest2.set_direction(direction1) ;
TS_ASSERT_EQUALS(calibrationrequest1, calibrationrequest2) ;
calibrationrequest2.set_type(OWL_REQUEST_AUTOCALIBRATION) ;
TS_ASSERT(calibrationrequest1 != calibrationrequest2) ;
calibrationrequest2.set_type(OWL_REQUEST_CALIBRATION) ;
TS_ASSERT_EQUALS(calibrationrequest1, calibrationrequest2) ;
// !=
timestamp1.now() ;
Request request2(&mobile1, timestamp1) ;
ReferencePoint referencepoint2 ;
CalibrationRequest calibrationrequest3(request2, &referencepoint2) ;
Direction direction3(3) ;
CalibrationRequest
calibrationrequest3(request2, &referencepoint2,
direction3, OWL_REQUEST_AUTOCALIBRATION) ;
TS_ASSERT(calibrationrequest1 != calibrationrequest3) ;
// =

View File

@ -11,11 +11,13 @@ public:
// Default constructor
CapturePoint capturepoint1 ;
CapturePoint capturepoint2(Point3D(), "", "",
CP_DEFAULT_ANTENNA_GAIN,
WIFIDEVICE_DEFAULT_TRX_POWER,
CP_DEFAULT_CHANNEL) ;
CP_DEFAULT_ANTENNA_GAIN,
WIFIDEVICE_DEFAULT_TRX_POWER,
CP_DEFAULT_CHANNEL) ;
TS_ASSERT_EQUALS(capturepoint1, capturepoint2) ;
// TODO: WifiDevice copy constructors
// Copy constructor
CapturePoint capturepoint3(Point3D(4,3,5), "192.168.0.1",
"AA:BB:CC:DD:EE:FF", 5, 32, 11) ;
@ -29,7 +31,7 @@ public:
// Simple read accessors
Point3D point3d1(78,23,4) ;
CapturePoint capturepoint1(point3d1, "192.168.0.1",
"AA:BB:CC:DD:EE:FF", 6, 38, 10) ;
"AA:BB:CC:DD:EE:FF", 6, 38, 10) ;
TS_ASSERT_EQUALS(capturepoint1.get_coordinates(), point3d1) ;
TS_ASSERT_EQUALS(capturepoint1.get_ip_addr(), "192.168.0.1") ;
TS_ASSERT_EQUALS(capturepoint1.get_mac_addr(), "AA:BB:CC:DD:EE:FF") ;
@ -63,15 +65,15 @@ public:
// ==
Point3D point3d1(78,23,4) ;
CapturePoint capturepoint1(point3d1, "192.168.0.1",
"AA:BB:CC:DD:EE:FF", 6, 38, 10) ;
"AA:BB:CC:DD:EE:FF", 6, 38, 10) ;
CapturePoint capturepoint2(point3d1, "192.168.0.1",
"AA:BB:CC:DD:EE:FF", 6, 38, 10) ;
"AA:BB:CC:DD:EE:FF", 6, 38, 10) ;
TS_ASSERT_EQUALS(capturepoint1, capturepoint2) ;
// !=
Point3D point3d2(7,3,24) ;
CapturePoint capturepoint3(point3d1, "10.0.0.1",
"AA:BB:CC:DD:EE:FF", 6, 38, 10) ;
"AA:BB:CC:DD:EE:FF", 6, 38, 10) ;
TS_ASSERT(capturepoint2 != capturepoint3) ;
// =

View File

@ -85,7 +85,11 @@ public:
std::ofstream output_file(test_file_name.c_str()) ;
assert(output_file) ;
for (unsigned int i = 0 ; i < nlines ; ++i)
output_file << "aa:bb:cc:dd:ee:ff;1265120910725;0;0;0;0;11:22:33:44:55:01;-58;11:22:33:44:55:03;-50;11:22:33:44:55:02;-42;11:22:33:44:55:01;-55;11:22:33:44:55:02;-37\n" ;
output_file
<< "aa:bb:cc:dd:ee:ff;1265120910725;0;0;0;0;"
<< "11:22:33:44:55:01;-58;11:22:33:44:55:03;-50;"
<< "11:22:33:44:55:02;-42;11:22:33:44:55:01;-55;"
<< "11:22:33:44:55:02;-37\n" ;
output_file.close() ;
CSVFileReader *csvfilereader ;

View File

@ -11,11 +11,10 @@ public:
{
// Default constructor
TS_ASSERT_THROWS_NOTHING(Direction()) ;
Direction direction0 ;
TS_ASSERT(! direction0) ;
// char constructor
TS_ASSERT_THROWS(Direction(0), bad_direction) ;
// int constructor
// 0 is accepted, although it doesn't create a valid Direction
TS_ASSERT_THROWS_NOTHING(Direction(0)) ;
TS_ASSERT_THROWS(Direction(5), bad_direction) ;
TS_ASSERT_THROWS_NOTHING(Direction(north)) ;
@ -43,6 +42,7 @@ public:
void test_operators(void)
{
Direction direction0 ;
Direction direction1(Direction::north) ;
Direction direction2(Direction::east) ;
Direction direction3(Direction::south) ;
@ -61,6 +61,7 @@ public:
TS_ASSERT(direction5 != direction6) ;
// bool
TS_ASSERT(! direction0) ;
TS_ASSERT(direction1) ;
TS_ASSERT(direction2) ;
TS_ASSERT(direction3) ;

View File

@ -20,9 +20,6 @@ public:
// If we cannot open the file, we want to stop the test
CxxTest::setAbortTestOnFail(true) ;
// Clear the stock
Stock::clear() ;
csv_file_name = "/tmp/InputCSV_test_csv_file.csv" ;
TestUtil::create_test_csv_file(csv_file_name, true) ;
@ -35,9 +32,6 @@ public:
{
// Delete the test CSV file
TestUtil::remove_file(csv_file_name) ;
// Clear the stock
Stock::clear() ;
}
@ -66,27 +60,22 @@ public:
request1 = inputcsv1.get_next_request() ;
TS_ASSERT(request1) ;
/*
assert(request1.get_mobile()) ;
TS_ASSERT_EQUALS(request1.get_mobile()->get_mac_addr(),
TestUtil::mobiles[0].get_mac_addr()) ;
TS_ASSERT_EQUALS(request1.get_time_sent(),
TestUtil::requests.at(0)->get_time_sent()) ;
for (std::vector<CapturePoint>::const_iterator i = TestUtil::aps.begin() ;
i != TestUtil::aps.end() ; ++i)
for (auto i = TestUtil::aps.begin() ; i != TestUtil::aps.end() ; ++i)
{
std::unordered_map<std::string, Measurement>::const_iterator
measurement_it1 =
request1.get_measurements().find(i->get_mac_addr()) ;
TS_ASSERT(request1.get_measurements().end() != measurement_it1) ;
// TS_ASSERT_EQUALS(TestUtil::requests.at(0)->get_measurements().
// at(i->get_mac_addr()).get_ss_list(),
// measurement_it1->second.get_ss_list()) ;
// We cannot compare the complete ss_list since there is not a
// Measurement::get_ss_list() any more.
}
*/
TS_ASSERT(inputcsv1) ;
TS_ASSERT(! inputcsv1.eof()) ;
@ -95,31 +84,24 @@ public:
request1 = inputcsv1.get_next_request() ;
TS_ASSERT(request1) ;
/*
assert(request1.get_mobile()) ;
TS_ASSERT_EQUALS(request1.get_mobile()->get_mac_addr(),
TestUtil::mobiles[1].get_mac_addr()) ;
TS_ASSERT_EQUALS(request1.get_time_sent(),
TestUtil::requests.at(1)->get_time_sent()) ;
for (std::vector<CapturePoint>::const_iterator i = TestUtil::aps.begin() ;
i != TestUtil::aps.end() ; ++i)
for (auto i = TestUtil::aps.begin() ; i != TestUtil::aps.end() ; ++i)
{
std::unordered_map<std::string, Measurement>::const_iterator
measurement_it1 =
request1.get_measurements().find(i->get_mac_addr()) ;
TS_ASSERT(request1.get_measurements().end() != measurement_it1) ;
// TS_ASSERT_EQUALS(TestUtil::requests.at(1)->get_measurements().
// at(i->get_mac_addr()).get_ss_list(),
// measurement_it1->second.get_ss_list()) ;
}
*/
// Third Request //
TS_ASSERT(inputcsv1) ;
TS_ASSERT(request1) ;
/*
assert(request1.get_mobile()) ;
TS_ASSERT(! inputcsv1.eof()) ;
@ -129,18 +111,13 @@ public:
TS_ASSERT_EQUALS(request1.get_time_sent(),
TestUtil::requests.at(2)->get_time_sent()) ;
for (std::vector<CapturePoint>::const_iterator i = TestUtil::aps.begin() ;
i != TestUtil::aps.end() ; ++i)
for (auto i = TestUtil::aps.begin() ; i != TestUtil::aps.end() ; ++i)
{
std::unordered_map<std::string, Measurement>::const_iterator
measurement_it1 =
request1.get_measurements().find(i->get_mac_addr()) ;
TS_ASSERT(request1.get_measurements().end() != measurement_it1) ;
// TS_ASSERT_EQUALS(TestUtil::requests.at(2)->get_measurements().
// at(i->get_mac_addr()).get_ss_list(),
// measurement_it1->second.get_ss_list()) ;
}
*/
// End of file

View File

@ -18,9 +18,6 @@ public:
// If we cannot open the file, we want to stop the test
CxxTest::setAbortTestOnFail(true) ;
// Clear the stock
Stock::clear() ;
csv_file_name = "/tmp/InputLogCSV_test_csv_file.csv" ;
TestUtil::create_test_csv_file(csv_file_name) ;
@ -35,7 +32,6 @@ public:
{
TestUtil::remove_file(csv_file_name) ;
TestUtil::remove_file(log_file_name) ;
Stock::clear() ;
}
@ -70,8 +66,7 @@ public:
// Read the two files and compare to the reference Request list
InputCSV inputcsv_csv(csv_file_name) ;
InputCSV inputcsv_log(log_file_name) ;
for (std::vector<Request*>::const_iterator i =
TestUtil::requests.begin() ;
for (auto i = TestUtil::requests.begin() ;
i != TestUtil::requests.end() ; ++i)
{
Stock::clear() ;

View File

@ -11,12 +11,13 @@ public:
TrilaterationAlgorithm *algo = new InterlinkNetworks() ;
// Initialise algo->request
char mobile_gain = 3, mobile_power = 15 ;
float mobile_gain = 3, mobile_power = 15 ;
Mobile mobile("", "", mobile_gain, mobile_power) ;
Request request(&mobile) ;
algo->compute(request) ; // yes, that's ugly
char ap_gain = 5, ap_power = 20, ap_channel = 1 ;
float ap_gain = 5, ap_power = 20 ;
unsigned int ap_channel = 1 ;
CapturePoint ap(Point3D(), "", "", ap_gain, ap_power, ap_channel) ;
std::map<pkt_id_t, ss_t> ss_list ;
@ -24,12 +25,17 @@ public:
Measurement measurement(&ap) ;
measurement.add_ss_list(ss_list) ;
/* ** How to check ref_distance in Scilab? **
* C = 5 + 20 + 20 * log10(299792458 / 2412000000 / (4 * PI)) + 3
* L = -42
* ref_distance = 10^((C-L)/35)
/* To check ref_distance in Scilab:
mobile_gain = 3
mobile_power = 15
ap_gain = 5
celerity = 299792458
frequency = 2412000000
C = mobile_gain + mobile_power + ap_gain + 20 * log10(celerity / frequency / (4 * %pi))
L = -42
ref_distance = 10^((C-L)/35)
*/
float ref_distance = 7.1519 ;
float ref_distance = 5.1470931 ;
float computed_distance = algo->estimate_distance(measurement) ;
TS_ASSERT_DELTA(computed_distance, ref_distance, 0.0001) ;

View File

@ -42,6 +42,7 @@ public:
m1.add_ss(1, -33) ;
m1.add_ss(2, -78) ;
m1.add_ss(3, -21) ;
TS_ASSERT_EQUALS(m1.get_nb_ss(), 3) ;
TS_ASSERT_EQUALS(m1.get_ss(1), -33) ;
TS_ASSERT_EQUALS(m1.get_ss(2), -78) ;
TS_ASSERT_EQUALS(m1.get_ss(3), -21) ;
@ -64,18 +65,26 @@ public:
*/
TS_ASSERT_DELTA(m1.get_average_dbm(), -25.505481, 0.0001) ;
m1.clear() ;
Measurement m2(&ap2) ;
std::map<pkt_id_t, ss_t> vi2 ;
vi2[1] = -54 ;
vi2[2] = -1 ;
m1.add_ss_list(vi2) ;
TS_ASSERT_EQUALS(m1.get_ss(1), -54) ;
TS_ASSERT_EQUALS(m1.get_ss(2), -1) ;
TS_ASSERT_DELTA(m1.get_average_dbm(), -4.0102782, 0.0001) ;
vi2[3] = -54 ;
vi2[4] = -1 ;
m2.add_ss_list(vi2) ;
TS_ASSERT_EQUALS(m2.get_nb_ss(), vi2.size()) ;
TS_ASSERT_EQUALS(m2.get_ss(3), -54) ;
TS_ASSERT_EQUALS(m2.get_ss(4), -1) ;
TS_ASSERT_DELTA(m2.get_average_dbm(), -4.0102782, 0.0001) ;
m1.merge(m2) ;
TS_ASSERT_EQUALS(m1.get_nb_ss(), 4) ;
TS_ASSERT_EQUALS(m1.get_ss(1), -33) ;
TS_ASSERT_EQUALS(m1.get_ss(2), -78) ;
TS_ASSERT_EQUALS(m1.get_ss(3), -54) ;
TS_ASSERT_EQUALS(m1.get_ss(4), -1) ;
m1.clear() ;
Measurement m2 ;
TS_ASSERT_EQUALS(m1, m2) ;
Measurement m3 ;
TS_ASSERT_EQUALS(m1, m3) ;
}

View File

@ -11,7 +11,6 @@ public:
OutputCSV_test(void)
{
Stock::clear() ;
csv_file_name = "/tmp/OutputCSV_test_csv_file.csv" ;
}
@ -19,7 +18,6 @@ public:
~OutputCSV_test(void)
{
TestUtil::remove_file(csv_file_name) ;
Stock::clear() ;
}
@ -35,11 +33,10 @@ public:
}
void test_outputcsv(void)
void test_write_result(void)
{
OutputCSV *outputcsv1 = new OutputCSV(csv_file_name) ;
for (std::vector<Result>::const_iterator i =
TestUtil::results.begin() ;
for (auto i = TestUtil::results.begin() ;
i != TestUtil::results.end() ; ++i)
outputcsv1->write(*i) ;
delete outputcsv1 ;
@ -52,15 +49,8 @@ public:
getline(inputcsv, line) ;
const Result &result = TestUtil::results.at(result_count) ;
std::ostringstream result_csv ;
result_csv
<< result.get_request()->get_mobile()->get_mac_addr() << ';'
<< result.get_request()->get_time_sent() << ';'
<< result.get_position().get_x() << ';'
<< result.get_position().get_y() << ';'
<< result.get_position().get_z() ;
TS_ASSERT_EQUALS(line, result_csv.str()) ;
std::string result_csv = result.to_csv() ;
TS_ASSERT_EQUALS(line, result_csv) ;
if (++result_count >= TestUtil::results.size())
break ;

View File

@ -40,6 +40,23 @@ public:
TS_ASSERT_EQUALS(p1.get_y(), 321) ;
p1.set_z(98) ;
TS_ASSERT_EQUALS(p1.get_z(), 98) ;
p1.set_coordinates(78, 79, 80) ;
TS_ASSERT_EQUALS(p1.get_x(), 78) ;
TS_ASSERT_EQUALS(p1.get_y(), 79) ;
TS_ASSERT_EQUALS(p1.get_z(), 80) ;
Point3D p2(4, 5, 6) ;
p1.set_coordinates(p2) ;
TS_ASSERT_EQUALS(p1.get_x(), 4) ;
TS_ASSERT_EQUALS(p1.get_y(), 5) ;
TS_ASSERT_EQUALS(p1.get_z(), 6) ;
float p3[3] = {7, 8, 9} ;
p1.set_coordinates(p3) ;
TS_ASSERT_EQUALS(p1.get_x(), 7) ;
TS_ASSERT_EQUALS(p1.get_y(), 8) ;
TS_ASSERT_EQUALS(p1.get_z(), 9) ;
}
@ -58,6 +75,8 @@ public:
Point3D p5(23, 2.4, 0.4) ;
TS_ASSERT_DELTA(p4.distance(p5), 43.588, 0.001) ;
TS_ASSERT_DELTA(p4.square_distance(p5), 1900, 0.001) ;
// TODO: complete this.
}

View File

@ -18,18 +18,22 @@ public:
PositioningAlgorithm *algo = new RealPosition() ;
Result res ;
// Empty request
res = algo->compute(request) ;
TS_ASSERT_EQUALS(res.get_position(), null_point) ;
// Non-empty request
Point3D point(3,2,1) ;
request.set_real_position(point) ;
res = algo->compute(request) ;
TS_ASSERT_EQUALS(res.get_position(), point) ;
// Calibration request
res = algo->compute(calibration_request) ;
TS_ASSERT_EQUALS(res.get_position(), reference_point) ;
Request *request_ptr ;
request_ptr = &request ;
res = algo->compute(*request_ptr) ;
TS_ASSERT_EQUALS(res.get_position(), null_point) ;
request_ptr = static_cast<Request*>(&calibration_request) ;
// CalibrationRequest casted to Request
Request *request_ptr = static_cast<Request*>(&calibration_request) ;
res = algo->compute(*request_ptr) ;
TS_ASSERT_EQUALS(res.get_position(), reference_point) ;

View File

@ -7,6 +7,7 @@ class ReferencePoint_test: public CxxTest::TestSuite
{
public:
void test_constructors(void)
{
// Default constructor
@ -40,7 +41,8 @@ public:
TS_ASSERT_EQUALS(rp1.get_z(), 5) ;
// Write & read accessors
CalibrationRequest calibrationrequest1, calibrationrequest2, calibrationrequest3 ;
CalibrationRequest
calibrationrequest1, calibrationrequest2, calibrationrequest3 ;
rp1.add_request(&calibrationrequest1) ;
rp1.add_request(&calibrationrequest2) ;
rp1.add_request(&calibrationrequest3) ;
@ -55,37 +57,15 @@ public:
TS_ASSERT_EQUALS(rp1.get_y(), 321) ;
rp1.set_z(98) ;
TS_ASSERT_EQUALS(rp1.get_z(), 98) ;
}
void test_ss_square_distance(void)
{
CapturePoint ap1(Point3D(1,2,3), "aa:bb:cc:dd:ee:ff") ;
CalibrationRequest calibrationrequest1 ;
Measurement measurement1(&ap1) ;
measurement1.add_ss(1, -78) ;
std::unordered_map<std::string, Measurement> measurements ;
measurements["aa:bb:cc:dd:ee:ff"] = measurement1 ;
calibrationrequest1.set_measurements(measurements) ;
ReferencePoint referencepoint1 ;
referencepoint1.add_request(&calibrationrequest1) ;
/*
TS_ASSERT_EQUALS(0, referencepoint1.ss_square_distance(
calibrationrequest1)) ;
*/
/* Distance computation:
* (-42 - (-78))^2 == 1296
*/
CalibrationRequest calibrationrequest2 ;
measurement1.clear() ;
measurement1.add_ss(1, -42) ;
measurements["aa:bb:cc:dd:ee:ff"] = measurement1 ;
calibrationrequest2.set_measurements(measurements) ;
/*
TS_ASSERT_EQUALS(1296, referencepoint1.ss_square_distance(
calibrationrequest2)) ;
*/
// delete_requests()
/* Note: as delete_requests() deletes the requests from the Stock,
* we must store them there first. */
Stock::find_create_calibration_request(calibrationrequest1) ;
Stock::find_create_calibration_request(calibrationrequest2) ;
Stock::find_create_calibration_request(calibrationrequest3) ;
rp1.delete_requests() ;
TS_ASSERT(rp1.get_requests().empty()) ;
}

View File

@ -2,6 +2,7 @@
#include "request.hh"
#include "mobile.hh"
#include "timestamp.hh"
class Request_test: public CxxTest::TestSuite
{
@ -9,17 +10,16 @@ public:
void test_constructors(void)
{
// Default constructor
Request r1 ;
std::unordered_map<std::string, Measurement> measurements ;
Request r2(measurements) ;
TS_ASSERT_EQUALS(r1, r2) ;
// We can't test the default constructor with two different objects
// like we usually do because the reception time is initialised by
// the Request constructor.
// Copy constructor
struct timespec current_time ;
std::unordered_map<std::string, Measurement> measurements ;
Measurement meas1 ;
measurements["aa:bb:cc:dd:ee:ff"] = meas1 ;
clock_gettime(CLOCK_REALTIME, &current_time) ;
measurements["AA:BB:CC:DD:EE:FF"] = meas1 ;
Timestamp current_time ;
current_time.now() ;
Mobile mob1 ;
Request r3(&mob1, current_time, measurements) ;
Request r4(r3) ;
@ -35,7 +35,7 @@ public:
CapturePoint ap1(Point3D(1,2,3), "192.168.0.1", "AA:BB:CC:DD:EE:FF") ;
Measurement meas1(&ap1) ;
std::unordered_map<std::string, Measurement> measurements ;
measurements["aa:bb:cc:dd:ee:ff"] = meas1 ;
measurements["AA:BB:CC:DD:EE:FF"] = meas1 ;
Mobile mob1 ;
Request r1(&mob1, current_time, measurements) ;
TS_ASSERT_EQUALS(r1.get_mobile(), &mob1) ;
@ -43,6 +43,12 @@ public:
TS_ASSERT_EQUALS(r1.get_measurements(), measurements) ;
// Write & read accessors
r1.set_type(OWL_REQUEST_GENERATED) ;
TS_ASSERT_EQUALS(r1.get_type(), OWL_REQUEST_GENERATED) ;
r1.set_nb_packets(42) ;
TS_ASSERT_EQUALS(r1.get_nb_packets(), 42) ;
Mobile mob2 ;
r1.set_mobile(&mob2) ;
TS_ASSERT_EQUALS(r1.get_mobile(), &mob2) ;
@ -51,39 +57,53 @@ public:
r1.set_time_sent(current_time) ;
TS_ASSERT_EQUALS(r1.get_time_sent(), current_time) ;
current_time.now() ;
r1.received_now() ;
TS_ASSERT_DELTA(static_cast<uint64_t>(r1.get_time_received()),
static_cast<uint64_t>(current_time),
100) ;
CapturePoint ap2(Point3D(3,2,1), "192.168.0.2", "AA:BB:CC:DD:EE:02") ;
Measurement meas2(&ap2) ;
measurements["aa:bb:cc:dd:ee:02"] = meas2 ;
measurements["AA:BB:CC:DD:EE:02"] = meas2 ;
r1.set_measurements(measurements) ;
TS_ASSERT_EQUALS(r1.get_measurements(), measurements) ;
// clear()
r1.clear() ;
Request r2 ;
r2.clear() ;
TS_ASSERT_EQUALS(r1, r2) ;
}
/*
* Operations:
* We don't test similarity() because it's just a wrapper around
* PosUtil functions.
*/
void test_operators(void)
{
// ==
struct timespec current_time ;
Timestamp current_time ;
current_time.now() ;
std::unordered_map<std::string, Measurement> measurements ;
Measurement meas1 ;
measurements["aa:bb:cc:dd:ee:00"] = meas1 ;
clock_gettime(CLOCK_REALTIME, &current_time) ;
measurements["AA:BB:CC:DD:EE:00"] = meas1 ;
Request r1(current_time, measurements) ;
Request r2(current_time, measurements) ;
Request r2(r1) ;
TS_ASSERT_EQUALS(r1, r2) ;
Mobile mob1 ;
Request r3(&mob1, current_time, measurements) ;
Request r4(&mob1, current_time, measurements) ;
Request r4(r3) ;
TS_ASSERT_EQUALS(r3, r4) ;
// !=
Measurement meas2 ;
measurements["aa:bb:cc:dd:ee:01"] = meas2 ;
measurements["AA:BB:CC:DD:EE:01"] = meas2 ;
Request r5(&mob1, current_time, measurements) ;
TS_ASSERT(r4 != r5) ;

View File

@ -7,12 +7,12 @@ class Result_test: public CxxTest::TestSuite
{
public:
void test_constructor(void)
void test_constructors(void)
{
// Default constructor
Result result1 ;
Result result2(NULL) ;
Result result3(NULL, Point3D()) ;
Result result3(NULL, "UnknownAlgorithm") ;
TS_ASSERT_EQUALS(result1, result2) ;
TS_ASSERT_EQUALS(result1, result3) ;
@ -23,14 +23,32 @@ public:
void test_accessors(void)
{
// We cannot test easily in_which_area() without a complete
// configuration.
Timestamp timestamp1 ;
timestamp1.now() ;
Request request1(timestamp1) ;
Point3D point3d1(3,4,2) ;
Result result1(&request1, point3d1) ;
Result result1(&request1, "MyAlgorithm", point3d1) ;
TS_ASSERT_EQUALS(result1.get_position(), point3d1) ;
TS_ASSERT_EQUALS(result1.get_request(), &request1) ;
TS_ASSERT_EQUALS(result1.get_error(), -1) ;
}
void test_error(void)
{
Timestamp timestamp1 ;
timestamp1.now() ;
Request request1(timestamp1) ;
Point3D position(1, 1, 1), real_position(1, 5, 1) ;
Result result1(&request1, "MyAlgorithm", position, real_position) ;
TS_ASSERT_EQUALS(result1.get_error(), 4) ;
Point3D real_position2(1, 3.5, 1) ;
result1.compute_error(real_position2) ;
TS_ASSERT_EQUALS(result1.get_error(), 2.5) ;
}
void test_operators(void)

View File

@ -7,11 +7,13 @@ class Stock_test: public CxxTest::TestSuite
{
public:
// Run before each test
void setUp(void)
{
Stock::clear() ;
}
// Run after each test
void tearDown(void)
{
Stock::clear() ;
@ -87,7 +89,7 @@ public:
TS_ASSERT_EQUALS(Stock::getw_cp("00:00:00:00:02:01"), ap1) ;
CapturePoint ap2(Point3D(1,2,3), "192.168.2.1", "00:00:00:00:02:02",
8.5, 2.1, 11) ;
8.5, 2.1, 11) ;
Stock::getw_cp("00:00:00:00:02:02") = ap2 ;
TS_ASSERT_EQUALS(Stock::get_cp("00:00:00:00:02:02"), ap2) ;
TS_ASSERT_EQUALS(Stock::getw_cp("00:00:00:00:02:02"), ap2) ;
@ -130,7 +132,7 @@ public:
Measurement measurement1(&ap1) ;
measurement1.add_ss(1, -23) ;
std::unordered_map<std::string, Measurement> measurements ;
measurements["aa:bb:cc:dd:ee:ff"] = measurement1 ;
measurements["AA:BB:CC:DD:EE:FF"] = measurement1 ;
calibrationrequest1.set_measurements(measurements) ;
TS_ASSERT_THROWS(Stock::closest_reference_point(calibrationrequest1),
element_not_found) ;
@ -147,7 +149,7 @@ public:
Measurement measurement2(&ap1) ;
measurement2.add_ss(1, -78) ;
measurements.clear() ;
measurements["aa:bb:cc:dd:ee:ff"] = measurement2 ;
measurements["AA:BB:CC:DD:EE:FF"] = measurement2 ;
calibrationrequest2.set_measurements(measurements) ;
ReferencePoint referencepoint2(88,99,111) ;
referencepoint2.add_request(&calibrationrequest2) ;
@ -164,7 +166,7 @@ public:
Measurement measurement3(&ap1) ;
measurement3.add_ss(1, -75) ;
measurements.clear() ;
measurements["aa:bb:cc:dd:ee:ff"] = measurement3 ;
measurements["AA:BB:CC:DD:EE:FF"] = measurement3 ;
request3.set_measurements(measurements) ;
TS_ASSERT_EQUALS(
&Stock::closest_reference_point(request3),
@ -174,7 +176,7 @@ public:
Measurement measurement4(&ap1) ;
measurement4.add_ss(1, -8) ;
measurements.clear() ;
measurements["aa:bb:cc:dd:ee:ff"] = measurement4 ;
measurements["AA:BB:CC:DD:EE:FF"] = measurement4 ;
request4.set_measurements(measurements) ;
TS_ASSERT_EQUALS(
&Stock::closest_reference_point(request4),

View File

@ -5,6 +5,7 @@
static TestSetUp testsetup ;
// This is called before each test suite
bool TestSetUp::setUpWorld(void)
{
TestUtil::set_up() ;
@ -12,6 +13,7 @@ bool TestSetUp::setUpWorld(void)
}
// This is called after each test suite
bool TestSetUp::tearDownWorld(void)
{
TestUtil::tear_down() ;

View File

@ -1,6 +1,8 @@
#include "testutil.hh"
#include <cxxtest/TestSuite.h>
#include "stock.hh"
#include "userinterface.hh"
#include "calibrationrequest.hh"
#include "realposition.hh"
@ -19,6 +21,8 @@ vector<ReferencePoint> TestUtil::reference_points ;
void TestUtil::tear_down()
{
Stock::clear() ;
aps.clear() ;
mobiles.clear() ;
@ -39,6 +43,7 @@ void TestUtil::set_up()
create_cp_list() ;
create_request_list() ;
create_result_list() ;
setup_configuration() ;
}
void TestUtil::create_mobile_list()
@ -154,6 +159,23 @@ void TestUtil::create_result_list()
}
}
void TestUtil::setup_configuration()
{
const std::string config_file_name("/dev/null") ;
const char *argv[] =
{
"owlps-positionerd", // program name
"--config-file", config_file_name.c_str(),
"--positioning.area-start", "0;0;0",
"--positioning.area-stop", "10;15;3",
"--positioning.accept-new-mobiles", "true",
"--positioning.accept-new-cps", "true"
} ;
int argc = 11 ;
UserInterface ui(argc, argv) ;
}
// Create the file output_file_name and fill it with the contents of
// output_lines
@ -189,53 +211,72 @@ create_test_csv_file(const string &file_name, bool with_spaces)
// Fill name and contents of the test CSV file
vector<string> csv_lines ;
ostringstream line ;
constexpr unsigned int csv_format = OWL_LATEST_AGGREGATION_CSV_FORMAT ;
/* The CSV format to use is documented in the header of InputCSV */
if (with_spaces)
line << "\n \n " ;
line << mobiles[0].get_mac_addr() ;
line << csv_format ;
line << ';' << mobiles[0].get_mac_addr() ;
line << ';' << static_cast<uint_fast16_t>(requests.at(0)->get_type()) ;
line << ';' << requests.at(0)->get_nb_packets() ;
line << ';' << requests.at(0)->get_time_sent() ;
line << ";0;0;0;0;" ;
line << aps[0].get_mac_addr() ;
line << ';' << 1 ;
line << ';' << requests.at(0)->get_measurements()
.at(aps[0].get_mac_addr()).get_ss(1) ;
line << ';' << aps[2].get_mac_addr() ;
line << ';' << 1 ;
line << ';' << requests.at(0)->get_measurements()
.at(aps[2].get_mac_addr()).get_ss(1) ;
line << ';' << aps[1].get_mac_addr() ;
line << ';' << 1 ;
line << ';' << requests.at(0)->get_measurements()
.at(aps[1].get_mac_addr()).get_ss(1) ;
line << ';' << aps[0].get_mac_addr() ;
line << ';' << 2 ;
line << ';' << requests.at(0)->get_measurements()
.at(aps[0].get_mac_addr()).get_ss(2) ;
line << ';' << aps[1].get_mac_addr() ;
line << ';' << 2 ;
line << ';' << requests.at(0)->get_measurements()
.at(aps[1].get_mac_addr()).get_ss(2) ;
line << '\n' ;
csv_lines.push_back(line.str()) ;
line.str("") ;
line << mobiles[1].get_mac_addr() ;
line << csv_format ;
line << ';' << mobiles[1].get_mac_addr() ;
CalibrationRequest *calibration_request =
dynamic_cast<CalibrationRequest*>(requests.at(1)) ;
assert(calibration_request) ;
line << ';' << static_cast<uint_fast16_t>(calibration_request->get_type()) ;
line << ';' << calibration_request->get_nb_packets() ;
line << ';' << calibration_request->get_time_sent() ;
line << ';' << reference_points.at(0).get_x() ;
line << ';' << reference_points.at(0).get_y() ;
line << ';' << reference_points.at(0).get_z() ;
line << ';' << static_cast<int>(calibration_request->get_direction()) ;
line << ';' << aps[2].get_mac_addr() ;
line << ';' << 1 ;
line << ';' << calibration_request->get_measurements()
.at(aps[2].get_mac_addr()).get_ss(1) ;
line << ';' << aps[0].get_mac_addr() ;
line << ';' << 1 ;
line << ';' << calibration_request->get_measurements()
.at(aps[0].get_mac_addr()).get_ss(1) ;
line << ';' << aps[1].get_mac_addr() ;
line << ';' << 1 ;
line << ';' << calibration_request->get_measurements()
.at(aps[1].get_mac_addr()).get_ss(1) ;
line << ';' << aps[1].get_mac_addr() ;
line << ';' << 2 ;
line << ';' << calibration_request->get_measurements()
.at(aps[1].get_mac_addr()).get_ss(2) ;
line << ';' << aps[0].get_mac_addr() ;
line << ';' << 2 ;
line << ';' << calibration_request->get_measurements()
.at(aps[0].get_mac_addr()).get_ss(2) ;
line << '\n' ;
@ -249,22 +290,30 @@ create_test_csv_file(const string &file_name, bool with_spaces)
line.str("") ;
if (with_spaces)
line << '\t' ;
line << mobiles[0].get_mac_addr() ;
line << csv_format ;
line << ';' << mobiles[0].get_mac_addr() ;
line << ';' << static_cast<uint_fast16_t>(requests.at(2)->get_type()) ;
line << ';' << requests.at(2)->get_nb_packets() ;
line << ';' << requests.at(2)->get_time_sent() ;
line << ";0;0;0;0;" ;
line << aps[2].get_mac_addr() ;
line << ';' << 1 ;
line << ';' << requests.at(2)->get_measurements()
.at(aps[2].get_mac_addr()).get_ss(1) ;
line << ';' << aps[1].get_mac_addr() ;
line << ';' << 1 ;
line << ';' << requests.at(2)->get_measurements()
.at(aps[1].get_mac_addr()).get_ss(1) ;
line << ';' << aps[0].get_mac_addr() ;
line << ';' << 1 ;
line << ';' << requests.at(2)->get_measurements()
.at(aps[0].get_mac_addr()).get_ss(1) ;
line << ';' << aps[1].get_mac_addr() ;
line << ';' << 2 ;
line << ';' << requests.at(2)->get_measurements()
.at(aps[1].get_mac_addr()).get_ss(2) ;
line << ';' << aps[0].get_mac_addr() ;
line << ';' << 2 ;
line << ';' << requests.at(2)->get_measurements()
.at(aps[0].get_mac_addr()).get_ss(2) ;
line << '\n' ;

View File

@ -19,6 +19,7 @@ private:
static void create_cp_list(void) ;
static void create_request_list(void) ;
static void create_result_list(void) ;
static void setup_configuration(void) ;
public:
static std::vector<CapturePoint> aps ;

View File

@ -41,7 +41,7 @@ public:
output_file.close() ;
std::string line ;
TextFileReader *textfilereader ;
TextFileReader *textfilereader = NULL ;
TS_ASSERT_THROWS_NOTHING(
textfilereader = new TextFileReader(test_file_name)) ;
TS_ASSERT(textfilereader->read_line(line)) ;

View File

@ -35,7 +35,7 @@ public:
void test_textfilewriter(void)
{
TextFileWriter *textfilewriter ;
TextFileWriter *textfilewriter = NULL ;
TS_ASSERT_THROWS_NOTHING(
textfilewriter = new TextFileWriter(test_file_name)) ;
TS_ASSERT(textfilewriter->write_text("Hello\nWorld\n")) ;

View File

@ -39,7 +39,8 @@ public:
TS_ASSERT_EQUALS(timestamp1, timestamp4) ;
// Equality
TS_ASSERT_EQUALS(static_cast<struct timespec>(timestamp1), timespec1) ;
TS_ASSERT_EQUALS(static_cast<struct timespec>(timestamp1),
timespec1) ;
TS_ASSERT_EQUALS(timestamp1, timespec1) ;
TS_ASSERT_EQUALS(static_cast<uint64_t>(timestamp1), msec) ;
TS_ASSERT_EQUALS(timestamp1, msec) ;
@ -48,7 +49,7 @@ public:
void test_non_zero(void)
{
uint64_t sec = 1234567 ;
uint64_t nsec = 891234567 ; // Do not put a value >= 1 sec. for the test!
uint64_t nsec = 891234567 ; // Don't put a value >= 1 sec. for the test!
uint64_t msec = sec * 1000 + nsec / 1000000 ;
struct timespec timespec1 ;
timespec1.tv_sec = sec ;
@ -56,19 +57,23 @@ public:
// struct timespec constructor
Timestamp timestamp1(timespec1) ;
timespec1.tv_nsec = nsec / 1000000 * 1000000 ; // Round to ms
TS_ASSERT_EQUALS(static_cast<struct timespec>(timestamp1), timespec1) ;
TS_ASSERT_EQUALS(static_cast<struct timespec>(timestamp1),
timespec1) ;
TS_ASSERT_EQUALS(timestamp1, timespec1) ;
TS_ASSERT_EQUALS(static_cast<uint64_t>(timestamp1), msec) ;
TS_ASSERT_EQUALS(timestamp1, msec) ;
// ms constructor
// ms constructor (deprecated)
Timestamp timestamp2(msec) ;
TS_ASSERT_EQUALS(static_cast<struct timespec>(timestamp2), timespec1) ;
timespec1.tv_nsec = nsec / 1000000 * 1000000 ; // Round to ms
TS_ASSERT_EQUALS(static_cast<struct timespec>(timestamp2),
timespec1) ;
TS_ASSERT_EQUALS(timestamp2, timespec1) ;
TS_ASSERT_EQUALS(static_cast<uint64_t>(timestamp2), msec) ;
TS_ASSERT_EQUALS(timestamp2, msec) ;
TS_ASSERT_EQUALS(timestamp1, timestamp2) ;
// ms and ns give different values
TS_ASSERT_DIFFERS(timestamp1, timestamp2) ;
// Copy constructor
Timestamp timestamp3(timestamp1) ;
@ -77,6 +82,8 @@ public:
void test_current_time(void)
{
// Note: we could test update_current_time() in replay mode.
Timestamp timestamp1 ;
struct timespec current_time ;
@ -86,18 +93,28 @@ public:
TS_FAIL("Error getting current time!") ;
return ;
}
const Timestamp &now = Timestamp::get_current_time() ;
Timestamp timestamp2(current_time) ;
TS_ASSERT_DELTA(static_cast<uint64_t>(timestamp1),
static_cast<uint64_t>(timestamp2),
100) ;
TS_ASSERT_DELTA(static_cast<uint64_t>(timestamp2),
static_cast<uint64_t>(now),
100) ;
// The following tests may fail if the ns value is a ms
TS_ASSERT_DIFFERS(static_cast<struct timespec>(timestamp1), current_time) ;
TS_ASSERT(timestamp1 != current_time) ;
TS_ASSERT_DIFFERS(static_cast<struct timespec>(timestamp2), current_time) ;
TS_ASSERT(timestamp2 != current_time) ;
TS_ASSERT_DIFFERS(static_cast<struct timespec>(timestamp1),
current_time) ;
TS_ASSERT_EQUALS(static_cast<struct timespec>(timestamp2),
current_time) ;
// elapsed()
Timestamp elapsed11(timestamp1.elapsed(timestamp1)) ;
TS_ASSERT_EQUALS(static_cast<uint64_t>(elapsed11), 0) ;
TS_ASSERT(! elapsed11) ;
Timestamp elapsed12(timestamp1.elapsed(timestamp2)) ;
TS_ASSERT(static_cast<uint64_t>(elapsed12) < 100) ;
Timestamp elapsed21(timestamp2.elapsed(timestamp1)) ;
TS_ASSERT_EQUALS(elapsed12, elapsed21) ;
}
void test_affectation(void)
@ -111,26 +128,28 @@ public:
// struct timespec constructor
Timestamp timestamp1(current_time) ;
TS_ASSERT_DIFFERS(static_cast<struct timespec>(timestamp1), current_time) ;
TS_ASSERT(timestamp1 != current_time) ;
TS_ASSERT_EQUALS(static_cast<struct timespec>(timestamp1),
current_time) ;
// ms constructor
// ms constructor (deprecated)
current_time.tv_nsec = current_time.tv_nsec / 1000000 * 1000000 ;
uint64_t msec = timestamp1 ;
Timestamp timestamp2(msec) ;
TS_ASSERT_EQUALS(static_cast<uint64_t>(timestamp2), msec) ;
TS_ASSERT_EQUALS(timestamp2, msec) ;
TS_ASSERT_EQUALS(static_cast<struct timespec>(timestamp2), current_time) ;
TS_ASSERT_EQUALS(static_cast<struct timespec>(timestamp2),
current_time) ;
TS_ASSERT_EQUALS(timestamp2, current_time) ;
// Affectation
++current_time.tv_sec ;
timestamp2 = current_time ;
TS_ASSERT(timestamp1 != timestamp2) ;
TS_ASSERT_DIFFERS(timestamp1, timestamp2) ;
msec = timestamp2 ;
TS_ASSERT_EQUALS(static_cast<uint64_t>(timestamp2), msec) ;
TS_ASSERT_EQUALS(timestamp2, msec) ;
TS_ASSERT_EQUALS(static_cast<struct timespec>(timestamp2), current_time) ;
TS_ASSERT_EQUALS(static_cast<struct timespec>(timestamp2),
current_time) ;
TS_ASSERT_EQUALS(timestamp2, current_time) ;
msec = 1234567891234ull ;
@ -138,7 +157,8 @@ public:
TS_ASSERT_EQUALS(static_cast<uint64_t>(timestamp2), msec) ;
TS_ASSERT_EQUALS(timestamp2, msec) ;
current_time = timestamp2 ;
TS_ASSERT_EQUALS(static_cast<struct timespec>(timestamp2), current_time) ;
TS_ASSERT_EQUALS(static_cast<struct timespec>(timestamp2),
current_time) ;
TS_ASSERT_EQUALS(timestamp2, current_time) ;
}
@ -170,17 +190,17 @@ public:
TS_ASSERT(! (today > today_timespec)) ;
TS_ASSERT(! (today < today_timespec)) ;
TS_ASSERT(today != yesterday) ;
TS_ASSERT_DIFFERS(today, yesterday) ;
TS_ASSERT_LESS_THAN(yesterday, today) ;
TS_ASSERT_LESS_THAN_EQUALS(yesterday, today) ;
TS_ASSERT(! (yesterday > today)) ;
TS_ASSERT(! (yesterday >= today)) ;
TS_ASSERT(today != yesterday_int) ;
TS_ASSERT_DIFFERS(today, yesterday_int) ;
TS_ASSERT_LESS_THAN(yesterday, today_int) ;
TS_ASSERT_LESS_THAN_EQUALS(yesterday, today_int) ;
TS_ASSERT(! (yesterday > today_int)) ;
TS_ASSERT(! (yesterday >= today_int)) ;
TS_ASSERT(today != yesterday_timespec) ;
TS_ASSERT_DIFFERS(today, yesterday_timespec) ;
TS_ASSERT_LESS_THAN(yesterday, today_timespec) ;
TS_ASSERT_LESS_THAN_EQUALS(yesterday, today_timespec) ;
TS_ASSERT(! (yesterday > today_timespec)) ;
@ -198,9 +218,9 @@ public:
Timestamp today ;
today.now() ;
TS_ASSERT(today != zero) ;
TS_ASSERT(today != zero_timespec) ;
TS_ASSERT(today != zero_timestamp) ;
TS_ASSERT_DIFFERS(today, zero) ;
TS_ASSERT_DIFFERS(today, zero_timespec) ;
TS_ASSERT_DIFFERS(today, zero_timestamp) ;
today.clear() ;
TS_ASSERT_EQUALS(today, zero) ;

View File

@ -14,8 +14,6 @@ public:
areas_file_name("/tmp/TopologyReaderCSV_areas_file.csv"),
waypoints_file_name("/tmp/TopologyReaderCSV_waypoints_file.csv")
{
Stock::clear() ;
std::ofstream areas_file(areas_file_name.c_str()) ;
areas_file
<< "My building;My room #1;1;2;3;9;8;7\n"
@ -43,7 +41,6 @@ public:
~TopologyReaderCSV_test(void)
{
Stock::clear() ;
TestUtil::remove_file(areas_file_name) ;
TestUtil::remove_file(waypoints_file_name) ;
}
@ -63,11 +60,11 @@ public:
void test_areas(void)
{
Building *building1 ;
Building *building1 = NULL ;
TS_ASSERT_THROWS_NOTHING(
building1 = const_cast<Building*>(
&Stock::get_building("My building"))) ;
Building *building2 ;
Building *building2 = NULL ;
TS_ASSERT_THROWS_NOTHING(
building2 = const_cast<Building*>(
&Stock::get_building("Building #2"))) ;
@ -97,11 +94,11 @@ public:
void test_waypoints(void)
{
Building *building1 ;
Building *building1 = NULL ;
TS_ASSERT_THROWS_NOTHING(
building1 = const_cast<Building*>(
&Stock::get_building("My building"))) ;
Building *building2 ;
Building *building2 = NULL ;
TS_ASSERT_THROWS_NOTHING(
building2 = const_cast<Building*>(
&Stock::get_building("Building #2"))) ;

View File

@ -62,7 +62,7 @@ public:
} ;
int argc = 3 ;
UserInterface ui(argc, const_cast<char**>(argv)) ;
UserInterface ui(argc, argv) ;
TS_ASSERT(Configuration::is_configured("input.udp-port")) ;
TS_ASSERT(Configuration::is_configured("config-file")) ;