Mercurial > projects > orange
annotate tests/Serializer.d @ 36:c523d436052f experimental
Fixed an D1 error in the unit test.
author | Jacob Carlborg <doob@me.com> |
---|---|
date | Wed, 03 Aug 2011 21:45:56 +0200 |
parents | 511d1ef4e299 |
children | 9443bcddc699 |
rev | line source |
---|---|
27 | 1 |
2 /** | |
3 * Copyright: Copyright (c) 2010 Jacob Carlborg. All rights reserved. | |
4 * Authors: Jacob Carlborg | |
5 * Version: Initial created: Nov 5, 2010 | |
6 * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0) | |
7 */ | |
8 module tests.Serializer; | |
9 | |
10 private: | |
11 | |
12 import orange.serialization.Serializer; | |
13 import orange.serialization.archives.XMLArchive; | |
14 import orange.core.io; | |
15 import orange.core.string; | |
16 | |
17 bool containsDefaultXmlContent (string source) | |
18 { | |
19 return source.containsXmlHeader() && | |
20 source.containsArchive() && | |
21 source.containsXmlTag("data"); | |
22 } | |
23 | |
24 bool containsXmlHeader (string source) | |
25 { | |
26 return source.contains(`<?xml version="1.0" encoding="UTF-8"?>`); | |
27 } | |
28 | |
29 bool containsArchive (string source) | |
30 { | |
31 return source.containsArchiveHeader() && source.contains("</archive>"); | |
32 } | |
33 | |
34 bool containsArchiveHeader (string source) | |
35 { | |
35
511d1ef4e299
Now all unit tests pass on latest DMD2 compiler.
Jacob Carlborg <doob@me.com>
parents:
33
diff
changeset
|
36 return source.contains(`<archive type="org.dsource.orange.xml" version="1.0.0">`) || |
511d1ef4e299
Now all unit tests pass on latest DMD2 compiler.
Jacob Carlborg <doob@me.com>
parents:
33
diff
changeset
|
37 source.contains(`<archive version="1.0.0" type="org.dsource.orange.xml">`); |
27 | 38 } |
39 | |
40 bool containsXmlTag (string source, string tag, bool simple = false) | |
41 { | |
42 return source.containsXmlTag(tag, null, null, simple); | |
43 } | |
44 | |
45 bool containsXmlTag (string source, string tag, string attributes, bool simple = false) | |
46 { | |
47 return source.containsXmlTag(tag, attributes, null, simple); | |
48 } | |
49 | |
50 bool containsXmlTag (string source, string tag, string attributes, string content, bool simple = false) | |
51 { | |
52 string pattern = '<' ~ tag; | |
53 | |
54 if (attributes.length > 0) | |
55 pattern ~= ' ' ~ attributes; | |
56 | |
57 if (simple) | |
58 return source.contains(pattern ~ "/>"); | |
33
4fea56a5849f
Now both internal and external pointers work.
Jacob Carlborg <doob@me.com>
parents:
32
diff
changeset
|
59 |
27 | 60 if (content.length > 0) |
61 return source.contains(pattern ~ '>' ~ content ~ "</" ~ tag ~ '>'); | |
33
4fea56a5849f
Now both internal and external pointers work.
Jacob Carlborg <doob@me.com>
parents:
32
diff
changeset
|
62 |
27 | 63 return source.contains(pattern ~ '>') && source.contains("</" ~ tag ~ '>'); |
64 } | |
65 | |
66 enum Foo { a, b, c } | |
67 typedef int Int; | |
68 | |
69 class A | |
70 { | |
71 equals_t opEquals (Object other) | |
72 { | |
73 if (auto o = cast(A) other) | |
74 return true; | |
75 | |
76 return false; | |
77 } | |
78 } | |
79 | |
80 struct B | |
81 { | |
35
511d1ef4e299
Now all unit tests pass on latest DMD2 compiler.
Jacob Carlborg <doob@me.com>
parents:
33
diff
changeset
|
82 version (Tango) |
27 | 83 { |
35
511d1ef4e299
Now all unit tests pass on latest DMD2 compiler.
Jacob Carlborg <doob@me.com>
parents:
33
diff
changeset
|
84 equals_t opEquals (B b) |
511d1ef4e299
Now all unit tests pass on latest DMD2 compiler.
Jacob Carlborg <doob@me.com>
parents:
33
diff
changeset
|
85 { |
511d1ef4e299
Now all unit tests pass on latest DMD2 compiler.
Jacob Carlborg <doob@me.com>
parents:
33
diff
changeset
|
86 return true; |
511d1ef4e299
Now all unit tests pass on latest DMD2 compiler.
Jacob Carlborg <doob@me.com>
parents:
33
diff
changeset
|
87 } |
511d1ef4e299
Now all unit tests pass on latest DMD2 compiler.
Jacob Carlborg <doob@me.com>
parents:
33
diff
changeset
|
88 } |
511d1ef4e299
Now all unit tests pass on latest DMD2 compiler.
Jacob Carlborg <doob@me.com>
parents:
33
diff
changeset
|
89 |
511d1ef4e299
Now all unit tests pass on latest DMD2 compiler.
Jacob Carlborg <doob@me.com>
parents:
33
diff
changeset
|
90 else |
511d1ef4e299
Now all unit tests pass on latest DMD2 compiler.
Jacob Carlborg <doob@me.com>
parents:
33
diff
changeset
|
91 { |
511d1ef4e299
Now all unit tests pass on latest DMD2 compiler.
Jacob Carlborg <doob@me.com>
parents:
33
diff
changeset
|
92 mixin(`bool opEquals (ref const B) const |
511d1ef4e299
Now all unit tests pass on latest DMD2 compiler.
Jacob Carlborg <doob@me.com>
parents:
33
diff
changeset
|
93 { |
511d1ef4e299
Now all unit tests pass on latest DMD2 compiler.
Jacob Carlborg <doob@me.com>
parents:
33
diff
changeset
|
94 return true; |
511d1ef4e299
Now all unit tests pass on latest DMD2 compiler.
Jacob Carlborg <doob@me.com>
parents:
33
diff
changeset
|
95 }`); |
27 | 96 } |
97 } | |
98 | |
35
511d1ef4e299
Now all unit tests pass on latest DMD2 compiler.
Jacob Carlborg <doob@me.com>
parents:
33
diff
changeset
|
99 class C { string str; wstring wstr; dstring dstr; } |
27 | 100 class D { int[] arr; } |
101 class E { int[int] aa; } | |
33
4fea56a5849f
Now both internal and external pointers work.
Jacob Carlborg <doob@me.com>
parents:
32
diff
changeset
|
102 class F { int value; int* ptr; int* ptr2; } |
27 | 103 class G { Foo foo; } |
104 | |
33
4fea56a5849f
Now both internal and external pointers work.
Jacob Carlborg <doob@me.com>
parents:
32
diff
changeset
|
105 int pointee; |
4fea56a5849f
Now both internal and external pointers work.
Jacob Carlborg <doob@me.com>
parents:
32
diff
changeset
|
106 |
27 | 107 class H |
108 { | |
109 bool bool_; | |
110 byte byte_; | |
111 //cdouble cdouble_; // currently not suppported by to!() | |
112 //cent cent_; // currently not implemented but a reserved keyword | |
113 //cfloat cfloat_; // currently not suppported by to!() | |
114 char char_; | |
115 //creal creal_; // currently not suppported by to!() | |
116 dchar dchar_; | |
117 double double_; | |
118 float float_; | |
119 //idouble idouble_; // currently not suppported by to!() | |
120 //ifloat ifloat_; // currently not suppported by to!() | |
121 int int_; | |
122 //ireal ireal_; // currently not suppported by to!() | |
123 long long_; | |
124 real real_; | |
125 short short_; | |
126 ubyte ubyte_; | |
127 //ucent ucent_; // currently not implemented but a reserved keyword | |
128 uint uint_; | |
129 ulong ulong_; | |
130 ushort ushort_; | |
35
511d1ef4e299
Now all unit tests pass on latest DMD2 compiler.
Jacob Carlborg <doob@me.com>
parents:
33
diff
changeset
|
131 |
511d1ef4e299
Now all unit tests pass on latest DMD2 compiler.
Jacob Carlborg <doob@me.com>
parents:
33
diff
changeset
|
132 version (Tango) |
511d1ef4e299
Now all unit tests pass on latest DMD2 compiler.
Jacob Carlborg <doob@me.com>
parents:
33
diff
changeset
|
133 wchar wchar_; // Phobos to!() function can't handle string -> wchar |
27 | 134 |
135 equals_t opEquals (Object other) | |
136 { | |
137 if (auto o = cast(H) other) | |
138 { | |
35
511d1ef4e299
Now all unit tests pass on latest DMD2 compiler.
Jacob Carlborg <doob@me.com>
parents:
33
diff
changeset
|
139 auto result = bool_ == o.bool_ && |
27 | 140 byte_ == o.byte_ && |
141 //cdouble_ == o.cdouble_ && // currently not suppported by to!() | |
142 //cent_ == o.cent_ && // currently not implemented but a reserved keyword | |
143 //cfloat_ == o.cfloat_ && // currently not suppported by to!() | |
144 char_ == o.char_ && | |
145 //creal_ == o.creal_ && // currently not suppported by to!() | |
146 dchar_ == o.dchar_ && | |
147 double_ == o.double_ && | |
148 float_ == o.float_ && | |
149 //idouble_ == o.idouble_ && // currently not suppported by to!() | |
150 //ifloat_ == o.ifloat_ && // currently not suppported by to!() | |
151 int_ == o.int_ && | |
152 //ireal_ == o.ireal_ && // currently not suppported by to!() | |
153 long_ == o.long_ && | |
154 real_ == o.real_ && | |
155 short_ == o.short_ && | |
156 ubyte_ == o.ubyte_ && | |
157 //ucent_ == o.ucent_ && // currently not implemented but a reserved keyword | |
158 uint_ == o.uint_ && | |
159 ulong_ == o.ulong_ && | |
35
511d1ef4e299
Now all unit tests pass on latest DMD2 compiler.
Jacob Carlborg <doob@me.com>
parents:
33
diff
changeset
|
160 ushort_ == o.ushort_; |
511d1ef4e299
Now all unit tests pass on latest DMD2 compiler.
Jacob Carlborg <doob@me.com>
parents:
33
diff
changeset
|
161 |
511d1ef4e299
Now all unit tests pass on latest DMD2 compiler.
Jacob Carlborg <doob@me.com>
parents:
33
diff
changeset
|
162 version (Tango) |
511d1ef4e299
Now all unit tests pass on latest DMD2 compiler.
Jacob Carlborg <doob@me.com>
parents:
33
diff
changeset
|
163 return result && wchar_ == o.wchar_; |
511d1ef4e299
Now all unit tests pass on latest DMD2 compiler.
Jacob Carlborg <doob@me.com>
parents:
33
diff
changeset
|
164 |
511d1ef4e299
Now all unit tests pass on latest DMD2 compiler.
Jacob Carlborg <doob@me.com>
parents:
33
diff
changeset
|
165 else |
511d1ef4e299
Now all unit tests pass on latest DMD2 compiler.
Jacob Carlborg <doob@me.com>
parents:
33
diff
changeset
|
166 return result; |
27 | 167 } |
168 | |
169 return false; | |
170 } | |
171 } | |
172 | |
173 class I | |
174 { | |
175 Int a; | |
176 } | |
177 | |
178 class J | |
179 { | |
35
511d1ef4e299
Now all unit tests pass on latest DMD2 compiler.
Jacob Carlborg <doob@me.com>
parents:
33
diff
changeset
|
180 int[] firstSource; |
511d1ef4e299
Now all unit tests pass on latest DMD2 compiler.
Jacob Carlborg <doob@me.com>
parents:
33
diff
changeset
|
181 int[] firstSlice; |
27 | 182 |
35
511d1ef4e299
Now all unit tests pass on latest DMD2 compiler.
Jacob Carlborg <doob@me.com>
parents:
33
diff
changeset
|
183 int[] secondSlice; |
511d1ef4e299
Now all unit tests pass on latest DMD2 compiler.
Jacob Carlborg <doob@me.com>
parents:
33
diff
changeset
|
184 int[] secondSource; |
27 | 185 } |
186 | |
187 class K | |
188 { | |
189 int[int] a; | |
190 int[int] b; | |
191 } | |
192 | |
193 import orange.test.UnitTester; | |
194 Serializer serializer; | |
195 XMLArchive!(char) archive; | |
196 | |
197 A a; | |
198 B b; | |
199 C c; | |
200 D d; | |
201 E e; | |
202 F f; | |
33
4fea56a5849f
Now both internal and external pointers work.
Jacob Carlborg <doob@me.com>
parents:
32
diff
changeset
|
203 F fDeserialized; |
27 | 204 G g; |
205 H h; | |
206 I i; | |
207 J j; | |
208 J jDeserialized; | |
209 K k; | |
210 | |
211 string data; | |
212 | |
213 unittest | |
214 { | |
215 archive = new XMLArchive!(char); | |
216 serializer = new Serializer(archive); | |
217 | |
218 a = new A; | |
219 | |
220 c = new C; | |
221 c.str = "foo"; | |
35
511d1ef4e299
Now all unit tests pass on latest DMD2 compiler.
Jacob Carlborg <doob@me.com>
parents:
33
diff
changeset
|
222 c.wstr = "bar"; |
511d1ef4e299
Now all unit tests pass on latest DMD2 compiler.
Jacob Carlborg <doob@me.com>
parents:
33
diff
changeset
|
223 c.dstr = "foobar"; |
511d1ef4e299
Now all unit tests pass on latest DMD2 compiler.
Jacob Carlborg <doob@me.com>
parents:
33
diff
changeset
|
224 |
27 | 225 |
226 d = new D; | |
227 d.arr = [27, 382, 283, 3820, 32, 832].dup; | |
228 | |
229 e = new E; | |
230 e.aa = [3 : 4, 1 : 2, 39 : 472, 6 : 7]; | |
231 | |
33
4fea56a5849f
Now both internal and external pointers work.
Jacob Carlborg <doob@me.com>
parents:
32
diff
changeset
|
232 pointee = 3; |
27 | 233 f = new F; |
234 f.value = 9; | |
235 f.ptr = &f.value; | |
33
4fea56a5849f
Now both internal and external pointers work.
Jacob Carlborg <doob@me.com>
parents:
32
diff
changeset
|
236 f.ptr2 = &pointee; |
27 | 237 |
238 g = new G; | |
239 g.foo = Foo.b; | |
240 | |
241 h = new H; | |
242 h.bool_ = true; | |
243 h.byte_ = 1; | |
244 h.char_ = 'a'; | |
245 //h.cdouble_ = 0.0 + 0.0 * 1.0i; // currently not supported by to!() | |
246 //h.cfloat_ = 0.0f + 0.0f * 1.0i; // currently not supported by to!() | |
247 //h.creal_ = 0.0 + 0.0 * 1.0i; // currently not supported by to!() | |
248 h.dchar_ = 'b'; | |
249 h.double_ = 0.0; | |
250 h.float_ = 0.0f; | |
251 //h.idouble_ = 0.0 * 1.0i; // currently not supported by to!() | |
252 //h.ifloat_ = 0.0f * 1.0i; // currently not supported by to!() | |
253 h.int_ = 1; | |
254 //h.ireal_ = 0.0 * 1.0i; // currently not supported by to!() | |
255 h.long_ = 1L; | |
256 h.real_ = 0.0; | |
257 h.short_ = 1; | |
258 h.ubyte_ = 1U; | |
259 h.uint_ = 1U; | |
260 h.ulong_ = 1LU; | |
261 h.ushort_ = 1U; | |
35
511d1ef4e299
Now all unit tests pass on latest DMD2 compiler.
Jacob Carlborg <doob@me.com>
parents:
33
diff
changeset
|
262 |
511d1ef4e299
Now all unit tests pass on latest DMD2 compiler.
Jacob Carlborg <doob@me.com>
parents:
33
diff
changeset
|
263 version (Tango) |
511d1ef4e299
Now all unit tests pass on latest DMD2 compiler.
Jacob Carlborg <doob@me.com>
parents:
33
diff
changeset
|
264 h.wchar_ = 'c'; |
27 | 265 |
266 i = new I; | |
267 i.a = 1; | |
268 | |
269 j = new J; | |
35
511d1ef4e299
Now all unit tests pass on latest DMD2 compiler.
Jacob Carlborg <doob@me.com>
parents:
33
diff
changeset
|
270 j.firstSource = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9].dup; |
27 | 271 j.firstSlice = j.firstSource[3 .. 7]; |
35
511d1ef4e299
Now all unit tests pass on latest DMD2 compiler.
Jacob Carlborg <doob@me.com>
parents:
33
diff
changeset
|
272 j.secondSource = [10, 11, 12, 13, 14, 15].dup; |
27 | 273 j.secondSlice = j.secondSource[1 .. 4]; |
274 | |
275 k = new K; | |
276 k.a = [3 : 4, 1 : 2, 39 : 472, 6 : 7]; | |
277 k.b = k.a; | |
28
bffcbc8c392b
Associative arrays are now treated as references.
Jacob Carlborg <doob@me.com>
parents:
27
diff
changeset
|
278 |
27 | 279 describe("Serializer") in { |
280 describe("serialize object") in { | |
281 it("should return a serialized object") in { | |
282 serializer.reset; | |
283 serializer.serialize(a); | |
35
511d1ef4e299
Now all unit tests pass on latest DMD2 compiler.
Jacob Carlborg <doob@me.com>
parents:
33
diff
changeset
|
284 |
27 | 285 assert(archive.data().containsDefaultXmlContent()); |
286 assert(archive.data().contains(`<object runtimeType="tests.Serializer.A" type="A" key="0" id="0"/>`)); | |
287 }; | |
288 }; | |
289 | |
290 describe("deserialize object") in { | |
291 it("should return a deserialized object equal to the original object") in { | |
292 auto aDeserialized = serializer.deserialize!(A)(archive.data); | |
293 assert(a == aDeserialized); | |
294 }; | |
295 }; | |
296 | |
297 describe("serialize struct") in { | |
298 it("should return a serialized struct") in { | |
299 serializer.reset; | |
300 serializer.serialize(B()); | |
32
9df3b7a46a51
Updated the unit test with the latest changes.
Jacob Carlborg <doob@me.com>
parents:
28
diff
changeset
|
301 |
27 | 302 assert(archive.data().containsDefaultXmlContent()); |
32
9df3b7a46a51
Updated the unit test with the latest changes.
Jacob Carlborg <doob@me.com>
parents:
28
diff
changeset
|
303 assert(archive.data().contains(`<struct type="B" key="0" id="0"/>`)); |
27 | 304 }; |
305 }; | |
306 | |
307 describe("deserialize struct") in { | |
308 it("should return a deserialized struct equal to the original struct") in { | |
309 auto bDeserialized = serializer.deserialize!(B)(archive.data); | |
310 assert(b == bDeserialized); | |
311 }; | |
312 }; | |
313 | |
35
511d1ef4e299
Now all unit tests pass on latest DMD2 compiler.
Jacob Carlborg <doob@me.com>
parents:
33
diff
changeset
|
314 describe("serialize strings") in { |
511d1ef4e299
Now all unit tests pass on latest DMD2 compiler.
Jacob Carlborg <doob@me.com>
parents:
33
diff
changeset
|
315 it("should return serialized strings") in { |
27 | 316 serializer.reset; |
35
511d1ef4e299
Now all unit tests pass on latest DMD2 compiler.
Jacob Carlborg <doob@me.com>
parents:
33
diff
changeset
|
317 serializer.serialize(c); |
27 | 318 |
319 assert(archive.data().containsDefaultXmlContent()); | |
320 assert(archive.data().containsXmlTag("object", `runtimeType="tests.Serializer.C" type="C" key="0" id="0"`)); | |
35
511d1ef4e299
Now all unit tests pass on latest DMD2 compiler.
Jacob Carlborg <doob@me.com>
parents:
33
diff
changeset
|
321 |
36
c523d436052f
Fixed an D1 error in the unit test.
Jacob Carlborg <doob@me.com>
parents:
35
diff
changeset
|
322 version (Tango) string type = "char"; |
c523d436052f
Fixed an D1 error in the unit test.
Jacob Carlborg <doob@me.com>
parents:
35
diff
changeset
|
323 else string type = "immutable(char)"; |
35
511d1ef4e299
Now all unit tests pass on latest DMD2 compiler.
Jacob Carlborg <doob@me.com>
parents:
33
diff
changeset
|
324 |
511d1ef4e299
Now all unit tests pass on latest DMD2 compiler.
Jacob Carlborg <doob@me.com>
parents:
33
diff
changeset
|
325 assert(archive.data().containsXmlTag("string", `type="` ~ type ~ `" length="3" key="str" id="1"`, "foo")); |
511d1ef4e299
Now all unit tests pass on latest DMD2 compiler.
Jacob Carlborg <doob@me.com>
parents:
33
diff
changeset
|
326 |
511d1ef4e299
Now all unit tests pass on latest DMD2 compiler.
Jacob Carlborg <doob@me.com>
parents:
33
diff
changeset
|
327 version (Tango) type = "wchar"; |
511d1ef4e299
Now all unit tests pass on latest DMD2 compiler.
Jacob Carlborg <doob@me.com>
parents:
33
diff
changeset
|
328 else type = "immutable(wchar)"; |
511d1ef4e299
Now all unit tests pass on latest DMD2 compiler.
Jacob Carlborg <doob@me.com>
parents:
33
diff
changeset
|
329 |
511d1ef4e299
Now all unit tests pass on latest DMD2 compiler.
Jacob Carlborg <doob@me.com>
parents:
33
diff
changeset
|
330 assert(archive.data().containsXmlTag("string", `type="` ~ type ~ `" length="3" key="wstr" id="2"`, "bar")); |
511d1ef4e299
Now all unit tests pass on latest DMD2 compiler.
Jacob Carlborg <doob@me.com>
parents:
33
diff
changeset
|
331 |
511d1ef4e299
Now all unit tests pass on latest DMD2 compiler.
Jacob Carlborg <doob@me.com>
parents:
33
diff
changeset
|
332 version (Tango) type = "dchar"; |
511d1ef4e299
Now all unit tests pass on latest DMD2 compiler.
Jacob Carlborg <doob@me.com>
parents:
33
diff
changeset
|
333 else type = "immutable(dchar)"; |
511d1ef4e299
Now all unit tests pass on latest DMD2 compiler.
Jacob Carlborg <doob@me.com>
parents:
33
diff
changeset
|
334 |
511d1ef4e299
Now all unit tests pass on latest DMD2 compiler.
Jacob Carlborg <doob@me.com>
parents:
33
diff
changeset
|
335 assert(archive.data().containsXmlTag("string", `type="` ~ type ~ `" length="6" key="dstr" id="3"`, "foobar")); |
27 | 336 }; |
337 }; | |
338 | |
339 describe("deserialize string") in { | |
340 it("should return a deserialized string equal to the original string") in { | |
341 auto cDeserialized = serializer.deserialize!(C)(archive.data); | |
342 assert(c.str == cDeserialized.str); | |
343 }; | |
344 }; | |
345 | |
346 describe("serialize array") in { | |
347 it("should return a serialized array") in { | |
348 serializer.reset; | |
349 serializer.serialize(d); | |
32
9df3b7a46a51
Updated the unit test with the latest changes.
Jacob Carlborg <doob@me.com>
parents:
28
diff
changeset
|
350 |
27 | 351 assert(archive.data().containsDefaultXmlContent()); |
352 assert(archive.data().containsXmlTag("object", `runtimeType="tests.Serializer.D" type="D" key="0" id="0"`)); | |
32
9df3b7a46a51
Updated the unit test with the latest changes.
Jacob Carlborg <doob@me.com>
parents:
28
diff
changeset
|
353 assert(archive.data().containsXmlTag("array", `type="int" length="6" key="arr" id="1"`)); |
9df3b7a46a51
Updated the unit test with the latest changes.
Jacob Carlborg <doob@me.com>
parents:
28
diff
changeset
|
354 assert(archive.data().containsXmlTag("int", `key="0" id="2"`, "27")); |
9df3b7a46a51
Updated the unit test with the latest changes.
Jacob Carlborg <doob@me.com>
parents:
28
diff
changeset
|
355 assert(archive.data().containsXmlTag("int", `key="1" id="3"`, "382")); |
9df3b7a46a51
Updated the unit test with the latest changes.
Jacob Carlborg <doob@me.com>
parents:
28
diff
changeset
|
356 assert(archive.data().containsXmlTag("int", `key="2" id="4"`, "283")); |
9df3b7a46a51
Updated the unit test with the latest changes.
Jacob Carlborg <doob@me.com>
parents:
28
diff
changeset
|
357 assert(archive.data().containsXmlTag("int", `key="3" id="5"`, "3820")); |
9df3b7a46a51
Updated the unit test with the latest changes.
Jacob Carlborg <doob@me.com>
parents:
28
diff
changeset
|
358 assert(archive.data().containsXmlTag("int", `key="4" id="6"`, "32")); |
9df3b7a46a51
Updated the unit test with the latest changes.
Jacob Carlborg <doob@me.com>
parents:
28
diff
changeset
|
359 assert(archive.data().containsXmlTag("int", `key="5" id="7"`, "832")); |
27 | 360 }; |
361 }; | |
362 | |
363 describe("deserialize array") in { | |
364 it("should return a deserialize array equal to the original array") in { | |
365 auto dDeserialized = serializer.deserialize!(D)(archive.data); | |
366 assert(d.arr == dDeserialized.arr); | |
367 }; | |
368 }; | |
369 | |
370 describe("serialize associative array") in { | |
371 it("should return a serialized associative array") in { | |
372 serializer.reset(); | |
373 serializer.serialize(e); | |
35
511d1ef4e299
Now all unit tests pass on latest DMD2 compiler.
Jacob Carlborg <doob@me.com>
parents:
33
diff
changeset
|
374 |
27 | 375 assert(archive.data().containsDefaultXmlContent()); |
376 assert(archive.data().containsXmlTag("object", `runtimeType="tests.Serializer.E" type="E" key="0" id="0"`)); | |
35
511d1ef4e299
Now all unit tests pass on latest DMD2 compiler.
Jacob Carlborg <doob@me.com>
parents:
33
diff
changeset
|
377 version (Tango) assert(archive.data().containsXmlTag("associativeArray", `keyType="int" valueType="int" length="4" key="aa" id="1"`)); |
32
9df3b7a46a51
Updated the unit test with the latest changes.
Jacob Carlborg <doob@me.com>
parents:
28
diff
changeset
|
378 |
27 | 379 assert(archive.data().containsXmlTag("key", `key="0"`)); |
32
9df3b7a46a51
Updated the unit test with the latest changes.
Jacob Carlborg <doob@me.com>
parents:
28
diff
changeset
|
380 assert(archive.data().containsXmlTag("int", `key="0" id="2"`, "1")); |
27 | 381 assert(archive.data().containsXmlTag("value", `key="0"`)); |
32
9df3b7a46a51
Updated the unit test with the latest changes.
Jacob Carlborg <doob@me.com>
parents:
28
diff
changeset
|
382 assert(archive.data().containsXmlTag("int", `key="0" id="3"`, "2")); |
27 | 383 |
384 assert(archive.data().containsXmlTag("key", `key="1"`)); | |
32
9df3b7a46a51
Updated the unit test with the latest changes.
Jacob Carlborg <doob@me.com>
parents:
28
diff
changeset
|
385 assert(archive.data().containsXmlTag("int", `key="1" id="4"`, "3")); |
27 | 386 assert(archive.data().containsXmlTag("value", `key="1"`)); |
32
9df3b7a46a51
Updated the unit test with the latest changes.
Jacob Carlborg <doob@me.com>
parents:
28
diff
changeset
|
387 assert(archive.data().containsXmlTag("int", `key="1" id="5"`, "4")); |
27 | 388 |
389 assert(archive.data().containsXmlTag("key", `key="2"`)); | |
32
9df3b7a46a51
Updated the unit test with the latest changes.
Jacob Carlborg <doob@me.com>
parents:
28
diff
changeset
|
390 assert(archive.data().containsXmlTag("int", `key="2" id="6"`, "6")); |
27 | 391 assert(archive.data().containsXmlTag("value", `key="2"`)); |
32
9df3b7a46a51
Updated the unit test with the latest changes.
Jacob Carlborg <doob@me.com>
parents:
28
diff
changeset
|
392 assert(archive.data().containsXmlTag("int", `key="2" id="7"`, "7")); |
27 | 393 |
394 assert(archive.data().containsXmlTag("key", `key="3"`)); | |
32
9df3b7a46a51
Updated the unit test with the latest changes.
Jacob Carlborg <doob@me.com>
parents:
28
diff
changeset
|
395 assert(archive.data().containsXmlTag("int", `key="3" id="8"`, "39")); |
27 | 396 assert(archive.data().containsXmlTag("value", `key="3"`)); |
32
9df3b7a46a51
Updated the unit test with the latest changes.
Jacob Carlborg <doob@me.com>
parents:
28
diff
changeset
|
397 assert(archive.data().containsXmlTag("int", `key="3" id="9"`, "472")); |
27 | 398 }; |
399 }; | |
400 | |
401 describe("deserialize associative array") in { | |
402 it("should return an associative array equal to the original associative array") in { | |
403 auto eDeserialized = serializer.deserialize!(E)(archive.data); | |
404 | |
405 foreach (k, v ; eDeserialized.aa) | |
406 assert(e.aa[k] == v); | |
407 | |
408 //assert(e.aa == eDeserialized.aa); // cannot compare associative array | |
409 }; | |
410 }; | |
411 | |
412 describe("serialize pointer") in { | |
413 it("should return a serialized pointer") in { | |
414 serializer.reset(); | |
415 serializer.serialize(f); | |
32
9df3b7a46a51
Updated the unit test with the latest changes.
Jacob Carlborg <doob@me.com>
parents:
28
diff
changeset
|
416 |
27 | 417 assert(archive.data().containsDefaultXmlContent()); |
418 assert(archive.data().containsXmlTag("object", `runtimeType="tests.Serializer.F" type="F" key="0" id="0"`)); | |
419 assert(archive.data().containsXmlTag("pointer", `key="ptr" id="2"`)); | |
33
4fea56a5849f
Now both internal and external pointers work.
Jacob Carlborg <doob@me.com>
parents:
32
diff
changeset
|
420 assert(archive.data().containsXmlTag("reference", `key="1"`, "1")); |
32
9df3b7a46a51
Updated the unit test with the latest changes.
Jacob Carlborg <doob@me.com>
parents:
28
diff
changeset
|
421 assert(archive.data().containsXmlTag("int", `key="value" id="1"`, "9")); |
27 | 422 }; |
423 }; | |
424 | |
425 describe("deserialize pointer") in { | |
33
4fea56a5849f
Now both internal and external pointers work.
Jacob Carlborg <doob@me.com>
parents:
32
diff
changeset
|
426 fDeserialized = serializer.deserialize!(F)(archive.data); |
4fea56a5849f
Now both internal and external pointers work.
Jacob Carlborg <doob@me.com>
parents:
32
diff
changeset
|
427 |
27 | 428 it("should return a deserialized pointer equal to the original pointer") in { |
429 assert(*f.ptr == *fDeserialized.ptr); | |
430 }; | |
33
4fea56a5849f
Now both internal and external pointers work.
Jacob Carlborg <doob@me.com>
parents:
32
diff
changeset
|
431 |
4fea56a5849f
Now both internal and external pointers work.
Jacob Carlborg <doob@me.com>
parents:
32
diff
changeset
|
432 it("the pointer should point to the deserialized value") in { |
4fea56a5849f
Now both internal and external pointers work.
Jacob Carlborg <doob@me.com>
parents:
32
diff
changeset
|
433 assert(fDeserialized.ptr == &fDeserialized.value); |
4fea56a5849f
Now both internal and external pointers work.
Jacob Carlborg <doob@me.com>
parents:
32
diff
changeset
|
434 }; |
27 | 435 }; |
436 | |
437 describe("serialize enum") in { | |
438 it("should return a serialized enum") in { | |
439 serializer.reset(); | |
440 serializer.serialize(g); | |
32
9df3b7a46a51
Updated the unit test with the latest changes.
Jacob Carlborg <doob@me.com>
parents:
28
diff
changeset
|
441 |
27 | 442 assert(archive.data().containsDefaultXmlContent()); |
443 assert(archive.data().containsXmlTag("object", `runtimeType="tests.Serializer.G" type="G" key="0" id="0"`)); | |
32
9df3b7a46a51
Updated the unit test with the latest changes.
Jacob Carlborg <doob@me.com>
parents:
28
diff
changeset
|
444 assert(archive.data().containsXmlTag("enum", `type="Foo" baseType="int" key="foo" id="1"`, "1")); |
27 | 445 }; |
446 }; | |
447 | |
448 | |
449 describe("deserialize enum") in { | |
450 it("should return an enum equal to the original enum") in { | |
451 auto gDeserialized = serializer.deserialize!(G)(archive.data); | |
452 assert(g.foo == gDeserialized.foo); | |
453 }; | |
454 }; | |
455 | |
456 describe("serialize primitives") in { | |
457 it("should return serialized primitives") in { | |
458 serializer.reset; | |
459 serializer.serialize(h); | |
32
9df3b7a46a51
Updated the unit test with the latest changes.
Jacob Carlborg <doob@me.com>
parents:
28
diff
changeset
|
460 |
27 | 461 assert(archive.data().containsDefaultXmlContent()); |
462 assert(archive.data().containsXmlTag("object", `runtimeType="tests.Serializer.H" type="H" key="0" id="0"`)); | |
32
9df3b7a46a51
Updated the unit test with the latest changes.
Jacob Carlborg <doob@me.com>
parents:
28
diff
changeset
|
463 assert(archive.data().containsXmlTag("bool", `key="bool_" id="1"`, "true")); |
9df3b7a46a51
Updated the unit test with the latest changes.
Jacob Carlborg <doob@me.com>
parents:
28
diff
changeset
|
464 assert(archive.data().containsXmlTag("byte", `key="byte_" id="2"`, "1")); |
9df3b7a46a51
Updated the unit test with the latest changes.
Jacob Carlborg <doob@me.com>
parents:
28
diff
changeset
|
465 assert(archive.data().containsXmlTag("char", `key="char_" id="3"`, "a")); |
9df3b7a46a51
Updated the unit test with the latest changes.
Jacob Carlborg <doob@me.com>
parents:
28
diff
changeset
|
466 assert(archive.data().containsXmlTag("dchar", `key="dchar_" id="4"`, "b")); |
9df3b7a46a51
Updated the unit test with the latest changes.
Jacob Carlborg <doob@me.com>
parents:
28
diff
changeset
|
467 assert(archive.data().containsXmlTag("double", `key="double_" id="5"`, "0")); |
9df3b7a46a51
Updated the unit test with the latest changes.
Jacob Carlborg <doob@me.com>
parents:
28
diff
changeset
|
468 assert(archive.data().containsXmlTag("float", `key="float_" id="6"`, "0")); |
9df3b7a46a51
Updated the unit test with the latest changes.
Jacob Carlborg <doob@me.com>
parents:
28
diff
changeset
|
469 assert(archive.data().containsXmlTag("int", `key="int_" id="7"`, "1")); |
9df3b7a46a51
Updated the unit test with the latest changes.
Jacob Carlborg <doob@me.com>
parents:
28
diff
changeset
|
470 assert(archive.data().containsXmlTag("long", `key="long_" id="8"`, "1")); |
9df3b7a46a51
Updated the unit test with the latest changes.
Jacob Carlborg <doob@me.com>
parents:
28
diff
changeset
|
471 assert(archive.data().containsXmlTag("real", `key="real_" id="9"`, "0")); |
9df3b7a46a51
Updated the unit test with the latest changes.
Jacob Carlborg <doob@me.com>
parents:
28
diff
changeset
|
472 assert(archive.data().containsXmlTag("short", `key="short_" id="10"`, "1")); |
9df3b7a46a51
Updated the unit test with the latest changes.
Jacob Carlborg <doob@me.com>
parents:
28
diff
changeset
|
473 assert(archive.data().containsXmlTag("ubyte", `key="ubyte_" id="11"`, "1")); |
9df3b7a46a51
Updated the unit test with the latest changes.
Jacob Carlborg <doob@me.com>
parents:
28
diff
changeset
|
474 assert(archive.data().containsXmlTag("uint", `key="uint_" id="12"`, "1")); |
9df3b7a46a51
Updated the unit test with the latest changes.
Jacob Carlborg <doob@me.com>
parents:
28
diff
changeset
|
475 assert(archive.data().containsXmlTag("ulong", `key="ulong_" id="13"`, "1")); |
9df3b7a46a51
Updated the unit test with the latest changes.
Jacob Carlborg <doob@me.com>
parents:
28
diff
changeset
|
476 assert(archive.data().containsXmlTag("ushort", `key="ushort_" id="14"`, "1")); |
35
511d1ef4e299
Now all unit tests pass on latest DMD2 compiler.
Jacob Carlborg <doob@me.com>
parents:
33
diff
changeset
|
477 |
511d1ef4e299
Now all unit tests pass on latest DMD2 compiler.
Jacob Carlborg <doob@me.com>
parents:
33
diff
changeset
|
478 version (Tango) |
511d1ef4e299
Now all unit tests pass on latest DMD2 compiler.
Jacob Carlborg <doob@me.com>
parents:
33
diff
changeset
|
479 assert(archive.data().containsXmlTag("wchar", `key="wchar_" id="15"`, "c")); |
27 | 480 }; |
481 }; | |
482 | |
483 describe("deserialize primitives") in { | |
484 it("should return deserialized primitives equal to the original primitives") in { | |
485 auto hDeserialized = serializer.deserialize!(H)(archive.data); | |
486 assert(h == hDeserialized); | |
487 }; | |
488 }; | |
489 | |
490 describe("serialize typedef") in { | |
491 it("should return a serialized typedef") in { | |
492 serializer.reset(); | |
493 serializer.serialize(i); | |
494 assert(archive.data().containsDefaultXmlContent()); | |
495 assert(archive.data().containsXmlTag("object", `runtimeType="tests.Serializer.I" type="I" key="0" id="0"`)); | |
32
9df3b7a46a51
Updated the unit test with the latest changes.
Jacob Carlborg <doob@me.com>
parents:
28
diff
changeset
|
496 assert(archive.data().containsXmlTag("typedef", `type="Int" key="a" id="2"`)); |
9df3b7a46a51
Updated the unit test with the latest changes.
Jacob Carlborg <doob@me.com>
parents:
28
diff
changeset
|
497 assert(archive.data().containsXmlTag("int", `key="1" id="3"`, "1")); |
27 | 498 }; |
499 }; | |
500 | |
33
4fea56a5849f
Now both internal and external pointers work.
Jacob Carlborg <doob@me.com>
parents:
32
diff
changeset
|
501 // describe("deserialize typedef") in { |
4fea56a5849f
Now both internal and external pointers work.
Jacob Carlborg <doob@me.com>
parents:
32
diff
changeset
|
502 // it("should return a deserialized typedef equal to the original typedef") in { |
4fea56a5849f
Now both internal and external pointers work.
Jacob Carlborg <doob@me.com>
parents:
32
diff
changeset
|
503 // auto iDeserialized = serializer.deserialize!(I)(archive.data); |
4fea56a5849f
Now both internal and external pointers work.
Jacob Carlborg <doob@me.com>
parents:
32
diff
changeset
|
504 // assert(i.a == iDeserialized.a); |
4fea56a5849f
Now both internal and external pointers work.
Jacob Carlborg <doob@me.com>
parents:
32
diff
changeset
|
505 // }; |
4fea56a5849f
Now both internal and external pointers work.
Jacob Carlborg <doob@me.com>
parents:
32
diff
changeset
|
506 // }; |
27 | 507 |
508 describe("serialize slices") in { | |
509 it("should return serialized slices") in { | |
510 serializer.reset(); | |
511 serializer.serialize(j); | |
512 | |
513 assert(archive.data().containsDefaultXmlContent()); | |
514 assert(archive.data().containsXmlTag("object", `runtimeType="tests.Serializer.J" type="J" key="0" id="0"`)); | |
35
511d1ef4e299
Now all unit tests pass on latest DMD2 compiler.
Jacob Carlborg <doob@me.com>
parents:
33
diff
changeset
|
515 assert(archive.data().containsXmlTag("array", `type="int" length="10" key="firstSource" id="1"`)); |
511d1ef4e299
Now all unit tests pass on latest DMD2 compiler.
Jacob Carlborg <doob@me.com>
parents:
33
diff
changeset
|
516 |
511d1ef4e299
Now all unit tests pass on latest DMD2 compiler.
Jacob Carlborg <doob@me.com>
parents:
33
diff
changeset
|
517 assert(archive.data().containsXmlTag("int", `key="0" id="2"`, "0")); |
511d1ef4e299
Now all unit tests pass on latest DMD2 compiler.
Jacob Carlborg <doob@me.com>
parents:
33
diff
changeset
|
518 assert(archive.data().containsXmlTag("int", `key="1" id="3"`, "1")); |
511d1ef4e299
Now all unit tests pass on latest DMD2 compiler.
Jacob Carlborg <doob@me.com>
parents:
33
diff
changeset
|
519 assert(archive.data().containsXmlTag("int", `key="2" id="4"`, "2")); |
511d1ef4e299
Now all unit tests pass on latest DMD2 compiler.
Jacob Carlborg <doob@me.com>
parents:
33
diff
changeset
|
520 assert(archive.data().containsXmlTag("int", `key="3" id="5"`, "3")); |
511d1ef4e299
Now all unit tests pass on latest DMD2 compiler.
Jacob Carlborg <doob@me.com>
parents:
33
diff
changeset
|
521 assert(archive.data().containsXmlTag("int", `key="4" id="6"`, "4")); |
511d1ef4e299
Now all unit tests pass on latest DMD2 compiler.
Jacob Carlborg <doob@me.com>
parents:
33
diff
changeset
|
522 assert(archive.data().containsXmlTag("int", `key="5" id="7"`, "5")); |
511d1ef4e299
Now all unit tests pass on latest DMD2 compiler.
Jacob Carlborg <doob@me.com>
parents:
33
diff
changeset
|
523 assert(archive.data().containsXmlTag("int", `key="6" id="8"`, "6")); |
511d1ef4e299
Now all unit tests pass on latest DMD2 compiler.
Jacob Carlborg <doob@me.com>
parents:
33
diff
changeset
|
524 assert(archive.data().containsXmlTag("int", `key="7" id="9"`, "7")); |
511d1ef4e299
Now all unit tests pass on latest DMD2 compiler.
Jacob Carlborg <doob@me.com>
parents:
33
diff
changeset
|
525 assert(archive.data().containsXmlTag("int", `key="8" id="10"`, "8")); |
511d1ef4e299
Now all unit tests pass on latest DMD2 compiler.
Jacob Carlborg <doob@me.com>
parents:
33
diff
changeset
|
526 assert(archive.data().containsXmlTag("int", `key="9" id="11"`, "9")); |
511d1ef4e299
Now all unit tests pass on latest DMD2 compiler.
Jacob Carlborg <doob@me.com>
parents:
33
diff
changeset
|
527 |
511d1ef4e299
Now all unit tests pass on latest DMD2 compiler.
Jacob Carlborg <doob@me.com>
parents:
33
diff
changeset
|
528 version (Tango) |
511d1ef4e299
Now all unit tests pass on latest DMD2 compiler.
Jacob Carlborg <doob@me.com>
parents:
33
diff
changeset
|
529 { |
511d1ef4e299
Now all unit tests pass on latest DMD2 compiler.
Jacob Carlborg <doob@me.com>
parents:
33
diff
changeset
|
530 assert(archive.data().containsXmlTag("slice", `key="firstSlice" offset="3" length="4"`, "1")); |
511d1ef4e299
Now all unit tests pass on latest DMD2 compiler.
Jacob Carlborg <doob@me.com>
parents:
33
diff
changeset
|
531 assert(archive.data().containsXmlTag("slice", `key="secondSlice" offset="1" length="3"`, "21")); |
511d1ef4e299
Now all unit tests pass on latest DMD2 compiler.
Jacob Carlborg <doob@me.com>
parents:
33
diff
changeset
|
532 } |
511d1ef4e299
Now all unit tests pass on latest DMD2 compiler.
Jacob Carlborg <doob@me.com>
parents:
33
diff
changeset
|
533 |
511d1ef4e299
Now all unit tests pass on latest DMD2 compiler.
Jacob Carlborg <doob@me.com>
parents:
33
diff
changeset
|
534 assert(archive.data().containsXmlTag("array", `type="int" length="6" key="secondSource" id="21"`)); |
511d1ef4e299
Now all unit tests pass on latest DMD2 compiler.
Jacob Carlborg <doob@me.com>
parents:
33
diff
changeset
|
535 |
511d1ef4e299
Now all unit tests pass on latest DMD2 compiler.
Jacob Carlborg <doob@me.com>
parents:
33
diff
changeset
|
536 assert(archive.data().containsXmlTag("int", `key="0" id="22"`, "10")); |
511d1ef4e299
Now all unit tests pass on latest DMD2 compiler.
Jacob Carlborg <doob@me.com>
parents:
33
diff
changeset
|
537 assert(archive.data().containsXmlTag("int", `key="1" id="23"`, "11")); |
511d1ef4e299
Now all unit tests pass on latest DMD2 compiler.
Jacob Carlborg <doob@me.com>
parents:
33
diff
changeset
|
538 assert(archive.data().containsXmlTag("int", `key="2" id="24"`, "12")); |
511d1ef4e299
Now all unit tests pass on latest DMD2 compiler.
Jacob Carlborg <doob@me.com>
parents:
33
diff
changeset
|
539 assert(archive.data().containsXmlTag("int", `key="3" id="25"`, "13")); |
511d1ef4e299
Now all unit tests pass on latest DMD2 compiler.
Jacob Carlborg <doob@me.com>
parents:
33
diff
changeset
|
540 assert(archive.data().containsXmlTag("int", `key="4" id="26"`, "14")); |
511d1ef4e299
Now all unit tests pass on latest DMD2 compiler.
Jacob Carlborg <doob@me.com>
parents:
33
diff
changeset
|
541 assert(archive.data().containsXmlTag("int", `key="5" id="27"`, "15")); |
27 | 542 }; |
543 }; | |
544 | |
545 describe("deserialize slices") in { | |
546 jDeserialized = serializer.deserialize!(J)(archive.data); | |
547 | |
548 it("should return deserialized strings equal to the original strings") in { | |
549 assert(j.firstSource == jDeserialized.firstSource); | |
550 assert(j.secondSource == jDeserialized.secondSource); | |
551 }; | |
552 | |
553 it("should return deserialized slices equal to the original slices") in { | |
554 assert(j.firstSlice == jDeserialized.firstSlice); | |
555 assert(j.secondSlice == jDeserialized.secondSlice); | |
556 }; | |
557 | |
558 it("the slices should be equal to a slice of the original sources") in { | |
559 assert(jDeserialized.firstSource[3 .. 7] == jDeserialized.firstSlice); | |
560 assert(jDeserialized.secondSource[1 .. 4] == jDeserialized.secondSlice); | |
561 | |
562 assert(j.firstSource[3 .. 7] == jDeserialized.firstSlice); | |
563 assert(j.secondSource[1 .. 4] == jDeserialized.secondSlice); | |
564 }; | |
565 | |
566 it("the slices should be able to modify the sources") in { | |
35
511d1ef4e299
Now all unit tests pass on latest DMD2 compiler.
Jacob Carlborg <doob@me.com>
parents:
33
diff
changeset
|
567 jDeserialized.firstSlice[0] = 55; |
511d1ef4e299
Now all unit tests pass on latest DMD2 compiler.
Jacob Carlborg <doob@me.com>
parents:
33
diff
changeset
|
568 jDeserialized.secondSlice[0] = 3; |
27 | 569 |
35
511d1ef4e299
Now all unit tests pass on latest DMD2 compiler.
Jacob Carlborg <doob@me.com>
parents:
33
diff
changeset
|
570 assert(jDeserialized.firstSource == [0, 1, 2, 55, 4, 5, 6, 7, 8, 9]); |
511d1ef4e299
Now all unit tests pass on latest DMD2 compiler.
Jacob Carlborg <doob@me.com>
parents:
33
diff
changeset
|
571 assert(jDeserialized.secondSource == [10, 3, 12, 13, 14, 15]); |
27 | 572 }; |
573 }; | |
574 | |
28
bffcbc8c392b
Associative arrays are now treated as references.
Jacob Carlborg <doob@me.com>
parents:
27
diff
changeset
|
575 describe("serialize associative array references") in { |
bffcbc8c392b
Associative arrays are now treated as references.
Jacob Carlborg <doob@me.com>
parents:
27
diff
changeset
|
576 it("should return a serialized associative array and a serialized reference") in { |
27 | 577 serializer.reset(); |
578 serializer.serialize(k); | |
35
511d1ef4e299
Now all unit tests pass on latest DMD2 compiler.
Jacob Carlborg <doob@me.com>
parents:
33
diff
changeset
|
579 |
28
bffcbc8c392b
Associative arrays are now treated as references.
Jacob Carlborg <doob@me.com>
parents:
27
diff
changeset
|
580 assert(archive.data().containsDefaultXmlContent()); |
bffcbc8c392b
Associative arrays are now treated as references.
Jacob Carlborg <doob@me.com>
parents:
27
diff
changeset
|
581 assert(archive.data().containsXmlTag("object", `runtimeType="tests.Serializer.K" type="K" key="0" id="0"`)); |
35
511d1ef4e299
Now all unit tests pass on latest DMD2 compiler.
Jacob Carlborg <doob@me.com>
parents:
33
diff
changeset
|
582 version (Tango) assert(archive.data().containsXmlTag("associativeArray", `keyType="int" valueType="int" length="4" key="a" id="1"`)); |
32
9df3b7a46a51
Updated the unit test with the latest changes.
Jacob Carlborg <doob@me.com>
parents:
28
diff
changeset
|
583 |
28
bffcbc8c392b
Associative arrays are now treated as references.
Jacob Carlborg <doob@me.com>
parents:
27
diff
changeset
|
584 assert(archive.data().containsXmlTag("key", `key="0"`)); |
32
9df3b7a46a51
Updated the unit test with the latest changes.
Jacob Carlborg <doob@me.com>
parents:
28
diff
changeset
|
585 assert(archive.data().containsXmlTag("int", `key="0" id="2"`, "1")); |
28
bffcbc8c392b
Associative arrays are now treated as references.
Jacob Carlborg <doob@me.com>
parents:
27
diff
changeset
|
586 assert(archive.data().containsXmlTag("value", `key="0"`)); |
32
9df3b7a46a51
Updated the unit test with the latest changes.
Jacob Carlborg <doob@me.com>
parents:
28
diff
changeset
|
587 assert(archive.data().containsXmlTag("int", `key="0" id="3"`, "2")); |
28
bffcbc8c392b
Associative arrays are now treated as references.
Jacob Carlborg <doob@me.com>
parents:
27
diff
changeset
|
588 |
bffcbc8c392b
Associative arrays are now treated as references.
Jacob Carlborg <doob@me.com>
parents:
27
diff
changeset
|
589 assert(archive.data().containsXmlTag("key", `key="1"`)); |
32
9df3b7a46a51
Updated the unit test with the latest changes.
Jacob Carlborg <doob@me.com>
parents:
28
diff
changeset
|
590 assert(archive.data().containsXmlTag("int", `key="1" id="4"`, "3")); |
28
bffcbc8c392b
Associative arrays are now treated as references.
Jacob Carlborg <doob@me.com>
parents:
27
diff
changeset
|
591 assert(archive.data().containsXmlTag("value", `key="1"`)); |
32
9df3b7a46a51
Updated the unit test with the latest changes.
Jacob Carlborg <doob@me.com>
parents:
28
diff
changeset
|
592 assert(archive.data().containsXmlTag("int", `key="1" id="5"`, "4")); |
28
bffcbc8c392b
Associative arrays are now treated as references.
Jacob Carlborg <doob@me.com>
parents:
27
diff
changeset
|
593 |
bffcbc8c392b
Associative arrays are now treated as references.
Jacob Carlborg <doob@me.com>
parents:
27
diff
changeset
|
594 assert(archive.data().containsXmlTag("key", `key="2"`)); |
32
9df3b7a46a51
Updated the unit test with the latest changes.
Jacob Carlborg <doob@me.com>
parents:
28
diff
changeset
|
595 assert(archive.data().containsXmlTag("int", `key="2" id="6"`, "6")); |
28
bffcbc8c392b
Associative arrays are now treated as references.
Jacob Carlborg <doob@me.com>
parents:
27
diff
changeset
|
596 assert(archive.data().containsXmlTag("value", `key="2"`)); |
32
9df3b7a46a51
Updated the unit test with the latest changes.
Jacob Carlborg <doob@me.com>
parents:
28
diff
changeset
|
597 assert(archive.data().containsXmlTag("int", `key="2" id="7"`, "7")); |
28
bffcbc8c392b
Associative arrays are now treated as references.
Jacob Carlborg <doob@me.com>
parents:
27
diff
changeset
|
598 |
bffcbc8c392b
Associative arrays are now treated as references.
Jacob Carlborg <doob@me.com>
parents:
27
diff
changeset
|
599 assert(archive.data().containsXmlTag("key", `key="3"`)); |
32
9df3b7a46a51
Updated the unit test with the latest changes.
Jacob Carlborg <doob@me.com>
parents:
28
diff
changeset
|
600 assert(archive.data().containsXmlTag("int", `key="3" id="8"`, "39")); |
28
bffcbc8c392b
Associative arrays are now treated as references.
Jacob Carlborg <doob@me.com>
parents:
27
diff
changeset
|
601 assert(archive.data().containsXmlTag("value", `key="3"`)); |
32
9df3b7a46a51
Updated the unit test with the latest changes.
Jacob Carlborg <doob@me.com>
parents:
28
diff
changeset
|
602 assert(archive.data().containsXmlTag("int", `key="3" id="9"`, "472")); |
28
bffcbc8c392b
Associative arrays are now treated as references.
Jacob Carlborg <doob@me.com>
parents:
27
diff
changeset
|
603 |
bffcbc8c392b
Associative arrays are now treated as references.
Jacob Carlborg <doob@me.com>
parents:
27
diff
changeset
|
604 assert(archive.data().containsXmlTag("reference", `key="b"`, "1")); |
bffcbc8c392b
Associative arrays are now treated as references.
Jacob Carlborg <doob@me.com>
parents:
27
diff
changeset
|
605 }; |
bffcbc8c392b
Associative arrays are now treated as references.
Jacob Carlborg <doob@me.com>
parents:
27
diff
changeset
|
606 }; |
bffcbc8c392b
Associative arrays are now treated as references.
Jacob Carlborg <doob@me.com>
parents:
27
diff
changeset
|
607 |
bffcbc8c392b
Associative arrays are now treated as references.
Jacob Carlborg <doob@me.com>
parents:
27
diff
changeset
|
608 describe("deserialize associative array references") in { |
bffcbc8c392b
Associative arrays are now treated as references.
Jacob Carlborg <doob@me.com>
parents:
27
diff
changeset
|
609 it("should return two deserialized associative arrays pointing to the same data") in { |
bffcbc8c392b
Associative arrays are now treated as references.
Jacob Carlborg <doob@me.com>
parents:
27
diff
changeset
|
610 auto kDeserialized = serializer.deserialize!(K)(archive.data); |
bffcbc8c392b
Associative arrays are now treated as references.
Jacob Carlborg <doob@me.com>
parents:
27
diff
changeset
|
611 |
bffcbc8c392b
Associative arrays are now treated as references.
Jacob Carlborg <doob@me.com>
parents:
27
diff
changeset
|
612 assert(kDeserialized.a is kDeserialized.b); |
27 | 613 }; |
614 }; | |
615 }; | |
616 } |