2011-10-11 13:58:23 +00:00
|
|
|
|
|
|
|
// 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.testresolver;
|
|
|
|
|
|
|
|
|
|
|
|
import std.file;
|
|
|
|
import std.string;
|
|
|
|
|
|
|
|
import dyaml.testcommon;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Implicit tag resolution unittest.
|
|
|
|
*
|
|
|
|
* Params: verbose = Print verbose output?
|
2011-10-12 21:49:42 +00:00
|
|
|
* dataFilename = File with unittest data.
|
|
|
|
* detectFilename = Dummy filename used to specify which data filenames to use.
|
2011-10-11 13:58:23 +00:00
|
|
|
*/
|
|
|
|
void testImplicitResolver(bool verbose, string dataFilename, string detectFilename)
|
|
|
|
{
|
|
|
|
string correctTag;
|
|
|
|
Node node;
|
|
|
|
|
2011-10-12 21:49:42 +00:00
|
|
|
scope(failure)
|
2011-10-11 13:58:23 +00:00
|
|
|
{
|
2011-10-12 21:49:42 +00:00
|
|
|
if(true)
|
2011-10-11 13:58:23 +00:00
|
|
|
{
|
|
|
|
writeln("Correct tag: ", correctTag);
|
|
|
|
writeln("Node: ", node.debugString);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-10-12 21:49:42 +00:00
|
|
|
correctTag = readText(detectFilename).strip();
|
|
|
|
node = Loader(dataFilename).load();
|
|
|
|
assert(node.isSequence);
|
|
|
|
foreach(ref Node scalar; node)
|
|
|
|
{
|
|
|
|
assert(scalar.isScalar);
|
2011-10-20 13:48:21 +00:00
|
|
|
assert(scalar.tag == correctTag);
|
2011-10-12 21:49:42 +00:00
|
|
|
}
|
2011-10-11 13:58:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
unittest
|
|
|
|
{
|
|
|
|
writeln("D:YAML Resolver unittest");
|
|
|
|
run("testImplicitResolver", &testImplicitResolver, ["data", "detect"]);
|
|
|
|
}
|