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

Contents of /trunk/escript/test/DataVectorTestCase.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: 3997 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 /*
2 *****************************************************************************
3 * *
4 * COPYRIGHT ACcESS - All Rights Reserved *
5 * *
6 * This software is the property of ACcESS. No part of this code *
7 * may be copied in any form or by any means without the expressed written *
8 * consent of ACcESS. Copying, use or modification of this software *
9 * by any unauthorised person is illegal unless that person has a software *
10 * license agreement with ACcESS. *
11 * *
12 *****************************************************************************
13 */
14 #include "escript/DataVector.h"
15 #include "esysUtils/EsysException.h"
16
17 #include "DataVectorTestCase.h"
18
19 #include <iostream>
20
21 using namespace std;
22 using namespace CppUnitTest;
23 using namespace escript;
24 using namespace esysUtils;
25
26 void DataVectorTestCase::setUp() {
27 //
28 // This is called before each test is run
29
30 }
31
32 void DataVectorTestCase::tearDown() {
33 //
34 // This is called after each test has been run
35
36 }
37
38 void DataVectorTestCase::testAll() {
39
40 cout << endl;
41
42 {
43 cout << "\tCreate and check an empty DataVector object." << endl;
44
45 DataVector vec;
46 assert(vec.size() == 0);
47 }
48
49 {
50 cout << "\tCheck DataVector resize operation." << endl;
51
52 DataVector vec;
53 assert(vec.size() == 0);
54
55 vec.resize(1,0,1);
56 assert(vec.size() == 1);
57
58 vec.resize(1000,0,1);
59 assert(vec.size() == 1000);
60
61 vec.resize(0,0,1);
62 assert(vec.size() == 0);
63 }
64
65 {
66 cout << "\tCreate and check DataVector objects of various sizes." << endl;
67
68 DataVector vec1(0,0,1);
69 assert(vec1.size() == 0);
70
71 DataVector vec2(1,0,1);
72 assert(vec2.size() == 1);
73
74 DataVector vec3(1000,0,1);
75 assert(vec3.size() == 1000);
76 }
77
78 {
79 cout << "\tAssign and check various elements to a DataVector." << endl;
80
81 DataVector vec(1000,0,1);
82
83 for (int i=0; i < 1000; i++) {
84 vec[i] = i;
85 }
86
87 for (int i=0; i < 1000; i++) {
88 assert(vec[i] == i);
89 }
90
91 for (int i=0; i < 1000; i++) {
92 vec[i] = i/1000;
93 }
94
95 for (int i=0; i < 1000; i++) {
96 assert(vec[i] == i/1000);
97 }
98 }
99
100 {
101 cout << "\tCheck DataVector copy constructor." << endl;
102
103 DataVector vec1(1000,0,1);
104
105 for (int i=0; i < 1000; i++) {
106 vec1[i] = i;
107 }
108
109 DataVector vec2(vec1);
110
111 assert(vec1.size() == vec2.size());
112
113 for (int i=0; i < 1000; i++) {
114 assert(vec2[i] == i);
115 }
116 }
117
118 {
119 cout << "\tCheck DataVector = operator." << endl;
120
121 DataVector vec1(1000,0,1);
122
123 for (int i=0; i < 1000; i++) {
124 vec1[i] = i;
125 }
126
127 DataVector vec2;
128
129 vec2 = vec1;
130
131 assert(vec1.size() == vec2.size());
132
133 for (int i=0; i < 1000; i++) {
134 assert(vec2[i] == i);
135 }
136 }
137
138 {
139 cout << "\tCheck DataVector == operator." << endl;
140
141 DataVector vec1(1000,0,1);
142
143 for (int i=0; i < 1000; i++) {
144 vec1[i] = i;
145 }
146
147 DataVector vec2;
148
149 vec2 = vec1;
150
151 assert(vec1 == vec2);
152 }
153
154 {
155 cout << "\tCheck DataVector != operator." << endl;
156
157 DataVector vec1(1000,0,1);
158
159 for (int i=0; i < 1000; i++) {
160 vec1[i] = i;
161 }
162
163 DataVector vec2;
164
165 assert(vec1 != vec2);
166 }
167
168 {
169 cout << "\tCheck DataVector index exception." << endl;
170
171 DataVector vec(1000,0,1);
172
173 try {
174 double x = vec[1001];
175 assert(false);
176 }
177
178 catch (EsysException& e) {
179 //cout << e.toString() << endl;
180 assert(true);
181 }
182
183 }
184
185 }
186
187 TestSuite* DataVectorTestCase::suite ()
188 {
189 //
190 // create the suite of tests to perform.
191 TestSuite *testSuite = new TestSuite ("DataVectorTestCase");
192
193 testSuite->addTest (new TestCaller< DataVectorTestCase>("testAll",&DataVectorTestCase::testAll));
194 return testSuite;
195 }
196

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26