diff tests/Serializer.d @ 33:4fea56a5849f experimental

Now both internal and external pointers work.
author Jacob Carlborg <doob@me.com>
date Sun, 31 Jul 2011 17:56:44 +0200
parents 9df3b7a46a51
children 511d1ef4e299
line wrap: on
line diff
--- a/tests/Serializer.d	Sun Nov 21 18:51:05 2010 +0100
+++ b/tests/Serializer.d	Sun Jul 31 17:56:44 2011 +0200
@@ -55,10 +55,10 @@
 	
 	if (simple)
 		return source.contains(pattern ~ "/>");
-	
+
 	if (content.length > 0)
 		return source.contains(pattern ~ '>' ~ content ~ "</" ~ tag ~ '>');
-	
+
 	return source.contains(pattern ~ '>') && source.contains("</" ~ tag ~ '>');
 }
 
@@ -87,9 +87,11 @@
 class C { string str; }
 class D { int[] arr; }
 class E { int[int] aa; }
-class F { int value; int* ptr; }
+class F { int value; int* ptr; int* ptr2; }
 class G { Foo foo; }
 
+int pointee;
+
 class H
 {
 	bool bool_;
@@ -179,6 +181,7 @@
 D d;
 E e;
 F f;
+F fDeserialized;
 G g;
 H h;
 I i;
@@ -204,9 +207,11 @@
 	e = new E;
 	e.aa = [3 : 4, 1 : 2, 39 : 472, 6 : 7];
 	
+	pointee = 3;
 	f = new F;
 	f.value = 9;
 	f.ptr = &f.value;
+	f.ptr2 = &pointee;
 	
 	g = new G;
 	g.foo = Foo.b;
@@ -374,17 +379,21 @@
 				assert(archive.data().containsDefaultXmlContent());
 				assert(archive.data().containsXmlTag("object", `runtimeType="tests.Serializer.F" type="F" key="0" id="0"`));
 				assert(archive.data().containsXmlTag("pointer", `key="ptr" id="2"`));
-				assert(archive.data().containsXmlTag("reference", null, "1"));
+				assert(archive.data().containsXmlTag("reference", `key="1"`, "1"));
 				assert(archive.data().containsXmlTag("int", `key="value" id="1"`, "9"));
 			};
 		};
 		
 		describe("deserialize pointer") in {
+			fDeserialized = serializer.deserialize!(F)(archive.data);
+
 			it("should return a deserialized pointer equal to the original pointer") in {
-				auto fDeserialized = serializer.deserialize!(F)(archive.data);
-
 				assert(*f.ptr == *fDeserialized.ptr);
 			};
+			
+			it("the pointer should point to the deserialized value") in {
+				assert(fDeserialized.ptr == &fDeserialized.value);
+			};
 		};
 		
 		describe("serialize enum") in {
@@ -449,12 +458,12 @@
 			};
 		};
 		
-		describe("deserialize typedef") in {
-			it("should return a deserialized typedef equal to the original typedef") in {
-				auto iDeserialized = serializer.deserialize!(I)(archive.data);
-				assert(i.a == iDeserialized.a);
-			};
-		};
+		// describe("deserialize typedef") in {
+		// 	it("should return a deserialized typedef equal to the original typedef") in {
+		// 		auto iDeserialized = serializer.deserialize!(I)(archive.data);
+		// 		assert(i.a == iDeserialized.a);
+		// 	};
+		// };
 		
 		describe("serialize slices") in {
 			it("should return serialized slices") in {