New loader ctor in errors unittests.
This commit is contained in:
parent
9fe6950df0
commit
601f10bf2f
|
@ -7,6 +7,8 @@
|
||||||
module dyaml.testerrors;
|
module dyaml.testerrors;
|
||||||
|
|
||||||
|
|
||||||
|
import std.file;
|
||||||
|
|
||||||
import dyaml.testcommon;
|
import dyaml.testcommon;
|
||||||
|
|
||||||
|
|
||||||
|
@ -16,11 +18,10 @@ import dyaml.testcommon;
|
||||||
/// errorFilename = File name to read from.
|
/// errorFilename = File name to read from.
|
||||||
void testLoaderError(bool verbose, string errorFilename)
|
void testLoaderError(bool verbose, string errorFilename)
|
||||||
{
|
{
|
||||||
auto file = new File(errorFilename);
|
auto buffer = std.file.read(errorFilename);
|
||||||
scope(exit){file.close();}
|
|
||||||
|
|
||||||
Node[] nodes;
|
Node[] nodes;
|
||||||
try{nodes = Loader(file).loadAll();}
|
try { nodes = Loader(buffer).loadAll(); }
|
||||||
catch(YAMLException e)
|
catch(YAMLException e)
|
||||||
{
|
{
|
||||||
if(verbose) { writeln(typeid(e).toString(), "\n", e); }
|
if(verbose) { writeln(typeid(e).toString(), "\n", e); }
|
||||||
|
@ -36,15 +37,11 @@ void testLoaderError(bool verbose, string errorFilename)
|
||||||
void testLoaderErrorString(bool verbose, string errorFilename)
|
void testLoaderErrorString(bool verbose, string errorFilename)
|
||||||
{
|
{
|
||||||
// Load file to a buffer, then pass that to the YAML loader.
|
// Load file to a buffer, then pass that to the YAML loader.
|
||||||
auto file = new File(errorFilename);
|
auto buffer = std.file.read(errorFilename);
|
||||||
scope(exit){file.close();}
|
|
||||||
ubyte[] buffer;
|
|
||||||
buffer.length = file.available;
|
|
||||||
file.read(buffer);
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
auto nodes = Loader(new MemoryStream(buffer)).loadAll();
|
auto nodes = Loader(buffer).loadAll();
|
||||||
}
|
}
|
||||||
catch(YAMLException e)
|
catch(YAMLException e)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue