69 lines
1.7 KiB
C++
69 lines
1.7 KiB
C++
/*
|
|
* 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 <cxxtest/TestSuite.h>
|
|
|
|
#include "textfilereader.hh"
|
|
|
|
class TextFileReader_test: public CxxTest::TestSuite
|
|
{
|
|
private:
|
|
std::string test_file_name ;
|
|
|
|
public:
|
|
|
|
TextFileReader_test(void)
|
|
{
|
|
test_file_name = "/tmp/TextFileReader_test_file.csv" ;
|
|
}
|
|
|
|
|
|
~TextFileReader_test(void)
|
|
{
|
|
TestUtil::remove_file(test_file_name) ;
|
|
}
|
|
|
|
|
|
static TextFileReader_test* createSuite(void)
|
|
{
|
|
return new TextFileReader_test() ;
|
|
}
|
|
|
|
|
|
static void destroySuite(TextFileReader_test *suite)
|
|
{
|
|
delete suite ;
|
|
}
|
|
|
|
|
|
void test_textfilereader(void)
|
|
{
|
|
std::ofstream output_file(test_file_name.c_str()) ;
|
|
assert(output_file) ;
|
|
output_file << "Hello\nWorld\n" ;
|
|
output_file.close() ;
|
|
|
|
std::string line ;
|
|
TextFileReader *textfilereader = nullptr ;
|
|
TS_ASSERT_THROWS_NOTHING(
|
|
textfilereader = new TextFileReader(test_file_name)) ;
|
|
TS_ASSERT(textfilereader->read_line(line)) ;
|
|
TS_ASSERT_EQUALS(line, "Hello") ;
|
|
TS_ASSERT(textfilereader->read_line(line)) ;
|
|
TS_ASSERT_EQUALS(line, "World") ;
|
|
|
|
delete textfilereader ;
|
|
}
|
|
|
|
} ;
|