85 lines
2.9 KiB
C++
85 lines
2.9 KiB
C++
#include <cxxtest/TestSuite.h>
|
|
|
|
#include "capturepoint.hh"
|
|
|
|
class CapturePoint_test: public CxxTest::TestSuite
|
|
{
|
|
public:
|
|
|
|
void test_constructors(void)
|
|
{
|
|
// Default constructor
|
|
CapturePoint capturepoint1 ;
|
|
CapturePoint capturepoint2(Point3D(), "", "",
|
|
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) ;
|
|
CapturePoint capturepoint4(capturepoint3) ;
|
|
TS_ASSERT_EQUALS(capturepoint3, capturepoint4) ;
|
|
}
|
|
|
|
|
|
void test_accessors(void)
|
|
{
|
|
// Simple read accessors
|
|
Point3D point3d1(78,23,4) ;
|
|
CapturePoint capturepoint1(point3d1, "192.168.0.1",
|
|
"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") ;
|
|
TS_ASSERT_EQUALS(capturepoint1.get_antenna_gain(), 6) ;
|
|
TS_ASSERT_EQUALS(capturepoint1.get_trx_power(), 38) ;
|
|
TS_ASSERT_EQUALS(capturepoint1.get_frequency(),
|
|
PosUtil::wifi_channel_to_hz(10)) ;
|
|
|
|
// Write & read accessors
|
|
Point3D point3d2(78,23,4) ;
|
|
capturepoint1.set_coordinates(point3d2) ;
|
|
TS_ASSERT_EQUALS(capturepoint1.get_coordinates(), point3d2) ;
|
|
capturepoint1.set_ip_addr("10.0.8.42") ;
|
|
TS_ASSERT_EQUALS(capturepoint1.get_ip_addr(), "10.0.8.42") ;
|
|
capturepoint1.set_mac_addr("00:11:22:33:44:55") ;
|
|
TS_ASSERT_EQUALS(capturepoint1.get_mac_addr(), "00:11:22:33:44:55") ;
|
|
capturepoint1.set_antenna_gain(12.4) ;
|
|
TS_ASSERT_DELTA(capturepoint1.get_antenna_gain(), 12.4, 0.00001) ;
|
|
capturepoint1.set_trx_power(22.7) ;
|
|
TS_ASSERT_DELTA(capturepoint1.get_trx_power(), 22.7, 0.00001) ;
|
|
capturepoint1.set_channel(13) ;
|
|
TS_ASSERT_EQUALS(capturepoint1.get_frequency(),
|
|
PosUtil::wifi_channel_to_hz(13)) ;
|
|
capturepoint1.set_frequency(2423) ;
|
|
TS_ASSERT_EQUALS(capturepoint1.get_frequency(), 2423u) ;
|
|
}
|
|
|
|
|
|
void test_operators(void)
|
|
{
|
|
// ==
|
|
Point3D point3d1(78,23,4) ;
|
|
CapturePoint capturepoint1(point3d1, "192.168.0.1",
|
|
"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) ;
|
|
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) ;
|
|
TS_ASSERT(capturepoint2 != capturepoint3) ;
|
|
|
|
// =
|
|
capturepoint2 = capturepoint3 ;
|
|
TS_ASSERT_EQUALS(capturepoint2, capturepoint3) ;
|
|
}
|
|
|
|
} ;
|