[Positioning] TestUtil: Add create_test_csv_file()
This commit is contained in:
parent
b6ab3c841d
commit
dbd58f8178
|
@ -11,7 +11,6 @@ class InputCSV_test: public CxxTest::TestSuite
|
|||
{
|
||||
private:
|
||||
std::string csv_file_name ; // Test CSV file name
|
||||
std::vector<std::string> csv_lines ; // Test CSV file contents
|
||||
std::vector<AccessPoint> 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) ;
|
||||
|
|
|
@ -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<AccessPoint> TestUtil::
|
||||
create_test_csv_file(const string &file_name)
|
||||
{
|
||||
// Create AP list
|
||||
vector<AccessPoint> 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<string> 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 ;
|
||||
}
|
||||
|
|
|
@ -4,12 +4,17 @@
|
|||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "accesspoint.hh"
|
||||
|
||||
class TestUtil
|
||||
{
|
||||
public:
|
||||
static void fill_file(const std::string &output_file_name,
|
||||
const std::vector<std::string> output_lines) ;
|
||||
static void remove_file(const std::string &file_name) ;
|
||||
|
||||
static std::vector<AccessPoint>
|
||||
create_test_csv_file(const std::string &file_name) ;
|
||||
} ;
|
||||
|
||||
#endif // _OWLPS_POSITIONING_TESTS_TESTUTIL_HH_
|
||||
|
|
Loading…
Reference in New Issue