annotate tests/Typedef.d @ 51:70df72d2299a default tip

Added unit tests for events.
author Jacob Carlborg <doob@me.com>
date Sat, 13 Aug 2011 17:06:35 +0200
parents 02dbd18b7fe9
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
40
02dbd18b7fe9 Moved all tests into its own modules.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
1 /**
02dbd18b7fe9 Moved all tests into its own modules.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
2 * Copyright: Copyright (c) 2011 Jacob Carlborg. All rights reserved.
02dbd18b7fe9 Moved all tests into its own modules.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
3 * Authors: Jacob Carlborg
02dbd18b7fe9 Moved all tests into its own modules.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
4 * Version: Initial created: Aug 6, 2011
02dbd18b7fe9 Moved all tests into its own modules.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
5 * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0)
02dbd18b7fe9 Moved all tests into its own modules.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
6 */
02dbd18b7fe9 Moved all tests into its own modules.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
7 module tests.Typedef;
02dbd18b7fe9 Moved all tests into its own modules.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
8
02dbd18b7fe9 Moved all tests into its own modules.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
9 import orange.core.string;
02dbd18b7fe9 Moved all tests into its own modules.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
10 import orange.serialization.Serializer;
02dbd18b7fe9 Moved all tests into its own modules.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
11 import orange.serialization.archives.XMLArchive;
02dbd18b7fe9 Moved all tests into its own modules.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
12 import orange.test.UnitTester;
02dbd18b7fe9 Moved all tests into its own modules.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
13 import tests.Util;
02dbd18b7fe9 Moved all tests into its own modules.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
14
02dbd18b7fe9 Moved all tests into its own modules.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
15 Serializer serializer;
02dbd18b7fe9 Moved all tests into its own modules.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
16 XMLArchive!(char) archive;
02dbd18b7fe9 Moved all tests into its own modules.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
17
02dbd18b7fe9 Moved all tests into its own modules.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
18 typedef int Int;
02dbd18b7fe9 Moved all tests into its own modules.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
19
02dbd18b7fe9 Moved all tests into its own modules.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
20 class I
02dbd18b7fe9 Moved all tests into its own modules.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
21 {
02dbd18b7fe9 Moved all tests into its own modules.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
22 Int a;
02dbd18b7fe9 Moved all tests into its own modules.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
23 }
02dbd18b7fe9 Moved all tests into its own modules.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
24
02dbd18b7fe9 Moved all tests into its own modules.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
25 I i;
02dbd18b7fe9 Moved all tests into its own modules.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
26
02dbd18b7fe9 Moved all tests into its own modules.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
27 unittest
02dbd18b7fe9 Moved all tests into its own modules.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
28 {
02dbd18b7fe9 Moved all tests into its own modules.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
29 archive = new XMLArchive!(char);
02dbd18b7fe9 Moved all tests into its own modules.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
30 serializer = new Serializer(archive);
02dbd18b7fe9 Moved all tests into its own modules.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
31
02dbd18b7fe9 Moved all tests into its own modules.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
32 i = new I;
02dbd18b7fe9 Moved all tests into its own modules.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
33 i.a = 1;
02dbd18b7fe9 Moved all tests into its own modules.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
34
02dbd18b7fe9 Moved all tests into its own modules.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
35 describe("serialize typedef") in {
02dbd18b7fe9 Moved all tests into its own modules.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
36 it("should return a serialized typedef") in {
02dbd18b7fe9 Moved all tests into its own modules.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
37 serializer.reset();
02dbd18b7fe9 Moved all tests into its own modules.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
38 serializer.serialize(i);
02dbd18b7fe9 Moved all tests into its own modules.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
39 assert(archive.data().containsDefaultXmlContent());
02dbd18b7fe9 Moved all tests into its own modules.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
40 assert(archive.data().containsXmlTag("object", `runtimeType="tests.Typedef.I" type="I" key="0" id="0"`));
02dbd18b7fe9 Moved all tests into its own modules.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
41 assert(archive.data().containsXmlTag("typedef", `type="Int" key="a" id="2"`));
02dbd18b7fe9 Moved all tests into its own modules.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
42 assert(archive.data().containsXmlTag("int", `key="1" id="3"`, "1"));
02dbd18b7fe9 Moved all tests into its own modules.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
43 };
02dbd18b7fe9 Moved all tests into its own modules.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
44 };
02dbd18b7fe9 Moved all tests into its own modules.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
45
02dbd18b7fe9 Moved all tests into its own modules.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
46 // describe("deserialize typedef") in {
02dbd18b7fe9 Moved all tests into its own modules.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
47 // it("should return a deserialized typedef equal to the original typedef") in {
02dbd18b7fe9 Moved all tests into its own modules.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
48 // auto iDeserialized = serializer.deserialize!(I)(archive.untypedData);
02dbd18b7fe9 Moved all tests into its own modules.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
49 // assert(i.a == iDeserialized.a);
02dbd18b7fe9 Moved all tests into its own modules.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
50 // };
02dbd18b7fe9 Moved all tests into its own modules.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
51 // };
02dbd18b7fe9 Moved all tests into its own modules.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
52 }