owlps/owlps-positioning/tests/testutil.cc

35 lines
864 B
C++

#include "testutil.hh"
#include <cxxtest/TestSuite.h>
#include <fstream>
using namespace std ;
// Create the file output_file_name and fill it with the contents of
// output_lines
void TestUtil::fill_file(const string &output_file_name,
const vector<string> output_lines)
{
// Open the file
std::ofstream output_file ;
output_file.open(output_file_name.c_str()) ;
if (! output_file)
TS_FAIL("Cannot open test file `"+ output_file_name
+"` for creation!") ;
// Write contents to the file
for (std::vector<std::string>::const_iterator i = output_lines.begin() ;
i != output_lines.end() ; ++i)
output_file << *i ;
output_file.close() ;
}
void TestUtil::remove_file(const string &file_name)
{
if (remove(file_name.c_str()) == -1)
TS_WARN("Cannot remove test file `"+ file_name +"`!") ;
}