1 2 // Copyright Ferdinand Majerech 2011. 3 // Distributed under the Boost Software License, Version 1.0. 4 // (See accompanying file LICENSE_1_0.txt or copy at 5 // http://www.boost.org/LICENSE_1_0.txt) 6 7 module dyaml.testresolver; 8 9 10 version(unittest) 11 { 12 13 import std.file; 14 import std..string; 15 16 import dyaml.testcommon; 17 18 19 /** 20 * Implicit tag resolution unittest. 21 * 22 * Params: verbose = Print verbose output? 23 * dataFilename = File with unittest data. 24 * detectFilename = Dummy filename used to specify which data filenames to use. 25 */ 26 void testImplicitResolver(bool verbose, string dataFilename, string detectFilename) 27 { 28 string correctTag; 29 Node node; 30 31 scope(failure) 32 { 33 if(true) 34 { 35 writeln("Correct tag: ", correctTag); 36 writeln("Node: ", node.debugString); 37 } 38 } 39 40 correctTag = readText(detectFilename).strip(); 41 node = Loader(dataFilename).load(); 42 assert(node.isSequence); 43 foreach(ref Node scalar; node) 44 { 45 assert(scalar.isScalar); 46 assert(scalar.tag == correctTag); 47 } 48 } 49 50 51 unittest 52 { 53 writeln("D:YAML Resolver unittest"); 54 run("testImplicitResolver", &testImplicitResolver, ["data", "detect"]); 55 } 56 57 } // version(unittest)