blob: c20df6f96349f95b1c067aee9c86ac67957b39a5 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
// Copyright Ferdinand Majerech 2011.
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
module dyaml.test.reader;
@safe unittest
{
import std.exception :assertThrown;
import dyaml.test.common : readData, run;
import dyaml.reader : Reader, ReaderException;
/**
Try reading entire file through Reader, expecting an error (the file is invalid).
Params: data = Stream to read.
*/
static void runReader(ubyte[] fileData) @safe
{
auto reader = new Reader(fileData);
while(reader.peek() != '\0') { reader.forward(); }
}
/**
Stream error unittest. Tries to read invalid input files, expecting errors.
Params: errorFilename = File name to read from.
*/
static void testStreamError(string errorFilename) @safe
{
assertThrown!ReaderException(runReader(readData(errorFilename)));
}
run(&testStreamError, ["stream-error"]);
}
|