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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
// 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.compare;
@safe unittest
{
import dyaml : Loader;
import dyaml.test.common : assertNodesEqual, compareEvents, run;
/**
Test parser by comparing output from parsing two equivalent YAML files.
Params:
dataFilename = YAML file to parse.
canonicalFilename = Another file to parse, in canonical YAML format.
*/
static void testParser(string dataFilename, string canonicalFilename) @safe
{
auto dataEvents = Loader.fromFile(dataFilename).parse();
auto canonicalEvents = Loader.fromFile(canonicalFilename).parse();
//BUG: the return value isn't checked! This test currently fails...
compareEvents(dataEvents, canonicalEvents);
}
/**
Test loader by comparing output from loading two equivalent YAML files.
Params:
dataFilename = YAML file to load.
canonicalFilename = Another file to load, in canonical YAML format.
*/
static void testLoader(string dataFilename, string canonicalFilename) @safe
{
import std.array : array;
auto data = Loader.fromFile(dataFilename).array;
auto canonical = Loader.fromFile(canonicalFilename).array;
assert(data.length == canonical.length, "Unequal node count");
foreach (n; 0 .. data.length)
{
assertNodesEqual(data[n], canonical[n]);
}
}
run(&testParser, ["data", "canonical"]);
run(&testLoader, ["data", "canonical"], ["test_loader_skip"]);
}
|