/* * This file is part of the Owl Positioning System (OwlPS) project. * It is subject to the copyright notice and license terms in the * COPYRIGHT.t2t file found in the top-level directory of this * distribution and at * https://code.lm7.fr/mcy/owlps/src/master/COPYRIGHT.t2t * No part of the OwlPS Project, including this file, may be copied, * modified, propagated, or distributed except according to the terms * contained in the COPYRIGHT.t2t file; the COPYRIGHT.t2t file must be * distributed along with this file, either separately or by replacing * this notice by the COPYRIGHT.t2t file's contents. */ #include #include "outputcsv.hh" class OutputCSV_test: public CxxTest::TestSuite { private: std::string csv_file_name ; public: OutputCSV_test(void) { csv_file_name = "/tmp/OutputCSV_test_csv_file.csv" ; } ~OutputCSV_test(void) { TestUtil::remove_file(csv_file_name) ; } static OutputCSV_test* createSuite(void) { return new OutputCSV_test() ; } static void destroySuite(OutputCSV_test *suite) { delete suite ; } void test_write_result(void) { OutputCSV *outputcsv1 = new OutputCSV(csv_file_name) ; for (auto i = TestUtil::results.begin() ; i != TestUtil::results.end() ; ++i) outputcsv1->write(*i) ; delete outputcsv1 ; unsigned int result_count = 0 ; std::ifstream inputcsv(csv_file_name.c_str()) ; while (inputcsv) { std::string line ; getline(inputcsv, line) ; const Result &result = TestUtil::results.at(result_count) ; std::string result_csv = result.to_csv() ; TS_ASSERT_EQUALS(line, result_csv) ; if (++result_count >= TestUtil::results.size()) break ; } } } ;