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

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

Parent Directory Parent Directory | Revision Log Revision Log


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

1 jgs 102 // $Id$
2 jgs 82 /*
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 jgs 102
41 jgs 82 cout << endl;
42 jgs 102
43 jgs 108 cout << "\tTesting FMax." << endl;
44 jgs 106
45 jgs 108 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 jgs 106 sup.resetResult();
53 jgs 108 sup(-1);
54     sup(-2);
55     sup(-14);
56 jgs 106 sup(3);
57 jgs 108 assert(sup.getResult()==3);
58 jgs 102
59     cout << "\tTesting AbsMax." << endl;
60 jgs 108
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 jgs 102 DataAlgorithmAdapter<AbsMax> Lsup(0);
68 jgs 106 Lsup.resetResult();
69 jgs 82 Lsup(-2);
70     Lsup(2);
71     Lsup(5);
72 jgs 102 Lsup(-10);
73     assert(Lsup.getResult()==10);
74    
75     cout << "\tTesting FMin." << endl;
76 jgs 108
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 jgs 82 DataAlgorithmAdapter<FMin> inf(numeric_limits<double>::max());
84 jgs 106 inf.resetResult();
85 jgs 82 inf(1);
86 jgs 102 inf(12);
87 jgs 82 inf(2);
88 jgs 102 inf(99);
89     assert(inf.getResult()==1);
90    
91 jgs 106 cout << "\tTesting Length." << endl;
92 jgs 108
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 jgs 106 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 jgs 102
113 jgs 106 cout << "\tTesting Trace." << endl;
114 jgs 108
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 jgs 106 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 jgs 82 }
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