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
|
// 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.resolver;
@safe unittest
{
import std.conv : text;
import std.file : readText;
import std.string : strip;
import dyaml : Loader, Node, NodeID;
import dyaml.test.common : run;
/**
Implicit tag resolution unittest.
Params:
dataFilename = File with unittest data.
detectFilename = Dummy filename used to specify which data filenames to use.
*/
static void testImplicitResolver(string dataFilename, string detectFilename) @safe
{
const correctTag = readText(detectFilename).strip();
auto node = Loader.fromFile(dataFilename).load();
assert(node.nodeID == NodeID.sequence, text("Expected sequence when reading '", dataFilename, "', got ", node.nodeID));
foreach (Node scalar; node)
{
assert(scalar.nodeID == NodeID.scalar, text("Expected sequence of scalars when reading '", dataFilename, "', got sequence of ", scalar.nodeID));
assert(scalar.tag == correctTag, text("Expected tag '", correctTag, "' when reading '", dataFilename, "', got '", scalar.tag, "'"));
}
}
run(&testImplicitResolver, ["data", "detect"]);
}
|