/[escript]/trunk/escript/test/DataAlgorithmAdapter/DataAlgorithmAdapterTestCase.cpp
ViewVC logotype

Contents of /trunk/escript/test/DataAlgorithmAdapter/DataAlgorithmAdapterTestCase.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 108 - (show annotations)
Thu Jan 27 06:21:59 2005 UTC (15 years, 11 months ago) by jgs
Original Path: trunk/esys2/escript/test/DataAlgorithmAdapter/DataAlgorithmAdapterTestCase.cpp
File size: 3611 byte(s)
*** empty log message ***

1 // $Id$
2 /*
3 *****************************************************************************
4 * *
5 * COPYRIGHT ACcESS - All Rights Reserved *
6 * *
7 * This software is the property of ACcESS. No part of this code *
8 * may be copied in any form or by any means without the expressed written *
9 * consent of ACcESS. Copying, use or modification of this software *
10 * by any unauthorised person is illegal unless that person has a software *
11 * license agreement with ACcESS. *
12 * *
13 *****************************************************************************
14 */
15 #include "escript/Data/DataAlgorithm.h"
16 #include "DataAlgorithmAdapterTestCase.h"
17
18 #include <iostream>
19 #include <algorithm>
20 #include <math.h>
21 #include <limits>
22
23 using namespace CppUnitTest;
24 using namespace std;
25 using namespace escript;
26
27 void DataAlgorithmAdapterTestCase::setUp() {
28 //
29 // This is called before each test is run
30
31 }
32
33 void DataAlgorithmAdapterTestCase::tearDown() {
34 //
35 // This is called after each test has been run
36
37 }
38
39 void DataAlgorithmAdapterTestCase::testAll() {
40
41 cout << endl;
42
43 cout << "\tTesting FMax." << endl;
44
45 FMax fmax;
46 assert(fmax(5,6)==6);
47 assert(fmax(5,-6)==5);
48 assert(fmax(0,0)==0);
49 assert(fmax(15,-96)==15);
50
51 DataAlgorithmAdapter<FMax> sup(numeric_limits<double>::max()*-1);
52 sup.resetResult();
53 sup(-1);
54 sup(-2);
55 sup(-14);
56 sup(3);
57 assert(sup.getResult()==3);
58
59 cout << "\tTesting AbsMax." << endl;
60
61 AbsMax absmax;
62 assert(absmax(5,6)==6);
63 assert(absmax(5,-6)==6);
64 assert(absmax(0,0)==0);
65 assert(absmax(15,-96)==96);
66
67 DataAlgorithmAdapter<AbsMax> Lsup(0);
68 Lsup.resetResult();
69 Lsup(-2);
70 Lsup(2);
71 Lsup(5);
72 Lsup(-10);
73 assert(Lsup.getResult()==10);
74
75 cout << "\tTesting FMin." << endl;
76
77 FMin fmin;
78 assert(fmin(5,6)==5);
79 assert(fmin(5,-6)==-6);
80 assert(fmin(0,0)==0);
81 assert(fmin(15,-96)==-96);
82
83 DataAlgorithmAdapter<FMin> inf(numeric_limits<double>::max());
84 inf.resetResult();
85 inf(1);
86 inf(12);
87 inf(2);
88 inf(99);
89 assert(inf.getResult()==1);
90
91 cout << "\tTesting Length." << endl;
92
93 Length lngth;
94 assert(lngth(5,6)==std::sqrt(61.0));
95 assert(lngth(5,-6)==std::sqrt(61.0));
96 assert(lngth(0,0)==std::sqrt(0.0));
97 assert(lngth(15,-96)==std::sqrt(9441.0));
98
99 DataAlgorithmAdapter<Length> length(0);
100 length.resetResult();
101 length(2);
102 length(4);
103 length(6);
104 length(8);
105 assert(length.getResult()==std::sqrt(120.0));
106 length.resetResult();
107 length(1.5);
108 length(2.5);
109 length(3.5);
110 length(4.5);
111 assert(length.getResult()==std::sqrt(41.0));
112
113 cout << "\tTesting Trace." << endl;
114
115 Trace trce;
116 assert(trce(5,6)==11);
117 assert(trce(5,-6)==-1);
118 assert(trce(0,0)==0);
119 assert(trce(15,-96)==-81);
120
121 DataAlgorithmAdapter<Trace> trace(0);
122 trace.resetResult();
123 trace(1);
124 trace(2);
125 trace(3);
126 trace(4);
127 trace(5);
128 assert(trace.getResult()==15);
129 trace.resetResult();
130 trace(1.5);
131 trace(2.5);
132 trace(3.5);
133 trace(4.5);
134 trace(5.5);
135 assert(trace.getResult()==17.5);
136
137 }
138
139 TestSuite* DataAlgorithmAdapterTestCase::suite ()
140 {
141 //
142 // create the suite of tests to perform.
143 TestSuite *testSuite = new TestSuite ("DataAlgorithmAdapterTestCase");
144
145 testSuite->addTest (new TestCaller< DataAlgorithmAdapterTestCase>("testAll",&DataAlgorithmAdapterTestCase::testAll));
146 return testSuite;
147 }
148

Properties

Name Value
svn:eol-style native
svn:keywords Author Date Id Revision

  ViewVC Help
Powered by ViewVC 1.1.26