/[escript]/trunk/escript/test/DataBlocks2DTestCase.cpp
ViewVC logotype

Contents of /trunk/escript/test/DataBlocks2DTestCase.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 682 - (show annotations)
Mon Mar 27 02:43:09 2006 UTC (13 years, 6 months ago) by robwdcock
File size: 6002 byte(s)
+ NEW BUILD SYSTEM

This commit contains the new build system with cross-platform support.
Most things work are before though you can have more control.

ENVIRONMENT settings have changed:
+ You no longer require LD_LIBRARY_PATH or PYTHONPATH to point to the
esysroot for building and testing performed via scons
+ ACcESS altix users: It is recommended you change your modules to load
the latest intel compiler and other libraries required by boost to match
the setup in svn (you can override). The correct modules are as follows

module load intel_cc.9.0.026
export
MODULEPATH=${MODULEPATH}:/data/raid2/toolspp4/modulefiles/gcc-3.3.6
module load boost/1.33.0/python-2.4.1
module load python/2.4.1
module load numarray/1.3.3


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
16 #include "escript/DataBlocks2D.h"
17 #include "esysUtils/EsysException.h"
18
19 #include "DataBlocks2DTestCase.h"
20
21 #include <iostream>
22
23 using namespace std;
24 using namespace CppUnitTest;
25 using namespace escript;
26 using namespace esysUtils;
27
28 void DataBlocks2DTestCase::setUp() {
29 //
30 // This is called before each test is run
31
32 }
33
34 void DataBlocks2DTestCase::tearDown() {
35 //
36 // This is called after each test has been run
37
38 }
39
40 void DataBlocks2DTestCase::testAll() {
41
42 cout << endl;
43
44 cout << "\tTest DataBlocks2D constructor for various dimension values:" << endl;
45
46 {
47 cout << "\t\tnumRows = 1, numCols = 1, blockSize = 20." << endl;
48 int numRows=1;
49 int numCols=1;
50 int blockSize=20;
51 DataBlocks2D myData(numRows,numCols,blockSize);
52 int i = numRows-1;
53 int j = numCols-1;
54 assert(myData.index(i,j) == (i*numCols+j)*blockSize);
55 assert(myData.size() == numRows*numCols*blockSize);
56 }
57
58 {
59 cout << "\t\tnumRows = 3, numCols = 5, blockSize = 20." << endl;
60 int numRows=3;
61 int numCols=5;
62 int blockSize=20;
63 DataBlocks2D myData(numRows,numCols,blockSize);
64 int i = numRows-1;
65 int j = numCols-1;
66 assert(myData.index(i,j) == (i*numCols+j)*blockSize);
67 assert(myData.size() == numRows*numCols*blockSize);
68 }
69
70 {
71 cout << "\t\tnumRows = 3, numCols = 5, blockSize = 1." << endl;
72 int numRows=3;
73 int numCols=5;
74 int blockSize=1;
75 DataBlocks2D myData(numRows,numCols,blockSize);
76 int i = numRows-1;
77 int j = numCols-1;
78 assert(myData.index(i,j) == (i*numCols+j)*blockSize);
79 assert(myData.size() == numRows*numCols*blockSize);
80 }
81
82 {
83 cout << "\t\tnumRows = 1, numCols = 1, blockSize = 1." << endl;
84 int numRows=1;
85 int numCols=1;
86 int blockSize=1;
87 DataBlocks2D myData(numRows,numCols,blockSize);
88 int i = numRows-1;
89 int j = numCols-1;
90 assert(myData.index(i,j) == (i*numCols+j)*blockSize);
91 assert(myData.size() == numRows*numCols*blockSize);
92 }
93
94 {
95 cout << "\tTest DataBlocks2D.index and DataBlocks2D operator[] for blockSize = 3." << endl;
96 int numRows=10;
97 int numCols=8;
98 int blockSize=3;
99 DataBlocks2D myData(numRows,numCols,blockSize);
100 int val=0;
101 for (int i=0; i<numRows; i++) {
102 for (int j=0; j<numCols; j++) {
103 for (int k=0; k<blockSize; k++) {
104 myData[myData.index(i,j)+k] = val;
105 val++;
106 }
107 }
108 }
109 val=0;
110 for (int i=0; i<numRows; i++) {
111 for (int j=0; j<numCols; j++) {
112 for (int k=0; k<blockSize; k++) {
113 assert(myData[myData.index(i,j)+k] == val);
114 val++;
115 }
116 }
117 }
118 }
119
120 {
121 cout << "\tTest DataBlocks2D exception for numRows = 0." << endl;
122 int numRows=0;
123 int numCols=8;
124 int blockSize=10;
125 try {
126 DataBlocks2D myData(numRows,numCols,blockSize);
127 assert(false);
128 }
129 catch(EsysException& e) {
130 assert(true);
131 }
132 }
133
134 {
135 cout << "\tTest DataBlocks2D exception for numCols = 0." << endl;
136 int numRows=10;
137 int numCols=0;
138 int blockSize=10;
139 try {
140 DataBlocks2D myData(numRows,numCols,blockSize);
141 assert(false);
142 }
143 catch(EsysException& e) {
144 assert(true);
145 }
146 }
147
148 {
149 cout << "\tTest DataBlocks2D exception for blockSize = 0." << endl;
150 int numRows=10;
151 int numCols=8;
152 int blockSize=0;
153 try {
154 DataBlocks2D myData(numRows,numCols,blockSize);
155 assert(false);
156 }
157 catch(EsysException& e) {
158 assert(true);
159 }
160 }
161
162 {
163 cout << "\tTest getNumRows, getNumCols and getBlockSize." << endl;
164 int numRows=1;
165 int numCols=1;
166 int blockSize=1;
167 DataBlocks2D myData(numRows,numCols,blockSize);
168 assert(myData.getNumRows() == numRows);
169 assert(myData.getNumCols() == numCols);
170 assert(myData.getBlockSize() == blockSize);
171 }
172
173 {
174 cout << "\tTest resize." << endl;
175 int numRows=1;
176 int numCols=1;
177 int blockSize=1;
178 DataBlocks2D myData;
179 myData.resize(numRows,numCols,blockSize);
180 assert(myData.getNumRows() == numRows);
181 assert(myData.getNumCols() == numCols);
182 assert(myData.getBlockSize() == blockSize);
183 }
184
185 {
186 cout << "\tTest = operator, swap, and copy constructor." << endl;
187 DataBlocks2D myData1;
188 DataBlocks2D myData2(1, 1, 1);
189 int val=0;
190 for (int i=0; i<1; i++) {
191 for (int j=0; j<1; j++) {
192 for (int k=0; k<1; k++) {
193 myData2[myData2.index(i,j)+k] = val;
194 val++;
195 }
196 }
197 }
198 myData1 = myData2;
199 for (int i=0; i<myData1.getNumRows(); i++) {
200 for (int j=0; j<myData1.getNumCols(); j++) {
201 assert(myData1(i,j) == myData2(i,j));
202 }
203 }
204 }
205
206 {
207 cout << "\tTest DOASSERT exception." << endl;
208 DataBlocks2D myData;
209 try {
210 myData.index(1,2);
211 assert(false);
212 }
213 catch (EsysException& e) {
214 assert(true);
215 }
216 }
217
218 }
219
220 TestSuite* DataBlocks2DTestCase::suite ()
221 {
222 //
223 // create the suite of tests to perform.
224 TestSuite *testSuite = new TestSuite ("DataBlocks2DTestCase");
225
226 testSuite->addTest (new TestCaller< DataBlocks2DTestCase>("testAll",&DataBlocks2DTestCase::testAll));
227 return testSuite;
228 }

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26