test/util/TokenizedLineReaderTester.cpp
/**This operation checks the TokenizedLineReader when the comment token is
 * changed.*/
This operation checks the TokenizedLineReader when the comment token is
changed.
This operation checks the TokenizedLineReader when the comment token is changed .
BOOST_AUTO_TEST_CASE(checkCommentDelimiter)
{
	TokenizedLineReader<double> doubleReader;
	vector<double> dLine;
	auto doubleTestStream = std::make_shared<stringstream>(ios::in | ios::out);
	*doubleTestStream << doubleCSVDoubleSlashCommentString;
	doubleReader.setDelimiter(",");
	doubleReader.setCommentDelimiter("//");
	doubleReader.setInputStream(doubleTestStream);
	dLine = doubleReader.loadLine();
	BOOST_REQUIRE(!dLine.empty());
	BOOST_REQUIRE_EQUAL(3U, dLine.size());
	BOOST_REQUIRE_CLOSE_FRACTION(0.0, dLine.at(0), 0.001);
	BOOST_REQUIRE_CLOSE_FRACTION(1.0, dLine.at(1), 0.001);
	BOOST_REQUIRE_CLOSE_FRACTION(5.0, dLine.at(2), 0.001);
	dLine = doubleReader.loadLine();
	BOOST_REQUIRE(!dLine.empty());
	BOOST_REQUIRE_EQUAL(4U, dLine.size());
	BOOST_REQUIRE_CLOSE_FRACTION(0.11, dLine.at(0), 0.001);
	BOOST_REQUIRE_CLOSE_FRACTION(0.55, dLine.at(1), 0.001);
	BOOST_REQUIRE_CLOSE_FRACTION(22.86, dLine.at(2), 0.001);
	BOOST_REQUIRE_CLOSE_FRACTION(99.283, dLine.at(3), 0.0001);
	dLine = doubleReader.loadLine();
	BOOST_REQUIRE(!dLine.empty());
	BOOST_REQUIRE_EQUAL(3U, dLine.size());
	BOOST_REQUIRE_CLOSE_FRACTION(0.000382, dLine.at(0), 0.001);
	BOOST_REQUIRE_CLOSE_FRACTION(883.33, dLine.at(1), 0.001);
	BOOST_REQUIRE_CLOSE_FRACTION(74.832, dLine.at(2), 0.0001);
	return;
}
BOOST_AUTO_TEST_CASE ( checkCommentDelimiter ) { TokenizedLineReader < double > doubleReader ; vector < double > dLine ; auto doubleTestStream = std :: make_shared < stringstream > ( ios :: in | ios :: out ) ; * doubleTestStream << doubleCSVDoubleSlashCommentString ; doubleReader . setDelimiter ( " " ) ; doubleReader . setCommentDelimiter ( " " ) ; doubleReader . setInputStream ( doubleTestStream ) ; dLine = doubleReader . loadLine ( ) ; BOOST_REQUIRE ( ! dLine . empty ( ) ) ; BOOST_REQUIRE_EQUAL ( 3U , dLine . size ( ) ) ; BOOST_REQUIRE_CLOSE_FRACTION ( 0.0 , dLine . at ( 0 ) , 0.001 ) ; BOOST_REQUIRE_CLOSE_FRACTION ( 1.0 , dLine . at ( 1 ) , 0.001 ) ; BOOST_REQUIRE_CLOSE_FRACTION ( 5.0 , dLine . at ( 2 ) , 0.001 ) ; dLine = doubleReader . loadLine ( ) ; BOOST_REQUIRE ( ! dLine . empty ( ) ) ; BOOST_REQUIRE_EQUAL ( 4U , dLine . size ( ) ) ; BOOST_REQUIRE_CLOSE_FRACTION ( 0.11 , dLine . at ( 0 ) , 0.001 ) ; BOOST_REQUIRE_CLOSE_FRACTION ( 0.55 , dLine . at ( 1 ) , 0.001 ) ; BOOST_REQUIRE_CLOSE_FRACTION ( 22.86 , dLine . at ( 2 ) , 0.001 ) ; BOOST_REQUIRE_CLOSE_FRACTION ( 99.283 , dLine . at ( 3 ) , 0.0001 ) ; dLine = doubleReader . loadLine ( ) ; BOOST_REQUIRE ( ! dLine . empty ( ) ) ; BOOST_REQUIRE_EQUAL ( 3U , dLine . size ( ) ) ; BOOST_REQUIRE_CLOSE_FRACTION ( 0.000382 , dLine . at ( 0 ) , 0.001 ) ; BOOST_REQUIRE_CLOSE_FRACTION ( 883.33 , dLine . at ( 1 ) , 0.001 ) ; BOOST_REQUIRE_CLOSE_FRACTION ( 74.832 , dLine . at ( 2 ) , 0.0001 ) ; return ; }
This operation checks the TokenizedLineReader when the comment token is
 changed.
This operation checks the TokenizedLineReader when the comment token is changed .
// Local Declarations //----- Check doubles -----// // Create the input stream // Set the delimiter // Set the comment delimiter // Load the double reader // Get the first line and check it // Get the second line and check it // The third line should skipped because it is a comment so, get the fourth // line and check it