1 /** 2 * Copyright: Copyright (c) 2011 Jacob Carlborg. All rights reserved. 3 * Authors: Jacob Carlborg 4 * Version: Initial created: Aug 6, 2011 5 * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0) 6 */ 7 module tests.NonCopyableStruct; 8 9 import orange.serialization.Serializer; 10 import orange.serialization.archives.XmlArchive; 11 import orange.test.UnitTester; 12 import tests.Util; 13 14 Serializer serializer; 15 XmlArchive!(char) archive; 16 17 struct B 18 { 19 @disable this(this); 20 @disable ref B opAssign () (auto ref B other); 21 22 bool opEquals (ref const B) const 23 { 24 return true; 25 } 26 } 27 28 B b; 29 30 unittest 31 { 32 archive = new XmlArchive!(char); 33 serializer = new Serializer(archive); 34 35 describe("serialize struct") in { 36 it("should return a serialized struct") in { 37 auto expected = q"xml 38 <?xml version="1.0" encoding="UTF-8"?> 39 <archive version="1.0.0" type="org.dsource.orange.xml"> 40 <data> 41 <struct type="tests.Struct.B" key="0" id="0"/> 42 </data> 43 </archive> 44 xml"; 45 serializer.reset; 46 serializer.serialize(B()); 47 48 assert(expected.equalToXml(archive.data)); 49 }; 50 }; 51 52 describe("deserialize struct") in { 53 it("should return a deserialized struct equal to the original struct") in { 54 auto bDeserialized = serializer.deserialize!(B)(archive.untypedData); 55 assert(b == bDeserialized); 56 }; 57 }; 58 }