diff --git a/owlps-positioning/tests/inputcsv_test.hh b/owlps-positioning/tests/inputcsv_test.hh index 3063417..396a1d9 100644 --- a/owlps-positioning/tests/inputcsv_test.hh +++ b/owlps-positioning/tests/inputcsv_test.hh @@ -11,7 +11,6 @@ class InputCSV_test: public CxxTest::TestSuite { private: std::string csv_file_name ; // Test CSV file name - std::vector csv_lines ; // Test CSV file contents std::vector aps ; // List of test AccessPoint @@ -24,44 +23,8 @@ public: // Clear the stock Stock::clear() ; - // Create AP list - aps.push_back(AccessPoint(Point3D(1,2,3), "11:22:33:44:55:01")) ; - aps.push_back(AccessPoint(Point3D(4,5,6), "11:22:33:44:55:02")) ; - aps.push_back(AccessPoint(Point3D(7,8,9), "11:22:33:44:55:03")) ; - - // Fill name and contents of the test CSV file csv_file_name = "/tmp/InputCSV_test_csv_file.csv" ; - csv_lines.push_back("\ -\n \n\ - aa:bb:cc:dd:ee:ff;1265120910725;0.00;0.00;0.00;0\ -;" + aps[0].get_mac_addr() + ";-58\ -;" + aps[2].get_mac_addr() + ";-50\ -;" + aps[1].get_mac_addr() + ";-42\ -;" + aps[0].get_mac_addr() + ";-55\ -;" + aps[1].get_mac_addr() + ";-37\ -\n") ; - csv_lines.push_back("\ -aa:bb:cc:dd:ee:77;1265120911234;0.00;0.00;0.00;0\ -;" + aps[2].get_mac_addr() + ";-59\ -;" + aps[0].get_mac_addr() + ";-51\ -;" + aps[1].get_mac_addr() + ";-70\ -;" + aps[1].get_mac_addr() + ";-21\ -;" + aps[0].get_mac_addr() + ";-19\ -\n \n\ -\n\t\n\ -\n \t \n\ -\n") ; - csv_lines.push_back("\ -\taa:bb:cc:dd:ee:ff;1265120912345;0.00;0.00;0.00;0\ -;" + aps[2].get_mac_addr() + ";-56\ -;" + aps[1].get_mac_addr() + ";-45\ -;" + aps[0].get_mac_addr() + ";-54\ -;" + aps[1].get_mac_addr() + ";-23\ -;" + aps[0].get_mac_addr() + ";-32\ -\n\n\t\n") ; - - // Create and fill the test CSV file - TestUtil::fill_file(csv_file_name, csv_lines) ; + aps = TestUtil::create_test_csv_file(csv_file_name) ; // Back to the normal behaviour (i.e. do not abort on fail) CxxTest::setAbortTestOnFail(false) ; diff --git a/owlps-positioning/tests/testutil.cc b/owlps-positioning/tests/testutil.cc index 66656e9..9f63ae4 100644 --- a/owlps-positioning/tests/testutil.cc +++ b/owlps-positioning/tests/testutil.cc @@ -32,3 +32,50 @@ void TestUtil::remove_file(const string &file_name) if (remove(file_name.c_str()) == -1) TS_WARN("Cannot remove test file `"+ file_name +"`!") ; } + + +vector TestUtil:: +create_test_csv_file(const string &file_name) +{ + // Create AP list + vector aps ; + aps.push_back(AccessPoint(Point3D(1,2,3), "11:22:33:44:55:01")) ; + aps.push_back(AccessPoint(Point3D(4,5,6), "11:22:33:44:55:02")) ; + aps.push_back(AccessPoint(Point3D(7,8,9), "11:22:33:44:55:03")) ; + + // Fill name and contents of the test CSV file + vector csv_lines ; + csv_lines.push_back("\ +\n \n\ + aa:bb:cc:dd:ee:ff;1265120910725;0;0;0;0\ +;" + aps[0].get_mac_addr() + ";-58\ +;" + aps[2].get_mac_addr() + ";-50\ +;" + aps[1].get_mac_addr() + ";-42\ +;" + aps[0].get_mac_addr() + ";-55\ +;" + aps[1].get_mac_addr() + ";-37\ +\n") ; + csv_lines.push_back("\ +aa:bb:cc:dd:ee:77;1265120911234;0;0;0;0\ +;" + aps[2].get_mac_addr() + ";-59\ +;" + aps[0].get_mac_addr() + ";-51\ +;" + aps[1].get_mac_addr() + ";-70\ +;" + aps[1].get_mac_addr() + ";-21\ +;" + aps[0].get_mac_addr() + ";-19\ +\n \n\ +\n\t\n\ +\n \t \n\ +\n") ; + csv_lines.push_back("\ +\taa:bb:cc:dd:ee:ff;1265120912345;0;0;0;0\ +;" + aps[2].get_mac_addr() + ";-56\ +;" + aps[1].get_mac_addr() + ";-45\ +;" + aps[0].get_mac_addr() + ";-54\ +;" + aps[1].get_mac_addr() + ";-23\ +;" + aps[0].get_mac_addr() + ";-32\ +\n\n\t\n") ; + + // Create and fill the test CSV file + fill_file(file_name, csv_lines) ; + + return aps ; +} diff --git a/owlps-positioning/tests/testutil.hh b/owlps-positioning/tests/testutil.hh index 64fa526..2b4db35 100644 --- a/owlps-positioning/tests/testutil.hh +++ b/owlps-positioning/tests/testutil.hh @@ -4,12 +4,17 @@ #include #include +#include "accesspoint.hh" + class TestUtil { public: static void fill_file(const std::string &output_file_name, const std::vector output_lines) ; static void remove_file(const std::string &file_name) ; + + static std::vector + create_test_csv_file(const std::string &file_name) ; } ; #endif // _OWLPS_POSITIONING_TESTS_TESTUTIL_HH_