1 | #include "mod2.h" |
---|
2 | |
---|
3 | #ifdef HAVE_WRAPPERS |
---|
4 | |
---|
5 | #include <iostream> |
---|
6 | #include "RingWrapper.h" |
---|
7 | #include "PolyWrapper.h" |
---|
8 | #include "Wrappers.h" |
---|
9 | #include "febase.h" |
---|
10 | |
---|
11 | void test1 (); |
---|
12 | void test2 (); |
---|
13 | void test3 (); |
---|
14 | |
---|
15 | PrettyPrinter prpr("", "", false, false, -1, " "); |
---|
16 | |
---|
17 | void testWrappers (bool detailedOutput) |
---|
18 | { |
---|
19 | prpr.setConsole(detailedOutput ? 0 : -1); |
---|
20 | prpr+1; |
---|
21 | |
---|
22 | test1(); |
---|
23 | test2(); |
---|
24 | test3(); |
---|
25 | |
---|
26 | prpr-1; |
---|
27 | PrintLn(); |
---|
28 | PrintLn(); |
---|
29 | } |
---|
30 | |
---|
31 | void test1 () |
---|
32 | { |
---|
33 | PrintLn(); |
---|
34 | PrintS("Test1: Creation and destruction of instances of RingWrapper"); |
---|
35 | const char* theVariables1[2] = {"x", "y"}; |
---|
36 | RingWrapper r1("myRing1", 7, 2, theVariables1, "dp"); |
---|
37 | PrintLn(); PrintS("r1 = "); r1.print(); |
---|
38 | const char* theVariables2[3] = {"u", "v", "w"}; |
---|
39 | RingWrapper r2("myRing2", 0, 3, theVariables2, "Ds"); |
---|
40 | PrintLn(); PrintS("r2 = "); r2.print(); |
---|
41 | } |
---|
42 | |
---|
43 | void test2 () |
---|
44 | { |
---|
45 | PrintLn(); |
---|
46 | PrintS("Test2: Creation, copying, assignment, and destruction of instances of PolyWrapper"); |
---|
47 | const char* theVariables[2] = {"x", "y"}; |
---|
48 | RingWrapper r("myRing", 0, 2, theVariables, "lp"); |
---|
49 | PrintLn(); PrintS("r = "); r.print(); |
---|
50 | PolyWrapper p1(4, r); |
---|
51 | PrintLn(); PrintS("p1 = "); p1.print(); |
---|
52 | PolyWrapper p2(p1); |
---|
53 | PrintLn(); PrintS("p2 = "); p2.print(); |
---|
54 | PolyWrapper p3(-37, r); |
---|
55 | PrintLn(); PrintS("p3 = "); p3.print(); |
---|
56 | PolyWrapper p4(p3); |
---|
57 | PrintLn(); PrintS("p4 = "); p4.print(); |
---|
58 | PolyWrapper p5 = p2; |
---|
59 | PrintLn(); PrintS("p5 = "); p5.print(); |
---|
60 | } |
---|
61 | |
---|
62 | void test3 () |
---|
63 | { |
---|
64 | PrintLn(); |
---|
65 | PrintS("Test3: Addition of instances of PolyWrapper"); |
---|
66 | const char* theVariables[2] = {"x", "y"}; |
---|
67 | RingWrapper r("myRing", 0, 2, theVariables, "Ds"); |
---|
68 | PrintLn(); PrintS("r = "); r.print(); |
---|
69 | PolyWrapper p1(4, r); |
---|
70 | PrintLn(); PrintS("p1 = "); p1.print(); |
---|
71 | PolyWrapper p2(7, r); |
---|
72 | PrintLn(); PrintS("p2 = "); p2.print(); |
---|
73 | PolyWrapper p3 = p1 + p2; |
---|
74 | PrintLn(); PrintS("p3 = "); p3.print(); |
---|
75 | p3 = p1; |
---|
76 | PrintLn(); PrintS("p3 = "); p3.print(); |
---|
77 | p3 += p2; // this should change p3 but NOT p2! |
---|
78 | PrintLn(); PrintS("p3 = "); p3.print(); |
---|
79 | PrintLn(); PrintS("p2 = "); p2.print(); |
---|
80 | } |
---|
81 | |
---|
82 | #endif // HAVE_WRAPPERS |
---|