Reader unittest fixes.

This commit is contained in:
Ferdinand Majerech 2014-07-22 01:13:01 +02:00
parent 9bf9a0c278
commit 405a61891f

View file

@ -11,38 +11,34 @@ import dyaml.testcommon;
import dyaml.reader;
/**
* Try reading entire stream through Reader, expecting an error (the stream is invalid).
*
* Params: verbose = Print verbose output?
* data = Stream to read.
*/
void runReader(in bool verbose, Stream stream)
// Try reading entire stream through Reader, expecting an error (the stream is invalid).
//
// Params: verbose = Print verbose output?
// data = Stream to read.
void runReader(const bool verbose, Stream stream)
{
try
{
auto reader = new Reader(stream);
while(reader.peek() != '\0'){reader.forward();}
while(reader.peek() != '\0') { reader.forward(); }
}
catch(ReaderException e)
{
if(verbose){writeln(typeid(e).toString(), "\n", e);}
if(verbose) { writeln(typeid(e).toString(), "\n", e); }
return;
}
assert(false, "Expected an exception");
}
/**
* Stream error unittest. Tries to read invalid input streams, expecting errors.
*
* Params: verbose = Print verbose output?
* errorFilename = File name to read from.
*/
/// Stream error unittest. Tries to read invalid input streams, expecting errors.
///
/// Params: verbose = Print verbose output?
/// errorFilename = File name to read from.
void testStreamError(bool verbose, string errorFilename)
{
auto file = new File(errorFilename);
scope(exit){file.close();}
scope(exit) { file.close(); }
runReader(verbose, file);
}