aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/ext_depends/D-YAML/source/dyaml/test/representer.d
diff options
context:
space:
mode:
authorRalph Amissah <ralph.amissah@gmail.com>2021-02-19 17:10:51 -0500
committerRalph Amissah <ralph.amissah@gmail.com>2021-02-24 16:46:47 -0500
commit02ca32ae0a5bc290918d2b2a3288e385b9cc6b11 (patch)
tree06379785e8a0165a7deb981c2eba362894820634 /src/ext_depends/D-YAML/source/dyaml/test/representer.d
parentbuild from static source-tree pre fetch depends (diff)
external & build dependences in src tree
- external & build dependences boost licensed - ext_depends (external depends) - D-YAML - tinyendian - d2sqlite3 - imageformats - build_depends - dub2nix
Diffstat (limited to 'src/ext_depends/D-YAML/source/dyaml/test/representer.d')
-rw-r--r--src/ext_depends/D-YAML/source/dyaml/test/representer.d54
1 files changed, 54 insertions, 0 deletions
diff --git a/src/ext_depends/D-YAML/source/dyaml/test/representer.d b/src/ext_depends/D-YAML/source/dyaml/test/representer.d
new file mode 100644
index 0000000..4a1ae67
--- /dev/null
+++ b/src/ext_depends/D-YAML/source/dyaml/test/representer.d
@@ -0,0 +1,54 @@
+
+// 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.representer;
+
+@safe unittest
+{
+ import std.array : Appender, array;
+ import std.meta : AliasSeq;
+ import std.path : baseName, stripExtension;
+ import std.utf : toUTF8;
+
+ import dyaml : dumper, Loader, Node;
+ import dyaml.test.common : assertNodesEqual, run;
+ import dyaml.test.constructor : expected;
+
+ /**
+ Representer unittest. Dumps nodes, then loads them again.
+
+ Params:
+ baseName = Nodes in dyaml.test.constructor.expected for roundtripping.
+ */
+ static void testRepresenterTypes(string baseName) @safe
+ {
+ assert((baseName in expected) !is null, "Unimplemented representer test: " ~ baseName);
+
+ Node[] expectedNodes = expected[baseName];
+ foreach (encoding; AliasSeq!(char, wchar, dchar))
+ {
+ auto emitStream = new Appender!(immutable(encoding)[]);
+ auto dumper = dumper();
+ dumper.dump!encoding(emitStream, expectedNodes);
+
+ immutable output = emitStream.data;
+
+ auto loader = Loader.fromString(emitStream.data.toUTF8);
+ loader.name = "TEST";
+ const readNodes = loader.array;
+
+ assert(expectedNodes.length == readNodes.length);
+ foreach (n; 0 .. expectedNodes.length)
+ {
+ assertNodesEqual(expectedNodes[n], readNodes[n]);
+ }
+ }
+ }
+ foreach (key, _; expected)
+ {
+ testRepresenterTypes(key);
+ }
+}