[Positioning] Add unit tests
Add tests for all (rewriten) classes, except for InputCSV.
This commit is contained in:
parent
fb73ba03c1
commit
bd28a26fa3
|
@ -1,5 +1,9 @@
|
|||
.PHONY : all obj doc clean purge install uninstall style check
|
||||
.PHONY : all obj test doc clean purge install uninstall style check
|
||||
|
||||
TEST_DIR = tests
|
||||
TEST_XX = $(TEST_DIR)/tests.cc
|
||||
TEST_OBJ = $(TEST_DIR)/tests.o
|
||||
TEST_TARGET = $(TEST_DIR)/tests
|
||||
DOXYGEN_DIR = doc
|
||||
DOXYFILE = Doxyfile
|
||||
|
||||
|
@ -19,6 +23,7 @@ DOXYGEN = doxygen
|
|||
|
||||
GXX = g++-4.4
|
||||
#DEBUG = -g
|
||||
TESTSGXXFLAGS = -I$(TEST_DIR) -I.
|
||||
GXXFLAGS = $(DEBUG) -Wall -Wextra $(STLPORTGXXFLAGS)
|
||||
LD = $(GXX)
|
||||
LDFLAGS = -lm -lrt
|
||||
|
@ -38,6 +43,9 @@ all: $(TARGET)
|
|||
%.o: %.cc $(HEADER)
|
||||
$(GXX) $(GXXFLAGS) -c $<
|
||||
|
||||
$(TEST_DIR)/%_test.o: %.o
|
||||
$(GXX) $(GXXFLAGS) $(TESTSGXXFLAGS) -c $<
|
||||
|
||||
posutil.o: posutil.hh
|
||||
stock.o: stock.hh
|
||||
point3d.o: point3d.hh
|
||||
|
@ -62,14 +70,29 @@ obj: $(OBJ)
|
|||
|
||||
$(TARGET): $(OBJ)
|
||||
|
||||
$(TEST_XX): $(OBJ:%.o=$(TEST_DIR)/%_test.hh)
|
||||
$(TEST_DIR)/cxxtestgen.pl --error-printer -o $@ $^
|
||||
|
||||
$(TEST_OBJ): $(TEST_XX) $(OBJ)
|
||||
$(GXX) $(GXXFLAGS) $(TESTSGXXFLAGS) -o $@ -c $<
|
||||
|
||||
$(TEST_TARGET): $(TEST_OBJ)
|
||||
$(LD) $(LDFLAGS) -o $@ $^ $(OBJ)
|
||||
|
||||
test: $(TEST_TARGET)
|
||||
@$(TEST_TARGET)
|
||||
|
||||
doc:
|
||||
@$(DOXYGEN) $(DOXYFILE)
|
||||
|
||||
clean:
|
||||
@$(RM) *~ *.o *.gch *.orig
|
||||
@$(RM) $(TEST_OBJ) $(TEST_XX) $(TEST_DIR)/*~ $(TEST_DIR)/*.o \
|
||||
$(TEST_DIR)/*.orig
|
||||
|
||||
purge: clean
|
||||
@$(RM) $(TARGET)
|
||||
@$(RM) $(TEST_TARGET)
|
||||
@$(RM_RECURSIVE) $(DOXYGEN_DIR)
|
||||
|
||||
install: $(TARGET)
|
||||
|
@ -84,7 +107,8 @@ style:
|
|||
@$(STYLE) \
|
||||
$(OBJ:.o=.hh) \
|
||||
$(OBJ:.o=.cc) \
|
||||
inputmedium.hh
|
||||
inputmedium.hh \
|
||||
$(OBJ:%.o=$(TEST_DIR)/%_test.hh)
|
||||
|
||||
check:
|
||||
@$(CPPCHECK) $(OBJ:.o=.hh) $(OBJ:.o=.cc) inputmedium.hh
|
||||
|
|
|
@ -0,0 +1,82 @@
|
|||
#include <cxxtest/TestSuite.h>
|
||||
|
||||
#include "accesspoint.hh"
|
||||
|
||||
class AccessPoint_test: public CxxTest::TestSuite
|
||||
{
|
||||
public:
|
||||
|
||||
void test_constructors(void)
|
||||
{
|
||||
// Default constructor
|
||||
AccessPoint accesspoint1 ;
|
||||
AccessPoint accesspoint2(Point3D(), "", "",
|
||||
AP_DEFAULT_ANTENNA_GAIN,
|
||||
WIFIDEVICE_DEFAULT_TRX_POWER,
|
||||
AP_DEFAULT_CHANNEL) ;
|
||||
TS_ASSERT_EQUALS(accesspoint1, accesspoint2) ;
|
||||
|
||||
// Copy constructor
|
||||
AccessPoint accesspoint3(Point3D(4,3,5), "192.168.0.1",
|
||||
"aa:bb:cc:dd:ee:ff", 5, 32, 11) ;
|
||||
AccessPoint accesspoint4(accesspoint3) ;
|
||||
TS_ASSERT_EQUALS(accesspoint3, accesspoint4) ;
|
||||
}
|
||||
|
||||
|
||||
void test_accessors(void)
|
||||
{
|
||||
// Simple read accessors
|
||||
Point3D point3d1(78,23,4) ;
|
||||
AccessPoint accesspoint1(point3d1, "192.168.0.1",
|
||||
"aa:bb:cc:dd:ee:ff", 6, 38, 10) ;
|
||||
TS_ASSERT_EQUALS(accesspoint1.get_coordinates(), point3d1) ;
|
||||
TS_ASSERT_EQUALS(accesspoint1.get_ip_addr(), "192.168.0.1") ;
|
||||
TS_ASSERT_EQUALS(accesspoint1.get_mac_addr(), "aa:bb:cc:dd:ee:ff") ;
|
||||
TS_ASSERT_EQUALS(accesspoint1.get_antenna_gain(), 6) ;
|
||||
TS_ASSERT_EQUALS(accesspoint1.get_trx_power(), 38) ;
|
||||
TS_ASSERT_EQUALS(accesspoint1.get_frequency(),
|
||||
PosUtil::channel_to_frequency(10)) ;
|
||||
|
||||
// Write & read accessors
|
||||
Point3D point3d2(78,23,4) ;
|
||||
accesspoint1.set_coordinates(point3d2) ;
|
||||
TS_ASSERT_EQUALS(accesspoint1.get_coordinates(), point3d2) ;
|
||||
accesspoint1.set_ip_addr("10.0.8.42") ;
|
||||
TS_ASSERT_EQUALS(accesspoint1.get_ip_addr(), "10.0.8.42") ;
|
||||
accesspoint1.set_mac_addr("00:11:22:33:44:55") ;
|
||||
TS_ASSERT_EQUALS(accesspoint1.get_mac_addr(), "00:11:22:33:44:55") ;
|
||||
accesspoint1.set_antenna_gain(12.4) ;
|
||||
TS_ASSERT_DELTA(accesspoint1.get_antenna_gain(), 12.4, 0.00001) ;
|
||||
accesspoint1.set_trx_power(22.7) ;
|
||||
TS_ASSERT_DELTA(accesspoint1.get_trx_power(), 22.7, 0.00001) ;
|
||||
accesspoint1.set_channel(13) ;
|
||||
TS_ASSERT_EQUALS(accesspoint1.get_frequency(),
|
||||
PosUtil::channel_to_frequency(13)) ;
|
||||
accesspoint1.set_frequency(2423) ;
|
||||
TS_ASSERT_EQUALS(accesspoint1.get_frequency(), 2423u) ;
|
||||
}
|
||||
|
||||
|
||||
void test_operators(void)
|
||||
{
|
||||
// ==
|
||||
Point3D point3d1(78,23,4) ;
|
||||
AccessPoint accesspoint1(point3d1, "192.168.0.1",
|
||||
"aa:bb:cc:dd:ee:ff", 6, 38, 10) ;
|
||||
AccessPoint accesspoint2(point3d1, "192.168.0.1",
|
||||
"aa:bb:cc:dd:ee:ff", 6, 38, 10) ;
|
||||
TS_ASSERT_EQUALS(accesspoint1, accesspoint2) ;
|
||||
|
||||
// !=
|
||||
Point3D point3d2(7,3,24) ;
|
||||
AccessPoint accesspoint3(point3d1, "10.0.0.1",
|
||||
"aa:bb:cc:dd:ee:ff", 6, 38, 10) ;
|
||||
TS_ASSERT_DIFFERS(accesspoint2, accesspoint3) ;
|
||||
|
||||
// =
|
||||
accesspoint2 = accesspoint3 ;
|
||||
TS_ASSERT_EQUALS(accesspoint2, accesspoint3) ;
|
||||
}
|
||||
|
||||
} ;
|
|
@ -0,0 +1,106 @@
|
|||
#include <cxxtest/TestSuite.h>
|
||||
|
||||
#include "area.hh"
|
||||
#include "building.hh"
|
||||
|
||||
class Area_test: public CxxTest::TestSuite
|
||||
{
|
||||
public:
|
||||
|
||||
void test_constructors(void)
|
||||
{
|
||||
// Default constructor
|
||||
Area a1 ;
|
||||
Area a2(NULL, "Unnamed area", 0,0,0, 0,0,0) ;
|
||||
TS_ASSERT_EQUALS(a1, a2) ;
|
||||
|
||||
// Copy constructor
|
||||
Building b1 ;
|
||||
Area a3(&b1, "My Area", 3,2,1, 0,1,2) ;
|
||||
Area a4(a3) ;
|
||||
TS_ASSERT_EQUALS(a3, a4) ;
|
||||
}
|
||||
|
||||
|
||||
void test_accessors(void)
|
||||
{
|
||||
// Simple read accessors
|
||||
Building b1("Numerica") ;
|
||||
Area a1(&b1, "My Area", 1,3,5, 8,7,4) ;
|
||||
TS_ASSERT_EQUALS(a1.get_building(), &b1) ;
|
||||
TS_ASSERT_EQUALS(a1.get_name(), "My Area") ;
|
||||
|
||||
TS_WARN("TODO: test inversion of points.") ;
|
||||
/*
|
||||
TS_ASSERT_EQUALS(a1.get_p_min(), Point3D(1,3,5)) ;
|
||||
TS_ASSERT_EQUALS(a1.get_p_max(), Point3D(8,7,4)) ;
|
||||
*/
|
||||
|
||||
// Write & read accessors
|
||||
Building b2("Numerica 2") ;
|
||||
a1.set_building(&b2) ;
|
||||
TS_ASSERT_EQUALS(a1.get_building(), &b2) ;
|
||||
a1.set_name("My new Area") ;
|
||||
TS_ASSERT_EQUALS(a1.get_name(), "My new Area") ;
|
||||
|
||||
TS_WARN("TODO: test inversion of points.") ;
|
||||
a1.set_x_min(56) ;
|
||||
a1.set_y_min(32) ;
|
||||
a1.set_z_min(49) ;
|
||||
TS_ASSERT_EQUALS(a1.get_p_min(), Point3D(56,32,49)) ;
|
||||
a1.set_x_max(99) ;
|
||||
a1.set_y_max(44) ;
|
||||
a1.set_z_max(77) ;
|
||||
TS_ASSERT_EQUALS(a1.get_p_max(), Point3D(99,44,77)) ;
|
||||
Point3D p1(9,4,2) ;
|
||||
a1.set_p_min(p1) ;
|
||||
TS_ASSERT_EQUALS(a1.get_p_min(), p1) ;
|
||||
Point3D p2(1,7,1) ;
|
||||
a1.set_p_max(p2) ;
|
||||
TS_ASSERT_EQUALS(a1.get_p_max(), p2) ;
|
||||
}
|
||||
|
||||
|
||||
void test_contains_point(void)
|
||||
{
|
||||
Building b1("Numerica") ;
|
||||
Area a1(&b1, "My Area", 0,0,0, 3,3,3) ;
|
||||
|
||||
Point3D p01(0,0,0) ;
|
||||
TS_ASSERT(a1.contains_point(p01)) ;
|
||||
Point3D p02(3,3,3) ;
|
||||
TS_ASSERT(a1.contains_point(p02)) ;
|
||||
Point3D p03(2,2,2) ;
|
||||
TS_ASSERT(a1.contains_point(p03)) ;
|
||||
Point3D p04(0,2,1) ;
|
||||
TS_ASSERT(a1.contains_point(p04)) ;
|
||||
|
||||
Point3D p11(-1,0,0) ;
|
||||
TS_ASSERT(! a1.contains_point(p11)) ;
|
||||
Point3D p12(3.1,3.2,3.3) ;
|
||||
TS_ASSERT(! a1.contains_point(p12)) ;
|
||||
Point3D p13(2,3.3,2) ;
|
||||
TS_ASSERT(! a1.contains_point(p13)) ;
|
||||
Point3D p14(2,2,3.5) ;
|
||||
TS_ASSERT(! a1.contains_point(p14)) ;
|
||||
}
|
||||
|
||||
|
||||
void test_operators(void)
|
||||
{
|
||||
// ==
|
||||
Building b1("Numerica") ;
|
||||
Area a1(&b1, "My Area", 1,3,5, 8,7,4) ;
|
||||
Area a2(&b1, "My Area", 1,3,5, 8,7,4) ;
|
||||
TS_ASSERT_EQUALS(a1, a2) ;
|
||||
|
||||
// !=
|
||||
Area a3(&b1, "My Area", 1,0,5, 8,7,4) ;
|
||||
TS_ASSERT_DIFFERS(a1, a3) ;
|
||||
|
||||
// =
|
||||
a2 = a3 ;
|
||||
TS_ASSERT_EQUALS(a2, a3) ;
|
||||
}
|
||||
|
||||
} ;
|
|
@ -0,0 +1,75 @@
|
|||
#include <cxxtest/TestSuite.h>
|
||||
|
||||
#include "building.hh"
|
||||
#include "waypoint.hh"
|
||||
#include "area.hh"
|
||||
|
||||
class Building_test: public CxxTest::TestSuite
|
||||
{
|
||||
public:
|
||||
|
||||
void test_constructors(void)
|
||||
{
|
||||
// Default constructor
|
||||
Building b1 ;
|
||||
Building b2("Unnamed building") ;
|
||||
TS_ASSERT_EQUALS(b1, b2) ;
|
||||
|
||||
// Copy constructor
|
||||
Building b3("My Enormous Building") ;
|
||||
Building b4(b3) ;
|
||||
TS_ASSERT_EQUALS(b3, b4) ;
|
||||
}
|
||||
|
||||
|
||||
void test_accessors(void)
|
||||
{
|
||||
// Simple read accessors
|
||||
Building b1 ;
|
||||
TS_ASSERT_EQUALS(b1.get_name(), "Unnamed building") ;
|
||||
std::vector<Area*> va1 ;
|
||||
TS_ASSERT_EQUALS(b1.get_areas(), va1) ;
|
||||
std::vector<Waypoint*> vwp1 ;
|
||||
TS_ASSERT_EQUALS(b1.get_waypoints(), vwp1) ;
|
||||
|
||||
// Write & read accessors
|
||||
Building b2("My Building") ;
|
||||
TS_ASSERT_EQUALS(b2.get_name(), "My Building") ;
|
||||
b2.set_name("My Second Building") ;
|
||||
TS_ASSERT_EQUALS(b2.get_name(), "My Second Building") ;
|
||||
|
||||
Waypoint *wp1 = new Waypoint(&b2, 43, 45, 909) ;
|
||||
Waypoint *wp2 = new Waypoint(&b2, 12, 78, 2) ;
|
||||
b2.add_waypoint(wp1) ;
|
||||
b2.add_waypoint(wp2) ;
|
||||
vwp1.push_back(wp1) ;
|
||||
vwp1.push_back(wp2) ;
|
||||
TS_ASSERT_EQUALS(b2.get_waypoints(), vwp1) ;
|
||||
|
||||
Area *a1 = new Area() ;
|
||||
Area *a2 = new Area() ;
|
||||
b2.add_area(a1) ;
|
||||
b2.add_area(a2) ;
|
||||
va1.push_back(a1) ;
|
||||
va1.push_back(a2) ;
|
||||
TS_ASSERT_EQUALS(b2.get_areas(), va1) ;
|
||||
}
|
||||
|
||||
|
||||
void test_operators(void)
|
||||
{
|
||||
// ==
|
||||
Building b1("Build") ;
|
||||
Building b2("Build") ;
|
||||
TS_ASSERT_EQUALS(b1, b2) ;
|
||||
|
||||
// !=
|
||||
Building b3("B2") ;
|
||||
TS_ASSERT_DIFFERS(b1, b3) ;
|
||||
|
||||
// =
|
||||
b2 = b3 ;
|
||||
TS_ASSERT_EQUALS(b2, b3) ;
|
||||
}
|
||||
|
||||
} ;
|
|
@ -0,0 +1,84 @@
|
|||
#include <cxxtest/TestSuite.h>
|
||||
|
||||
#include "calibrationmeasurement.hh"
|
||||
|
||||
class CalibrationMeasurement_test: public CxxTest::TestSuite
|
||||
{
|
||||
public:
|
||||
|
||||
void test_constructors(void)
|
||||
{
|
||||
// Default constructor
|
||||
CalibrationMeasurement cm00 ;
|
||||
std::vector<int> vi1 ;
|
||||
CalibrationMeasurement cm01(NULL, vi1, NULL) ;
|
||||
TS_ASSERT_EQUALS(cm00, cm01) ;
|
||||
|
||||
// Copy constructor
|
||||
AccessPoint ap1 ;
|
||||
ReferencePoint rp1 ;
|
||||
CalibrationMeasurement cm1(&ap1, vi1, &rp1) ;
|
||||
CalibrationMeasurement cm2(cm1) ;
|
||||
TS_ASSERT_EQUALS(cm1, cm2) ;
|
||||
|
||||
// Measurement copy constructor
|
||||
Measurement m1(&ap1, vi1) ;
|
||||
CalibrationMeasurement cm3(m1) ;
|
||||
TS_ASSERT_EQUALS(m1, cm3) ;
|
||||
}
|
||||
|
||||
|
||||
void test_accessors(void)
|
||||
{
|
||||
// Simple read accessors
|
||||
AccessPoint ap1 ;
|
||||
std::vector<int> vi1 ;
|
||||
CalibrationMeasurement cm1(&ap1, vi1) ;
|
||||
TS_ASSERT_EQUALS(cm1.get_ap(), &ap1) ;
|
||||
TS_ASSERT_EQUALS(cm1.get_ss_list(), vi1) ;
|
||||
TS_ASSERT_EQUALS(cm1.get_average_ss(), 0) ;
|
||||
|
||||
// Write & read accessors
|
||||
AccessPoint ap2 ;
|
||||
cm1.set_ap(&ap2) ;
|
||||
TS_ASSERT_EQUALS(cm1.get_ap(), &ap2) ;
|
||||
|
||||
cm1.add_ss(-33) ;
|
||||
cm1.add_ss(-78) ;
|
||||
cm1.add_ss(-21) ;
|
||||
vi1.push_back(-33) ;
|
||||
vi1.push_back(-78) ;
|
||||
vi1.push_back(-21) ;
|
||||
TS_ASSERT_EQUALS(cm1.get_ss_list(), vi1) ;
|
||||
|
||||
std::vector<int> vi2 ;
|
||||
vi1.push_back(-54) ;
|
||||
vi1.push_back(-1) ;
|
||||
cm1.set_ss_list(vi2) ;
|
||||
TS_ASSERT_EQUALS(cm1.get_ss_list(), vi2) ;
|
||||
|
||||
cm1.clear() ;
|
||||
CalibrationMeasurement cm2 ;
|
||||
TS_ASSERT_EQUALS(cm1, cm2) ;
|
||||
}
|
||||
|
||||
|
||||
void test_operators(void)
|
||||
{
|
||||
// ==
|
||||
AccessPoint ap1 ;
|
||||
CalibrationMeasurement cm1(&ap1) ;
|
||||
CalibrationMeasurement cm2(&ap1) ;
|
||||
TS_ASSERT_EQUALS(cm1, cm2) ;
|
||||
|
||||
// !=
|
||||
AccessPoint ap2 ;
|
||||
CalibrationMeasurement cm3(&ap2) ;
|
||||
TS_ASSERT_DIFFERS(cm1, cm3) ;
|
||||
|
||||
// =
|
||||
cm2 = cm3 ;
|
||||
TS_ASSERT_EQUALS(cm2, cm3) ;
|
||||
}
|
||||
|
||||
} ;
|
|
@ -0,0 +1,85 @@
|
|||
#include <cxxtest/TestSuite.h>
|
||||
|
||||
#include "measurement.hh"
|
||||
|
||||
class Measurement_test: public CxxTest::TestSuite
|
||||
{
|
||||
public:
|
||||
|
||||
void test_constructors(void)
|
||||
{
|
||||
// Default constructor
|
||||
Measurement m00 ;
|
||||
std::vector<int> vi1 ;
|
||||
Measurement m01(NULL, vi1) ;
|
||||
TS_ASSERT_EQUALS(m00, m01) ;
|
||||
|
||||
// Copy constructor
|
||||
AccessPoint ap1 ;
|
||||
Measurement m1(&ap1) ;
|
||||
Measurement m2(m1) ;
|
||||
TS_ASSERT_EQUALS(m1, m2) ;
|
||||
}
|
||||
|
||||
|
||||
void test_accessors(void)
|
||||
{
|
||||
// Simple read accessors
|
||||
AccessPoint ap1 ;
|
||||
std::vector<int> vi1 ;
|
||||
Measurement m1(&ap1, vi1) ;
|
||||
TS_ASSERT_EQUALS(m1.get_ap(), &ap1) ;
|
||||
TS_ASSERT_EQUALS(m1.get_ss_list(), vi1) ;
|
||||
TS_ASSERT_EQUALS(m1.get_average_ss(), 0) ;
|
||||
|
||||
// Write & read accessors
|
||||
AccessPoint ap2 ;
|
||||
m1.set_ap(&ap2) ;
|
||||
TS_ASSERT_EQUALS(m1.get_ap(), &ap2) ;
|
||||
|
||||
m1.add_ss(-33) ;
|
||||
m1.add_ss(-78) ;
|
||||
m1.add_ss(-21) ;
|
||||
vi1.push_back(-33) ;
|
||||
vi1.push_back(-78) ;
|
||||
vi1.push_back(-21) ;
|
||||
TS_ASSERT_EQUALS(m1.get_ss_list(), vi1) ;
|
||||
TS_WARN("TODO: Test average SS.") ;
|
||||
|
||||
std::vector<int> vi2 ;
|
||||
vi1.push_back(-54) ;
|
||||
vi1.push_back(-1) ;
|
||||
m1.set_ss_list(vi2) ;
|
||||
TS_ASSERT_EQUALS(m1.get_ss_list(), vi2) ;
|
||||
TS_WARN("TODO: Test average SS.") ;
|
||||
|
||||
m1.clear() ;
|
||||
Measurement m2 ;
|
||||
TS_ASSERT_EQUALS(m1, m2) ;
|
||||
}
|
||||
|
||||
|
||||
void test_operators(void)
|
||||
{
|
||||
// ==
|
||||
AccessPoint ap1 ;
|
||||
Measurement m1(&ap1) ;
|
||||
Measurement m2(&ap1) ;
|
||||
TS_ASSERT_EQUALS(m1, m2) ;
|
||||
|
||||
// !=
|
||||
AccessPoint ap2 ;
|
||||
Measurement m3(&ap2) ;
|
||||
TS_ASSERT_DIFFERS(m1, m3) ;
|
||||
|
||||
// =
|
||||
m2 = m3 ;
|
||||
TS_ASSERT_EQUALS(m2, m3) ;
|
||||
|
||||
// bool
|
||||
TS_ASSERT(m1) ;
|
||||
Measurement m4 ;
|
||||
TS_ASSERT(! m4) ;
|
||||
}
|
||||
|
||||
} ;
|
|
@ -0,0 +1,62 @@
|
|||
#include <cxxtest/TestSuite.h>
|
||||
|
||||
#include "mobile.hh"
|
||||
|
||||
class Mobile_test: public CxxTest::TestSuite
|
||||
{
|
||||
public:
|
||||
|
||||
void test_constructors(void)
|
||||
{
|
||||
// Default constructor
|
||||
Mobile mobile1 ;
|
||||
Mobile mobile2("", "",
|
||||
MOBILE_DEFAULT_ANTENNA_GAIN,
|
||||
WIFIDEVICE_DEFAULT_TRX_POWER) ;
|
||||
TS_ASSERT_EQUALS(mobile1, mobile2) ;
|
||||
|
||||
// Copy constructor
|
||||
Mobile mobile3("192.168.0.1", "aa:bb:cc:dd:ee:ff", 5, 32) ;
|
||||
Mobile mobile4(mobile3) ;
|
||||
TS_ASSERT_EQUALS(mobile3, mobile4) ;
|
||||
}
|
||||
|
||||
|
||||
void test_accessors(void)
|
||||
{
|
||||
// Simple read accessors
|
||||
Mobile mobile1("192.168.0.1", "aa:bb:cc:dd:ee:ff", 6, 38) ;
|
||||
TS_ASSERT_EQUALS(mobile1.get_ip_addr(), "192.168.0.1") ;
|
||||
TS_ASSERT_EQUALS(mobile1.get_mac_addr(), "aa:bb:cc:dd:ee:ff") ;
|
||||
TS_ASSERT_EQUALS(mobile1.get_antenna_gain(), 6) ;
|
||||
TS_ASSERT_EQUALS(mobile1.get_trx_power(), 38) ;
|
||||
|
||||
// Write & read accessors
|
||||
mobile1.set_ip_addr("10.0.8.42") ;
|
||||
TS_ASSERT_EQUALS(mobile1.get_ip_addr(), "10.0.8.42") ;
|
||||
mobile1.set_mac_addr("00:11:22:33:44:55") ;
|
||||
TS_ASSERT_EQUALS(mobile1.get_mac_addr(), "00:11:22:33:44:55") ;
|
||||
mobile1.set_antenna_gain(12.4) ;
|
||||
TS_ASSERT_DELTA(mobile1.get_antenna_gain(), 12.4, 0.00001) ;
|
||||
mobile1.set_trx_power(22.7) ;
|
||||
TS_ASSERT_DELTA(mobile1.get_trx_power(), 22.7, 0.00001) ;
|
||||
}
|
||||
|
||||
|
||||
void test_operators(void)
|
||||
{
|
||||
// ==
|
||||
Mobile mobile1("192.168.0.1", "aa:bb:cc:dd:ee:ff", 6, 38) ;
|
||||
Mobile mobile2("192.168.0.1", "aa:bb:cc:dd:ee:ff", 6, 38) ;
|
||||
TS_ASSERT_EQUALS(mobile1, mobile2) ;
|
||||
|
||||
// !=
|
||||
Mobile mobile3("192.168.0.2", "aa:bb:cc:dd:ee:aa", 6, 38) ;
|
||||
TS_ASSERT_DIFFERS(mobile2, mobile3) ;
|
||||
|
||||
// =
|
||||
mobile2 = mobile3 ;
|
||||
TS_ASSERT_EQUALS(mobile2, mobile3) ;
|
||||
}
|
||||
|
||||
} ;
|
|
@ -0,0 +1,89 @@
|
|||
#include <cxxtest/TestSuite.h>
|
||||
|
||||
#include "point3d.hh"
|
||||
|
||||
class Point3D_test: public CxxTest::TestSuite
|
||||
{
|
||||
public:
|
||||
|
||||
void test_constructors(void)
|
||||
{
|
||||
// Default constructor
|
||||
Point3D p00 ;
|
||||
Point3D p01(0, 0, 0) ;
|
||||
TS_ASSERT_EQUALS(p00, p01) ;
|
||||
|
||||
// Copy constructor
|
||||
Point3D p1(1, 2, 3) ;
|
||||
Point3D p2(p1) ;
|
||||
TS_ASSERT_EQUALS(p1, p2) ;
|
||||
|
||||
// 3-float array constructor
|
||||
float coord[3] = {1, 2, 3} ;
|
||||
Point3D p3(coord) ;
|
||||
TS_ASSERT_EQUALS(p1, p3) ;
|
||||
}
|
||||
|
||||
|
||||
void test_accessors(void)
|
||||
{
|
||||
// Simple read accessors
|
||||
Point3D p1(1, 3, 5) ;
|
||||
TS_ASSERT_EQUALS(p1.get_x(), 1) ;
|
||||
TS_ASSERT_EQUALS(p1.get_y(), 3) ;
|
||||
TS_ASSERT_EQUALS(p1.get_z(), 5) ;
|
||||
|
||||
// Write & read accessors
|
||||
p1.set_x(42) ;
|
||||
TS_ASSERT_EQUALS(p1.get_x(), 42) ;
|
||||
p1.set_y(321) ;
|
||||
TS_ASSERT_EQUALS(p1.get_y(), 321) ;
|
||||
p1.set_z(98) ;
|
||||
TS_ASSERT_EQUALS(p1.get_z(), 98) ;
|
||||
}
|
||||
|
||||
|
||||
void test_distances(void)
|
||||
{
|
||||
Point3D p1(0, 0, 0) ;
|
||||
Point3D p2(1, 0, 0) ;
|
||||
TS_ASSERT_EQUALS(p1.distance(p2), 1) ;
|
||||
TS_ASSERT_EQUALS(p1.square_distance(p2), 1) ;
|
||||
|
||||
Point3D p3(0, 2, 0) ;
|
||||
TS_ASSERT_EQUALS(p1.distance(p3), 2) ;
|
||||
TS_ASSERT_EQUALS(p1.square_distance(p3), 4) ;
|
||||
|
||||
TS_WARN("TODO: some more complex tests.") ;
|
||||
}
|
||||
|
||||
|
||||
void test_operators(void)
|
||||
{
|
||||
// ==
|
||||
Point3D p1(42, 21, 19) ;
|
||||
Point3D p2(42, 21, 19) ;
|
||||
TS_ASSERT_EQUALS(p1, p2) ;
|
||||
|
||||
// !=
|
||||
Point3D p3(1, 4, 7) ;
|
||||
TS_ASSERT_DIFFERS(p1, p3) ;
|
||||
|
||||
// =
|
||||
p2 = p3 ;
|
||||
TS_ASSERT_EQUALS(p2, p3) ;
|
||||
|
||||
// <
|
||||
TS_ASSERT_LESS_THAN(p2, p1) ;
|
||||
|
||||
// <=
|
||||
TS_ASSERT_LESS_THAN_EQUALS(p2, p1) ;
|
||||
|
||||
// >
|
||||
TS_ASSERT(p1 > p2) ;
|
||||
|
||||
// >=
|
||||
TS_ASSERT(p1 >= p2) ;
|
||||
}
|
||||
|
||||
} ;
|
|
@ -0,0 +1,67 @@
|
|||
#include <cxxtest/TestSuite.h>
|
||||
|
||||
#include "posutil.hh"
|
||||
|
||||
class PosUtil_test: public CxxTest::TestSuite
|
||||
{
|
||||
public:
|
||||
|
||||
void test_wifi(void)
|
||||
{
|
||||
// Bad values
|
||||
TS_ASSERT_EQUALS(PosUtil::channel_to_frequency(0),
|
||||
static_cast<unsigned int>(0)) ;
|
||||
TS_ASSERT_EQUALS(PosUtil::channel_to_frequency(15),
|
||||
static_cast<unsigned int>(0)) ;
|
||||
|
||||
// Good values
|
||||
for (unsigned int i = 1 ; i < 15 ; ++i)
|
||||
TS_ASSERT(PosUtil::channel_to_frequency(i) >= 2412 &&
|
||||
PosUtil::channel_to_frequency(i) <= 2477) ;
|
||||
}
|
||||
|
||||
void test_time(void)
|
||||
{
|
||||
// Zero tests
|
||||
struct timespec ts1 ;
|
||||
ts1.tv_sec = 0 ;
|
||||
ts1.tv_nsec = 0 ;
|
||||
uint64_t msec = 0 ; // ms time value
|
||||
struct timespec ts2 = PosUtil::ms_to_timespec(msec) ;
|
||||
TS_ASSERT(PosUtil::timespec_equals(ts1, ts2)) ;
|
||||
TS_ASSERT_EQUALS(PosUtil::timespec_to_ms(ts1), msec) ;
|
||||
|
||||
// Non-zero tests
|
||||
uint64_t sec = 1234567 ;
|
||||
uint64_t nsec = 891234567 ; // Do not put a value >= 1 sec. for the test!
|
||||
ts1.tv_sec = sec ;
|
||||
ts1.tv_nsec = nsec ;
|
||||
msec = sec * 1000 + nsec / 1000000 ;
|
||||
TS_ASSERT_EQUALS(PosUtil::timespec_to_ms(ts1), msec) ;
|
||||
ts2 = PosUtil::ms_to_timespec(msec) ;
|
||||
TS_ASSERT_EQUALS(PosUtil::timespec_to_ms(ts2), msec) ;
|
||||
|
||||
// timespec_round_to_ms()
|
||||
struct timespec ts3 = ts1 ;
|
||||
PosUtil::timespec_round_to_ms(ts1) ;
|
||||
TS_ASSERT_EQUALS(ts1.tv_sec, ts3.tv_sec) ;
|
||||
TS_ASSERT_EQUALS(ts1.tv_nsec, ts3.tv_nsec / 1000000 * 1000000) ;
|
||||
TS_ASSERT(PosUtil::timespec_equals(ts1, ts2)) ;
|
||||
|
||||
// Current time test
|
||||
struct timespec current_time ;
|
||||
if (clock_gettime(CLOCK_REALTIME, ¤t_time))
|
||||
TS_FAIL("Error calling clock_gettime()!") ;
|
||||
else
|
||||
{
|
||||
ts1 = current_time ;
|
||||
PosUtil::timespec_round_to_ms(current_time) ;
|
||||
TS_ASSERT(! PosUtil::timespec_equals(current_time, ts1)) ;
|
||||
msec = PosUtil::timespec_to_ms(current_time) ;
|
||||
ts2 = PosUtil::ms_to_timespec(msec) ;
|
||||
TS_ASSERT_EQUALS(PosUtil::timespec_to_ms(ts2), msec) ;
|
||||
TS_ASSERT(PosUtil::timespec_equals(current_time, ts2)) ;
|
||||
}
|
||||
}
|
||||
|
||||
} ;
|
|
@ -0,0 +1,89 @@
|
|||
#include <cxxtest/TestSuite.h>
|
||||
|
||||
#include "referencepoint.hh"
|
||||
#include "calibrationmeasurement.hh"
|
||||
|
||||
class ReferencePoint_test: public CxxTest::TestSuite
|
||||
{
|
||||
public:
|
||||
|
||||
void test_constructors(void)
|
||||
{
|
||||
// Default constructor
|
||||
ReferencePoint rp00 ;
|
||||
ReferencePoint rp01(0, 0, 0) ;
|
||||
TS_ASSERT_EQUALS(rp00, rp01) ;
|
||||
|
||||
// Copy constructor
|
||||
ReferencePoint rp1(1, 2, 3) ;
|
||||
ReferencePoint rp2(rp1) ;
|
||||
TS_ASSERT_EQUALS(rp1, rp2) ;
|
||||
|
||||
// Point3D copy constructor
|
||||
Point3D p0(5, 3, 8) ;
|
||||
ReferencePoint rp4(p0) ;
|
||||
TS_ASSERT_EQUALS(p0, rp4) ;
|
||||
|
||||
// 3-float array constructor
|
||||
float coord[3] = {1, 2, 3} ;
|
||||
ReferencePoint rp3(coord) ;
|
||||
TS_ASSERT_EQUALS(rp1, rp3) ;
|
||||
}
|
||||
|
||||
|
||||
void test_accessors(void)
|
||||
{
|
||||
// Simple read accessors
|
||||
ReferencePoint rp1(1, 3, 5) ;
|
||||
TS_ASSERT_EQUALS(rp1.get_x(), 1) ;
|
||||
TS_ASSERT_EQUALS(rp1.get_y(), 3) ;
|
||||
TS_ASSERT_EQUALS(rp1.get_z(), 5) ;
|
||||
|
||||
// Write & read accessors
|
||||
CalibrationMeasurement cm1, cm2, cm3 ;
|
||||
rp1.add_measurement(&cm1) ;
|
||||
rp1.add_measurement(&cm2) ;
|
||||
rp1.add_measurement(&cm3) ;
|
||||
std::vector<CalibrationMeasurement*> vcm1 ;
|
||||
vcm1.push_back(&cm1) ;
|
||||
vcm1.push_back(&cm2) ;
|
||||
vcm1.push_back(&cm3) ;
|
||||
TS_ASSERT_EQUALS(rp1.get_measurements(), vcm1) ;
|
||||
rp1.set_x(42) ;
|
||||
TS_ASSERT_EQUALS(rp1.get_x(), 42) ;
|
||||
rp1.set_y(321) ;
|
||||
TS_ASSERT_EQUALS(rp1.get_y(), 321) ;
|
||||
rp1.set_z(98) ;
|
||||
TS_ASSERT_EQUALS(rp1.get_z(), 98) ;
|
||||
}
|
||||
|
||||
|
||||
void test_operators(void)
|
||||
{
|
||||
// ==
|
||||
ReferencePoint rp1(42, 21, 19) ;
|
||||
ReferencePoint rp2(42, 21, 19) ;
|
||||
TS_ASSERT_EQUALS(rp1, rp2) ;
|
||||
|
||||
// !=
|
||||
ReferencePoint rp3(1, 4, 7) ;
|
||||
TS_ASSERT_DIFFERS(rp1, rp3) ;
|
||||
|
||||
// =
|
||||
rp2 = rp3 ;
|
||||
TS_ASSERT_EQUALS(rp2, rp3) ;
|
||||
|
||||
// <
|
||||
TS_ASSERT_LESS_THAN(rp2, rp1) ;
|
||||
|
||||
// <=
|
||||
TS_ASSERT_LESS_THAN_EQUALS(rp2, rp1) ;
|
||||
|
||||
// >
|
||||
TS_ASSERT(rp1 > rp2) ;
|
||||
|
||||
// >=
|
||||
TS_ASSERT(rp1 >= rp2) ;
|
||||
}
|
||||
|
||||
} ;
|
|
@ -0,0 +1,100 @@
|
|||
#include <cxxtest/TestSuite.h>
|
||||
|
||||
#include "request.hh"
|
||||
#include "mobile.hh"
|
||||
|
||||
class Request_test: public CxxTest::TestSuite
|
||||
{
|
||||
public:
|
||||
|
||||
void test_constructors(void)
|
||||
{
|
||||
// Default constructor
|
||||
Request r1 ;
|
||||
std::tr1::unordered_map<std::string, Measurement> measurements ;
|
||||
Request r2(measurements) ;
|
||||
TS_ASSERT_EQUALS(r1, r2) ;
|
||||
|
||||
// Copy constructor
|
||||
struct timespec current_time ;
|
||||
Measurement meas1 ;
|
||||
measurements["aa:bb:cc:dd:ee:ff"] = meas1 ;
|
||||
clock_gettime(CLOCK_REALTIME, ¤t_time) ;
|
||||
Mobile mob1 ;
|
||||
Request r3(&mob1, current_time, measurements) ;
|
||||
Request r4(r3) ;
|
||||
TS_ASSERT_EQUALS(r3, r4) ;
|
||||
}
|
||||
|
||||
|
||||
void test_accessors(void)
|
||||
{
|
||||
// Simple read accessors
|
||||
struct timespec current_time ;
|
||||
AccessPoint ap1(Point3D(1,2,3), "192.168.0.1", "aa:bb:cc:dd:ee:ff") ;
|
||||
Measurement meas1(&ap1) ;
|
||||
std::tr1::unordered_map<std::string, Measurement> measurements ;
|
||||
measurements["aa:bb:cc:dd:ee:ff"] = meas1 ;
|
||||
clock_gettime(CLOCK_REALTIME, ¤t_time) ;
|
||||
Mobile mob1 ;
|
||||
Request r1(&mob1, current_time, measurements) ;
|
||||
TS_ASSERT_EQUALS(r1.get_mobile(), &mob1) ;
|
||||
TS_ASSERT(PosUtil::timespec_equals(r1.get_timestamp(), current_time)) ;
|
||||
//TS_ASSERT_EQUALS(r1.get_measurements(), measurements) ;
|
||||
|
||||
// Write & read accessors
|
||||
Mobile mob2 ;
|
||||
r1.set_mobile(&mob2) ;
|
||||
TS_ASSERT_EQUALS(r1.get_mobile(), &mob2) ;
|
||||
|
||||
current_time.tv_sec += 10 ;
|
||||
r1.set_timestamp(current_time) ;
|
||||
TS_ASSERT(PosUtil::timespec_equals(r1.get_timestamp(), current_time)) ;
|
||||
|
||||
AccessPoint 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 ;
|
||||
r1.set_measurements(measurements) ;
|
||||
//TS_ASSERT_EQUALS(r1.get_measurements(), measurements) ;
|
||||
|
||||
// clear()
|
||||
r1.clear() ;
|
||||
Request r2 ;
|
||||
TS_ASSERT_EQUALS(r1, r2) ;
|
||||
}
|
||||
|
||||
|
||||
void test_operators(void)
|
||||
{
|
||||
// ==
|
||||
struct timespec current_time ;
|
||||
std::tr1::unordered_map<std::string, Measurement> measurements ;
|
||||
Measurement meas1 ;
|
||||
measurements["aa:bb:cc:dd:ee:00"] = meas1 ;
|
||||
clock_gettime(CLOCK_REALTIME, ¤t_time) ;
|
||||
Request r1(current_time, measurements) ;
|
||||
Request r2(current_time, measurements) ;
|
||||
TS_ASSERT_EQUALS(r1, r2) ;
|
||||
|
||||
Mobile mob1 ;
|
||||
Request r3(&mob1, current_time, measurements) ;
|
||||
Request r4(&mob1, current_time, measurements) ;
|
||||
TS_ASSERT_EQUALS(r3, r4) ;
|
||||
|
||||
// !=
|
||||
Measurement meas2 ;
|
||||
measurements["aa:bb:cc:dd:ee:01"] = meas2 ;
|
||||
Request r5(&mob1, current_time, measurements) ;
|
||||
TS_ASSERT_DIFFERS(r4, r5) ;
|
||||
|
||||
// =
|
||||
r2 = r3 ;
|
||||
TS_ASSERT_EQUALS(r2, r3) ;
|
||||
|
||||
// bool
|
||||
TS_ASSERT(r5) ;
|
||||
Request r6 ;
|
||||
TS_ASSERT(! r6) ;
|
||||
}
|
||||
|
||||
} ;
|
|
@ -0,0 +1,36 @@
|
|||
#include <cxxtest/TestSuite.h>
|
||||
|
||||
#include "stock.hh"
|
||||
|
||||
class Stock_test: public CxxTest::TestSuite
|
||||
{
|
||||
public:
|
||||
|
||||
void test_accessors(void)
|
||||
{
|
||||
// Non-existing elements
|
||||
TS_ASSERT_THROWS(Stock::get_mobile("aa:bb:cc:dd:ee:ff"),
|
||||
std::out_of_range) ;
|
||||
TS_ASSERT_THROWS(Stock::get_ap("aa:bb:cc:dd:ee:ff"),
|
||||
std::out_of_range) ;
|
||||
|
||||
// Creation of empty elements
|
||||
Mobile m1 ;
|
||||
AccessPoint ap1 ;
|
||||
TS_ASSERT_EQUALS(Stock::getw_mobile("00:00:00:00:01:01"), m1) ;
|
||||
TS_ASSERT_EQUALS(Stock::getw_ap("00:00:00:00:02:01"), ap1) ;
|
||||
|
||||
// Creation of elements and access
|
||||
Mobile m2("192.168.1.1", "00:00:00:00:01:02", 1.5, 20) ;
|
||||
Stock::getw_mobile("00:00:00:00:01:02") = m2 ;
|
||||
TS_ASSERT_EQUALS(Stock::get_mobile("00:00:00:00:01:02"), m2) ;
|
||||
TS_ASSERT_EQUALS(Stock::getw_mobile("00:00:00:00:01:02"), m2) ;
|
||||
|
||||
AccessPoint ap2(Point3D(1,2,3), "192.168.2.1", "00:00:00:00:02:02",
|
||||
8.5, 2.1, 11) ;
|
||||
Stock::getw_ap("00:00:00:00:02:02") = ap2 ;
|
||||
TS_ASSERT_EQUALS(Stock::get_ap("00:00:00:00:02:02"), ap2) ;
|
||||
TS_ASSERT_EQUALS(Stock::getw_ap("00:00:00:00:02:02"), ap2) ;
|
||||
}
|
||||
|
||||
} ;
|
|
@ -0,0 +1,91 @@
|
|||
#include <cxxtest/TestSuite.h>
|
||||
|
||||
#include "waypoint.hh"
|
||||
#include "building.hh"
|
||||
|
||||
class Waypoint_test: public CxxTest::TestSuite
|
||||
{
|
||||
public:
|
||||
|
||||
void test_constructors(void)
|
||||
{
|
||||
// Default constructor
|
||||
Waypoint wp00 ;
|
||||
Waypoint wp01(NULL, 0, 0, 0) ;
|
||||
TS_ASSERT_EQUALS(wp00, wp01) ;
|
||||
|
||||
// Copy constructor
|
||||
Building b1("My Building") ;
|
||||
Waypoint wp1(&b1, 1, 2, 3) ;
|
||||
Waypoint wp2(wp1) ;
|
||||
TS_ASSERT_EQUALS(wp1, wp2) ;
|
||||
|
||||
// Point3D copy constructor
|
||||
Point3D p0(5, 3, 8) ;
|
||||
Waypoint wp4(p0) ;
|
||||
TS_ASSERT_EQUALS(p0, wp4) ;
|
||||
Waypoint wp5(NULL, p0) ;
|
||||
TS_ASSERT_EQUALS(wp4, wp5) ;
|
||||
|
||||
// 3-float array constructor
|
||||
float coord[3] = {5, 3, 8} ;
|
||||
Waypoint wp3(coord) ;
|
||||
TS_ASSERT_EQUALS(wp3, wp4) ;
|
||||
}
|
||||
|
||||
|
||||
void test_accessors(void)
|
||||
{
|
||||
// Simple read accessors
|
||||
Building b1("My Building") ;
|
||||
Waypoint wp1(&b1, 1, 3, 5) ;
|
||||
TS_ASSERT_EQUALS(wp1.get_1st_building(), &b1) ;
|
||||
TS_ASSERT_EQUALS(wp1.get_x(), 1) ;
|
||||
TS_ASSERT_EQUALS(wp1.get_y(), 3) ;
|
||||
TS_ASSERT_EQUALS(wp1.get_z(), 5) ;
|
||||
|
||||
// Write & read accessors
|
||||
Building b2("My Second Building") ;
|
||||
wp1.add_building(&b2) ;
|
||||
std::vector<Building*> vb1 ;
|
||||
vb1.push_back(&b1) ;
|
||||
vb1.push_back(&b2) ;
|
||||
TS_ASSERT_EQUALS(wp1.get_buildings(), vb1) ;
|
||||
wp1.set_x(42) ;
|
||||
TS_ASSERT_EQUALS(wp1.get_x(), 42) ;
|
||||
wp1.set_y(321) ;
|
||||
TS_ASSERT_EQUALS(wp1.get_y(), 321) ;
|
||||
wp1.set_z(98) ;
|
||||
TS_ASSERT_EQUALS(wp1.get_z(), 98) ;
|
||||
}
|
||||
|
||||
|
||||
void test_operators(void)
|
||||
{
|
||||
// ==
|
||||
Waypoint wp1(NULL, 42, 21, 19) ;
|
||||
Waypoint wp2(NULL, 42, 21, 19) ;
|
||||
TS_ASSERT_EQUALS(wp1, wp2) ;
|
||||
|
||||
// !=
|
||||
Waypoint wp3(NULL, 1, 4, 7) ;
|
||||
TS_ASSERT_DIFFERS(wp1, wp3) ;
|
||||
|
||||
// =
|
||||
wp2 = wp3 ;
|
||||
TS_ASSERT_EQUALS(wp2, wp3) ;
|
||||
|
||||
// <
|
||||
TS_ASSERT_LESS_THAN(wp2, wp1) ;
|
||||
|
||||
// <=
|
||||
TS_ASSERT_LESS_THAN_EQUALS(wp2, wp1) ;
|
||||
|
||||
// >
|
||||
TS_ASSERT(wp1 > wp2) ;
|
||||
|
||||
// >=
|
||||
TS_ASSERT(wp1 >= wp2) ;
|
||||
}
|
||||
|
||||
} ;
|
|
@ -0,0 +1,61 @@
|
|||
#include <cxxtest/TestSuite.h>
|
||||
|
||||
#include "wifidevice.hh"
|
||||
|
||||
class WifiDevice_test: public CxxTest::TestSuite
|
||||
{
|
||||
public:
|
||||
|
||||
void test_constructors(void)
|
||||
{
|
||||
// Default constructor
|
||||
WifiDevice wifidevice1 ;
|
||||
WifiDevice wifidevice2("", "", WIFIDEVICE_DEFAULT_ANTENNA_GAIN,
|
||||
WIFIDEVICE_DEFAULT_TRX_POWER) ;
|
||||
TS_ASSERT_EQUALS(wifidevice1, wifidevice2) ;
|
||||
|
||||
// Copy constructor
|
||||
WifiDevice wifidevice3("192.168.0.1", "aa:bb:cc:dd:ee:ff", 5, 32) ;
|
||||
WifiDevice wifidevice4(wifidevice3) ;
|
||||
TS_ASSERT_EQUALS(wifidevice3, wifidevice4) ;
|
||||
}
|
||||
|
||||
|
||||
void test_accessors(void)
|
||||
{
|
||||
// Simple read accessors
|
||||
WifiDevice wifidevice1("192.168.0.1", "aa:bb:cc:dd:ee:ff", 6, 38) ;
|
||||
TS_ASSERT_EQUALS(wifidevice1.get_ip_addr(), "192.168.0.1") ;
|
||||
TS_ASSERT_EQUALS(wifidevice1.get_mac_addr(), "aa:bb:cc:dd:ee:ff") ;
|
||||
TS_ASSERT_EQUALS(wifidevice1.get_antenna_gain(), 6) ;
|
||||
TS_ASSERT_EQUALS(wifidevice1.get_trx_power(), 38) ;
|
||||
|
||||
// Write & read accessors
|
||||
wifidevice1.set_ip_addr("10.0.8.42") ;
|
||||
TS_ASSERT_EQUALS(wifidevice1.get_ip_addr(), "10.0.8.42") ;
|
||||
wifidevice1.set_mac_addr("00:11:22:33:44:55") ;
|
||||
TS_ASSERT_EQUALS(wifidevice1.get_mac_addr(), "00:11:22:33:44:55") ;
|
||||
wifidevice1.set_antenna_gain(12.4) ;
|
||||
TS_ASSERT_DELTA(wifidevice1.get_antenna_gain(), 12.4, 0.00001) ;
|
||||
wifidevice1.set_trx_power(22.7) ;
|
||||
TS_ASSERT_DELTA(wifidevice1.get_trx_power(), 22.7, 0.00001) ;
|
||||
}
|
||||
|
||||
|
||||
void test_operators(void)
|
||||
{
|
||||
// ==
|
||||
WifiDevice wifidevice1("192.168.0.1", "aa:bb:cc:dd:ee:ff", 6, 38) ;
|
||||
WifiDevice wifidevice2("192.168.0.1", "aa:bb:cc:dd:ee:ff", 6, 38) ;
|
||||
TS_ASSERT_EQUALS(wifidevice1, wifidevice2) ;
|
||||
|
||||
// !=
|
||||
WifiDevice wifidevice3("192.168.0.2", "aa:bb:cc:dd:ee:aa", 6, 38) ;
|
||||
TS_ASSERT_DIFFERS(wifidevice2, wifidevice3) ;
|
||||
|
||||
// =
|
||||
wifidevice2 = wifidevice3 ;
|
||||
TS_ASSERT_EQUALS(wifidevice2, wifidevice3) ;
|
||||
}
|
||||
|
||||
} ;
|
Loading…
Reference in New Issue