Arbint class implemented
[ipdf/code.git] / src / tests / saveload.cpp
1 #include "main.h"
2 #include <unistd.h>
3 unsigned test_objects = 4;
4
5 void Cleanup()
6 {
7         unlink("saveload.ipdf");
8 }
9
10 int main(int argc, char ** argv)
11 {
12         Debug("TEST STARTING %s", argv[0]);
13         atexit(Cleanup);
14         srand(time(NULL));
15         Document doc;
16         for (unsigned id = 0; id < test_objects; ++id)
17         {
18                 doc.Add((ObjectType)(rand() % 2), Rect(Random(), Random(), Random(), Random()));
19         }
20         doc.Save("saveload.ipdf");
21
22         Document equ("saveload.ipdf");
23         //doc.Add(Random(), Random(), Random(), Random());
24         if (doc != equ || equ != doc)
25         {
26                 Error("Loaded document is not equivelant to saved document!");
27                 doc.DebugDumpObjects();
28                 equ.DebugDumpObjects();
29                 Fatal("TEST FAILED");
30         }
31         
32         doc.Add((ObjectType)(0), Rect());
33         if (doc == equ)
34         {
35                 Error("Modified document is still equilant to saved document!?");
36                 doc.DebugDumpObjects();
37                 equ.DebugDumpObjects();
38                 Fatal("TEST FAILED");
39         }
40         Debug("TEST SUCCESSFUL");
41         // Cleanup
42
43         return 0;
44 }
45
46

UCC git Repository :: git.ucc.asn.au