From 4a534755db7dc511ab2d6b9672747f04f81bf4a0 Mon Sep 17 00:00:00 2001 From: Matteo Cypriani Date: Sat, 15 Jun 2013 21:02:40 -0400 Subject: [PATCH] [Positioner] tests: AccessPoint -> CapturePoint --- owlps-positioner/tests/accesspoint_test.hh | 82 ------------------- owlps-positioner/tests/capturepoint_test.hh | 82 +++++++++++++++++++ owlps-positioner/tests/inputcsv_test.hh | 8 +- .../tests/interlinknetworks_test.hh | 2 +- owlps-positioner/tests/measurement_test.hh | 16 ++-- owlps-positioner/tests/minmax_test.hh | 4 +- owlps-positioner/tests/referencepoint_test.hh | 2 +- owlps-positioner/tests/request_test.hh | 4 +- owlps-positioner/tests/stock_test.hh | 24 +++--- owlps-positioner/tests/testutil.cc | 32 ++++---- owlps-positioner/tests/testutil.hh | 6 +- 11 files changed, 131 insertions(+), 131 deletions(-) delete mode 100644 owlps-positioner/tests/accesspoint_test.hh create mode 100644 owlps-positioner/tests/capturepoint_test.hh diff --git a/owlps-positioner/tests/accesspoint_test.hh b/owlps-positioner/tests/accesspoint_test.hh deleted file mode 100644 index fdc55ff..0000000 --- a/owlps-positioner/tests/accesspoint_test.hh +++ /dev/null @@ -1,82 +0,0 @@ -#include - -#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::wifi_channel_to_hz(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::wifi_channel_to_hz(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(accesspoint2 != accesspoint3) ; - - // = - accesspoint2 = accesspoint3 ; - TS_ASSERT_EQUALS(accesspoint2, accesspoint3) ; - } - -} ; diff --git a/owlps-positioner/tests/capturepoint_test.hh b/owlps-positioner/tests/capturepoint_test.hh new file mode 100644 index 0000000..a3828b7 --- /dev/null +++ b/owlps-positioner/tests/capturepoint_test.hh @@ -0,0 +1,82 @@ +#include + +#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) ; + + // 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) ; + } + +} ; diff --git a/owlps-positioner/tests/inputcsv_test.hh b/owlps-positioner/tests/inputcsv_test.hh index e2295c0..7fa1763 100644 --- a/owlps-positioner/tests/inputcsv_test.hh +++ b/owlps-positioner/tests/inputcsv_test.hh @@ -11,7 +11,7 @@ class InputCSV_test: public CxxTest::TestSuite { private: std::string csv_file_name ; // Test CSV file name - std::vector aps ; // List of test AccessPoint + std::vector aps ; // List of test CapturePoint public: @@ -72,7 +72,7 @@ public: TS_ASSERT_EQUALS(request1.get_time_sent(), TestUtil::requests.at(0)->get_time_sent()) ; - for (std::vector::const_iterator i = TestUtil::aps.begin() ; + for (std::vector::const_iterator i = TestUtil::aps.begin() ; i != TestUtil::aps.end() ; ++i) { std::unordered_map::const_iterator @@ -97,7 +97,7 @@ public: TS_ASSERT_EQUALS(request1.get_time_sent(), TestUtil::requests.at(1)->get_time_sent()) ; - for (std::vector::const_iterator i = TestUtil::aps.begin() ; + for (std::vector::const_iterator i = TestUtil::aps.begin() ; i != TestUtil::aps.end() ; ++i) { std::unordered_map::const_iterator @@ -122,7 +122,7 @@ public: TS_ASSERT_EQUALS(request1.get_time_sent(), TestUtil::requests.at(2)->get_time_sent()) ; - for (std::vector::const_iterator i = TestUtil::aps.begin() ; + for (std::vector::const_iterator i = TestUtil::aps.begin() ; i != TestUtil::aps.end() ; ++i) { std::unordered_map::const_iterator diff --git a/owlps-positioner/tests/interlinknetworks_test.hh b/owlps-positioner/tests/interlinknetworks_test.hh index 75ae930..cb2ec64 100644 --- a/owlps-positioner/tests/interlinknetworks_test.hh +++ b/owlps-positioner/tests/interlinknetworks_test.hh @@ -17,7 +17,7 @@ public: algo->compute(request) ; // yes, that's ugly char ap_gain = 5, ap_power = 20, ap_channel = 1 ; - AccessPoint ap(Point3D(), "", "", ap_gain, ap_power, ap_channel) ; + CapturePoint ap(Point3D(), "", "", ap_gain, ap_power, ap_channel) ; std::vector ss_list ; ss_list.push_back(-42) ; diff --git a/owlps-positioner/tests/measurement_test.hh b/owlps-positioner/tests/measurement_test.hh index f36b4f0..0f0527e 100644 --- a/owlps-positioner/tests/measurement_test.hh +++ b/owlps-positioner/tests/measurement_test.hh @@ -15,7 +15,7 @@ public: TS_ASSERT_EQUALS(m00, m01) ; // Copy constructor - AccessPoint ap1 ; + CapturePoint ap1 ; Measurement m1(&ap1) ; Measurement m2(m1) ; TS_ASSERT_EQUALS(m1, m2) ; @@ -25,17 +25,17 @@ public: void test_accessors(void) { // Simple read accessors - AccessPoint ap1 ; + CapturePoint ap1 ; std::vector vi1 ; Measurement m1(&ap1, vi1) ; - TS_ASSERT_EQUALS(m1.get_ap(), &ap1) ; + TS_ASSERT_EQUALS(m1.get_cp(), &ap1) ; TS_ASSERT_EQUALS(m1.get_ss_list(), vi1) ; TS_ASSERT_EQUALS(m1.get_average_dbm(), 0) ; // Write & read accessors - AccessPoint ap2 ; - m1.set_ap(&ap2) ; - TS_ASSERT_EQUALS(m1.get_ap(), &ap2) ; + CapturePoint ap2 ; + m1.set_cp(&ap2) ; + TS_ASSERT_EQUALS(m1.get_cp(), &ap2) ; m1.add_ss(-33) ; m1.add_ss(-78) ; @@ -101,13 +101,13 @@ public: void test_operators(void) { // == - AccessPoint ap1 ; + CapturePoint ap1 ; Measurement m1(&ap1) ; Measurement m2(&ap1) ; TS_ASSERT_EQUALS(m1, m2) ; // != - AccessPoint ap2 ; + CapturePoint ap2 ; Measurement m3(&ap2) ; TS_ASSERT(m1 != m3) ; diff --git a/owlps-positioner/tests/minmax_test.hh b/owlps-positioner/tests/minmax_test.hh index 6f4b229..6e3d0c9 100644 --- a/owlps-positioner/tests/minmax_test.hh +++ b/owlps-positioner/tests/minmax_test.hh @@ -12,12 +12,12 @@ public: float step = 0.5 ; TrilaterationMethod *minmax = new MinMax(start, stop, step) ; - AccessPoint + CapturePoint ap1(Point3D(0,0,0)), ap2(Point3D(10,0,0)), ap3(Point3D(0,10,0)), ap4(Point3D(5,5,4)) ; - std::unordered_map ap_distances ; + std::unordered_map ap_distances ; ap_distances[&ap1] = 7.071 ; ap_distances[&ap2] = 7.071 ; ap_distances[&ap3] = 7.071 ; diff --git a/owlps-positioner/tests/referencepoint_test.hh b/owlps-positioner/tests/referencepoint_test.hh index b8bdc1d..167c788 100644 --- a/owlps-positioner/tests/referencepoint_test.hh +++ b/owlps-positioner/tests/referencepoint_test.hh @@ -60,7 +60,7 @@ public: void test_ss_square_distance(void) { - AccessPoint ap1(Point3D(1,2,3), "aa:bb:cc:dd:ee:ff") ; + CapturePoint ap1(Point3D(1,2,3), "aa:bb:cc:dd:ee:ff") ; CalibrationRequest calibrationrequest1 ; Measurement measurement1(&ap1) ; measurement1.add_ss(-78) ; diff --git a/owlps-positioner/tests/request_test.hh b/owlps-positioner/tests/request_test.hh index fcd643b..67e7398 100644 --- a/owlps-positioner/tests/request_test.hh +++ b/owlps-positioner/tests/request_test.hh @@ -32,7 +32,7 @@ public: // Simple read accessors Timestamp current_time ; current_time.now() ; - AccessPoint ap1(Point3D(1,2,3), "192.168.0.1", "aa:bb:cc:dd:ee:ff") ; + CapturePoint ap1(Point3D(1,2,3), "192.168.0.1", "aa:bb:cc:dd:ee:ff") ; Measurement meas1(&ap1) ; std::unordered_map measurements ; measurements["aa:bb:cc:dd:ee:ff"] = meas1 ; @@ -51,7 +51,7 @@ public: r1.set_time_sent(current_time) ; TS_ASSERT_EQUALS(r1.get_time_sent(), current_time) ; - AccessPoint ap2(Point3D(3,2,1), "192.168.0.2", "aa:bb:cc:dd:ee:02") ; + 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 ; r1.set_measurements(measurements) ; diff --git a/owlps-positioner/tests/stock_test.hh b/owlps-positioner/tests/stock_test.hh index ead3495..dd5e2c9 100644 --- a/owlps-positioner/tests/stock_test.hh +++ b/owlps-positioner/tests/stock_test.hh @@ -78,26 +78,26 @@ public: element_not_found) ; } - void test_aps(void) + void test_cps(void) { - TS_ASSERT_THROWS(Stock::get_ap("aa:bb:cc:dd:ee:ff"), + TS_ASSERT_THROWS(Stock::get_cp("aa:bb:cc:dd:ee:ff"), element_not_found) ; - AccessPoint ap1 ; - TS_ASSERT_EQUALS(Stock::getw_ap("00:00:00:00:02:01"), ap1) ; + CapturePoint ap1 ; + TS_ASSERT_EQUALS(Stock::getw_cp("00:00:00:00:02:01"), ap1) ; - AccessPoint ap2(Point3D(1,2,3), "192.168.2.1", "00:00:00:00:02:02", + CapturePoint 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) ; + 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) ; Stock::clear() ; - TS_ASSERT_THROWS(Stock::get_ap("aa:bb:cc:dd:ee:ff"), + TS_ASSERT_THROWS(Stock::get_cp("aa:bb:cc:dd:ee:ff"), element_not_found) ; - TS_ASSERT_THROWS(Stock::get_ap("00:00:00:00:02:01"), + TS_ASSERT_THROWS(Stock::get_cp("00:00:00:00:02:01"), element_not_found) ; - TS_ASSERT_THROWS(Stock::get_ap("00:00:00:00:02:02"), + TS_ASSERT_THROWS(Stock::get_cp("00:00:00:00:02:02"), element_not_found) ; } @@ -125,7 +125,7 @@ public: void test_closest_reference_point(void) { - const AccessPoint &ap1 = Stock::find_create_ap("aa:bb:cc:dd:ee:ff") ; + const CapturePoint &ap1 = Stock::find_create_cp("aa:bb:cc:dd:ee:ff") ; CalibrationRequest calibrationrequest1 ; Measurement measurement1(&ap1) ; measurement1.add_ss(-23) ; diff --git a/owlps-positioner/tests/testutil.cc b/owlps-positioner/tests/testutil.cc index d476a82..1a7e744 100644 --- a/owlps-positioner/tests/testutil.cc +++ b/owlps-positioner/tests/testutil.cc @@ -10,7 +10,7 @@ using namespace std ; -vector TestUtil::aps ; +vector TestUtil::aps ; vector TestUtil::mobiles ; vector TestUtil::requests ; vector TestUtil::results ; @@ -36,7 +36,7 @@ void TestUtil::set_up() { tear_down() ; create_mobile_list() ; - create_ap_list() ; + create_cp_list() ; create_request_list() ; create_result_list() ; } @@ -50,9 +50,9 @@ void TestUtil::create_mobile_list() mobiles.push_back(mobile1) ; } -void TestUtil::create_ap_list() +void TestUtil::create_cp_list() { - AccessPoint ap1 ; + CapturePoint ap1 ; ap1.set_mac_addr("11:22:33:44:55:01") ; aps.push_back(ap1) ; ap1.set_mac_addr("11:22:33:44:55:02") ; @@ -69,46 +69,46 @@ void TestUtil::create_request_list() measurement1.add_ss(-58) ; measurement1.add_ss(-55) ; - measurement1.set_ap(&aps[0]) ; + measurement1.set_cp(&aps[0]) ; measurements[0][aps[0].get_mac_addr()] = measurement1 ; measurement1.clear() ; measurement1.add_ss(-50) ; - measurement1.set_ap(&aps[2]) ; + measurement1.set_cp(&aps[2]) ; measurements[0][aps[2].get_mac_addr()] = measurement1 ; measurement1.clear() ; measurement1.add_ss(-42) ; measurement1.add_ss(-37) ; - measurement1.set_ap(&aps[1]) ; + measurement1.set_cp(&aps[1]) ; measurements[0][aps[1].get_mac_addr()] = measurement1 ; measurement1.clear() ; measurement1.add_ss(-51) ; measurement1.add_ss(-19) ; - measurement1.set_ap(&aps[0]) ; + measurement1.set_cp(&aps[0]) ; measurements[1][aps[0].get_mac_addr()] = measurement1 ; measurement1.clear() ; measurement1.add_ss(-70) ; measurement1.add_ss(-21) ; - measurement1.set_ap(&aps[1]) ; + measurement1.set_cp(&aps[1]) ; measurements[1][aps[1].get_mac_addr()] = measurement1 ; measurement1.clear() ; measurement1.add_ss(-59) ; - measurement1.set_ap(&aps[2]) ; + measurement1.set_cp(&aps[2]) ; measurements[1][aps[2].get_mac_addr()] = measurement1 ; measurement1.clear() ; measurement1.add_ss(-54) ; measurement1.add_ss(-32) ; - measurement1.set_ap(&aps[0]) ; + measurement1.set_cp(&aps[0]) ; measurements[2][aps[0].get_mac_addr()] = measurement1 ; measurement1.clear() ; measurement1.add_ss(-45) ; measurement1.add_ss(-23) ; - measurement1.set_ap(&aps[1]) ; + measurement1.set_cp(&aps[1]) ; measurements[2][aps[1].get_mac_addr()] = measurement1 ; measurement1.clear() ; measurement1.add_ss(-56) ; - measurement1.set_ap(&aps[2]) ; + measurement1.set_cp(&aps[2]) ; measurements[2][aps[2].get_mac_addr()] = measurement1 ; // Create timestamp list @@ -349,12 +349,12 @@ bool TestUtil::measurement_equals(const Measurement &first, return false ; // Compare ap values - if (first.get_ap() == NULL || second.get_ap() == NULL) + if (first.get_cp() == NULL || second.get_cp() == NULL) { - if (first.get_ap() != NULL || second.get_ap() != NULL) + if (first.get_cp() != NULL || second.get_cp() != NULL) return false ; } - else if (*first.get_ap() != *second.get_ap()) + else if (*first.get_cp() != *second.get_cp()) return false ; // Compare ss_list diff --git a/owlps-positioner/tests/testutil.hh b/owlps-positioner/tests/testutil.hh index 61c81f0..3f7cc80 100644 --- a/owlps-positioner/tests/testutil.hh +++ b/owlps-positioner/tests/testutil.hh @@ -1,7 +1,7 @@ #ifndef _OWLPS_POSITIONING_TESTS_TESTUTIL_HH_ #define _OWLPS_POSITIONING_TESTS_TESTUTIL_HH_ -#include "accesspoint.hh" +#include "capturepoint.hh" #include "mobile.hh" #include "request.hh" #include "measurement.hh" @@ -16,12 +16,12 @@ class TestUtil { private: static void create_mobile_list(void) ; - static void create_ap_list(void) ; + static void create_cp_list(void) ; static void create_request_list(void) ; static void create_result_list(void) ; public: - static std::vector aps ; + static std::vector aps ; static std::vector mobiles ; static std::vector requests ; static std::vector results ;