67 lines
1.6 KiB
C++
67 lines
1.6 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 "textfilewriter.hh"
|
|
|
|
class TextFileWriter_test: public CxxTest::TestSuite
|
|
{
|
|
private:
|
|
std::string test_file_name ;
|
|
|
|
public:
|
|
|
|
TextFileWriter_test(void)
|
|
{
|
|
test_file_name = "/tmp/TextFileWriter_test_file.csv" ;
|
|
}
|
|
|
|
|
|
~TextFileWriter_test(void)
|
|
{
|
|
TestUtil::remove_file(test_file_name) ;
|
|
}
|
|
|
|
|
|
static TextFileWriter_test* createSuite(void)
|
|
{
|
|
return new TextFileWriter_test() ;
|
|
}
|
|
|
|
|
|
static void destroySuite(TextFileWriter_test *suite)
|
|
{
|
|
delete suite ;
|
|
}
|
|
|
|
|
|
void test_textfilewriter(void)
|
|
{
|
|
TextFileWriter *textfilewriter = nullptr ;
|
|
TS_ASSERT_THROWS_NOTHING(
|
|
textfilewriter = new TextFileWriter(test_file_name)) ;
|
|
TS_ASSERT(textfilewriter->write_text("Hello\nWorld\n")) ;
|
|
delete textfilewriter ;
|
|
|
|
std::ifstream input_file(test_file_name.c_str()) ;
|
|
std::string line ;
|
|
getline(input_file, line) ;
|
|
TS_ASSERT_EQUALS(line, "Hello") ;
|
|
getline(input_file, line) ;
|
|
TS_ASSERT_EQUALS(line, "World") ;
|
|
input_file.close() ;
|
|
}
|
|
|
|
} ;
|