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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3597 - (show annotations)
Thu Sep 15 06:03:17 2011 UTC (8 years, 3 months ago) by caltinay
File size: 42148 byte(s)
Switching to external cppunit:
-removed tools/CppUnitTest
-updated scons script and files
-updated tests to changed API
-updated readme

Bumped scons options file version to 201. Additions:
-cppunit*
-boomeramg*
-vsl_random


1
2 /*******************************************************
3 *
4 * Copyright (c) 2003-2010 by University of Queensland
5 * Earth Systems Science Computational Center (ESSCC)
6 * http://www.uq.edu.au/esscc
7 *
8 * Primary Business: Queensland, Australia
9 * Licensed under the Open Software License version 3.0
10 * http://www.opensource.org/licenses/osl-3.0.php
11 *
12 *******************************************************/
13
14
15 #include "DataTypesTestCase.h"
16 #include "escript/DataAlgorithm.h"
17 #include "escript/DataTypes.h"
18 #include "escript/DataVector.h"
19 #include "esysUtils/EsysException.h"
20
21 #include <cppunit/TestCaller.h>
22 #include <iostream>
23
24 using namespace CppUnit;
25 using namespace esysUtils;
26 using namespace escript;
27 using namespace escript::DataTypes;
28 using namespace std;
29
30
31 void DataTypesTestCase::testShapeFns()
32 {
33 cout << "\n\tTest Shape functions." << endl;
34 ShapeType shape;
35 shape.push_back(2);
36 ShapeType s1=shape;
37 CPPUNIT_ASSERT(checkShape(s1,shape));
38 shape.push_back(3);
39 ShapeType s2=shape;
40 CPPUNIT_ASSERT(checkShape(s2,shape));
41 shape.push_back(4);
42 ShapeType s3=shape;
43 CPPUNIT_ASSERT(checkShape(s3,shape));
44 ShapeType s4=shape;
45 s4.push_back(5);
46
47 cout << "\t\tNumber of Values." << endl;
48 CPPUNIT_ASSERT(noValues(shape)==24);
49 CPPUNIT_ASSERT(noValues(scalarShape)==1);
50 cout << "\t\tGet Rank." << endl;
51 CPPUNIT_ASSERT(getRank(scalarShape)==0);
52 CPPUNIT_ASSERT(getRank(shape)==3);
53
54
55 cout << "\t\tNumber of Values for RegionLoopRangeType." << endl;
56 RegionLoopRangeType rlr;
57 CPPUNIT_ASSERT(noValues(rlr)==1);
58 rlr.push_back(std::pair<int,int>(0,2));
59 CPPUNIT_ASSERT(noValues(rlr)==2);
60 rlr.push_back(std::pair<int,int>(1,4));
61 CPPUNIT_ASSERT(noValues(rlr)==6);
62 rlr.push_back(std::pair<int,int>(2,7));
63 CPPUNIT_ASSERT(noValues(rlr)==30);
64 cout << "\t\tRelative index methods.\n";
65 CPPUNIT_ASSERT(getRelIndex(s1,1)==1);
66 CPPUNIT_ASSERT(getRelIndex(s2,1,2)==5);
67 CPPUNIT_ASSERT(getRelIndex(shape,1,1,1)==9);
68 CPPUNIT_ASSERT(getRelIndex(s4,2,1,1,1)==34);
69 cout << "\t\tCreateShapeErrorMessage.\n";
70 CPPUNIT_ASSERT(createShapeErrorMessage("prefix",s1,s2)==string("prefix This shape: (2,3) Other shape: (2)"));
71
72 cout << "\t\tgetSliceRegionLoopRange." << endl;
73 RegionType r;
74 r.push_back(std::pair<int,int>(1,1));
75 r.push_back(std::pair<int,int>(0,3));
76 r.push_back(std::pair<int,int>(0,3));
77 RegionLoopRangeType rl;
78 rl.push_back(std::pair<int,int>(1,2));
79 rl.push_back(std::pair<int,int>(0,3));
80 rl.push_back(std::pair<int,int>(0,3));
81 RegionLoopRangeType rt=getSliceRegionLoopRange(r);
82 CPPUNIT_ASSERT(rt==rl);
83
84
85 #ifdef DOASSERT
86 // The errors we are testing for are triggered by ESysAssert which is only defined when DOASSERT is.
87
88 cout << "\t\tInvalid index.(too many)" << endl;
89 // test too many indices
90 CPPUNIT_ASSERT_THROW(getRelIndex(s1,1,1), EsysException);
91 CPPUNIT_ASSERT_THROW(getRelIndex(s2,1,1,1), EsysException);
92 CPPUNIT_ASSERT_THROW(getRelIndex(s3,1,1,1,1), EsysException);
93 // too few inidicies
94 cout << "\t\tInvalid index.(too few)" << endl;
95 CPPUNIT_ASSERT_THROW(getRelIndex(s2,1), EsysException);
96 CPPUNIT_ASSERT_THROW(getRelIndex(s3,1,1), EsysException);
97 // indices too large
98 cout << "\t\tInvalid index.(too large for shape)" << endl;
99 CPPUNIT_ASSERT_THROW(getRelIndex(s1,10), EsysException);
100 CPPUNIT_ASSERT_THROW(getRelIndex(s3,2,4,4), EsysException);
101 #endif
102 }
103
104 void DataTypesTestCase::testResultSliceShape() {
105
106 cout << endl;
107 cout << "\tTest getResultSliceShape method." << endl;
108
109 DataTypes::RegionType region;
110 DataTypes::ShapeType resultShape;
111
112 region.push_back(DataTypes::RegionType::value_type(1,5));
113 resultShape.push_back(4);
114 CPPUNIT_ASSERT(DataTypes::getResultSliceShape(region)==resultShape);
115
116 region.push_back(DataTypes::RegionType::value_type(2,5));
117 resultShape.push_back(3);
118 CPPUNIT_ASSERT(DataTypes::getResultSliceShape(region)==resultShape);
119
120 region.push_back(DataTypes::RegionType::value_type(3,9));
121 resultShape.push_back(6);
122 CPPUNIT_ASSERT(DataTypes::getResultSliceShape(region)==resultShape);
123
124 region.push_back(DataTypes::RegionType::value_type(1,7));
125 resultShape.push_back(6);
126 CPPUNIT_ASSERT(DataTypes::getResultSliceShape(region)==resultShape);
127
128 }
129
130 void DataTypesTestCase::testSlicing() {
131
132 using namespace DataTypes;
133 {
134
135 cout << endl;
136 cout << "\tSlice a scalar to a scalar.";
137
138 // Define slice region.
139 DataTypes::RegionType region;
140
141 // Define shape of views.
142 DataTypes::ShapeType sourceShape;
143
144 // Create source and target views.
145 int len = DataTypes::noValues(sourceShape);
146 DataVector sourceData(len, 2.0, len);
147 // DataArrayView sourceView(sourceData, sourceShape);
148 DataVector targetData(1, 2.0, 1);
149 // DataArrayView targetView(targetData, DataTypes::ShapeType());
150
151 // Copy source view to target view.
152 // targetView.copySlice(sourceView,region);
153
154
155 DataTypes::copySlice(targetData, DataTypes::scalarShape, 0, sourceData, sourceShape, 0,region);
156
157 // Check results of copy.
158 // CPPUNIT_ASSERT(sourceView==targetView);
159 CPPUNIT_ASSERT(targetData==sourceData);
160 }
161
162 {
163 cout << endl;
164 cout << "\tSlice a scalar from a scalar.";
165
166 // Define slice region.
167 DataTypes::RegionType region;
168
169 // Define shape of views.
170 DataTypes::ShapeType sourceShape;
171
172 // Create source and target views.
173 int len = DataTypes::noValues(sourceShape);
174 DataVector sourceData(len, 2.0, len);
175 // DataArrayView sourceView(sourceData, sourceShape);
176 DataVector targetData(1, 2.0, 1);
177 // DataArrayView targetView(targetData, DataTypes::ShapeType());
178
179 // Copy source view to target view.
180 DataTypes::copySliceFrom(targetData, DataTypes::scalarShape, 0, sourceData, sourceShape, 0,region);
181
182 // Check results of copy.
183 // CPPUNIT_ASSERT(sourceView==targetView);
184 CPPUNIT_ASSERT(sourceData==targetData);
185 }
186
187 {
188 cout << endl;
189 cout << "\tSlice a 1 dimensional slice to a 1 dimensional array.";
190
191 // Define slice region.
192 DataTypes::RegionType region;
193 region.push_back(DataTypes::RegionType::value_type(2,4));
194
195 // Define shapes of views.
196 DataTypes::ShapeType sourceShape;
197 sourceShape.push_back(6);
198 DataTypes::ShapeType targetShape = DataTypes::getResultSliceShape(region);
199
200 // Create source and target views.
201 int len = DataTypes::noValues(sourceShape);
202 DataVector sourceData(len, 2.0, len);
203 //DataArrayView sourceView(sourceData, sourceShape);
204 for (int i=0;i<sourceShape[0];i++) {
205 sourceData[i]=i;
206 }
207
208 len = DataTypes::noValues(targetShape);
209 DataVector targetData(len, 2.0, len);
210 //DataArrayView targetView(targetData, targetShape);
211
212 // Copy source view to target view.
213 // targetView.copySlice(sourceView,region);
214 DataTypes::copySlice(targetData, targetShape,0,sourceData, sourceShape,0,region);
215
216 // Check results of copy.
217 for (int i=region[0].first;i<region[0].second;i++) {
218 // CPPUNIT_ASSERT(sourceView(i)==
219 // targetView(i-region[0].first));
220 CPPUNIT_ASSERT(sourceData[i]==targetData[i-region[0].first]);
221 }
222 }
223
224 {
225 cout << endl;
226 cout << "\tSlice a 1 dimensional slice to a scalar.";
227
228 // Define slice region.
229 DataTypes::RegionType region;
230 region.push_back(DataTypes::RegionType::value_type(2,3));
231
232 // Define shapes of views.
233 DataTypes::ShapeType sourceShape;
234 sourceShape.push_back(6);
235 DataTypes::ShapeType targetShape;
236
237 // Create source and target views.
238 int len = DataTypes::noValues(sourceShape);
239 DataVector sourceData(len, 2.0, len);
240 // DataArrayView sourceView(sourceData, sourceShape);
241
242 for (int i=0;i<sourceShape[0];i++) {
243 sourceData[i]=i;
244 }
245
246 len = DataTypes::noValues(targetShape);
247 DataVector targetData(len, 2.0, len);
248 // DataArrayView targetView(targetData, targetShape);
249
250 // Copy source view to target view.
251 // targetView.copySlice(sourceView,region);
252 DataTypes::copySlice(targetData, targetShape, 0, sourceData, sourceShape,0,region);
253
254 // Check results of copy.
255 for (int i=region[0].first;i<region[0].second;i++) {
256 /* CPPUNIT_ASSERT(sourceView(i)==
257 targetView());*/
258 CPPUNIT_ASSERT(sourceData[i]==
259 targetData[0]);
260
261 }
262 }
263
264 {
265 cout << endl;
266 cout << "\tSlice a 1 dimensional slice from a 1 dimensional array.";
267
268 // Define slice region.
269 DataTypes::RegionType region;
270 region.push_back(DataTypes::RegionType::value_type(2,4));
271
272 // Define shapes of views.
273 DataTypes::ShapeType sourceShape = DataTypes::getResultSliceShape(region);
274 DataTypes::ShapeType targetShape;
275 targetShape.push_back(6);
276
277 // Create source and target views.
278 int len = DataTypes::noValues(sourceShape);
279 DataVector sourceData(len, 2.0, len);
280 // DataArrayView sourceView(sourceData, sourceShape);
281 for (int i=0;i<sourceShape[0];i++) {
282 sourceData[i]=i;
283 }
284
285 len = DataTypes::noValues(targetShape);
286 DataVector targetData(len, 2.0, len);
287 // DataArrayView targetView(targetData, targetShape);
288
289 // Copy source view to target view.
290 // targetView.copySliceFrom(sourceView,region);
291 DataTypes::copySliceFrom(targetData,targetShape,0,sourceData, sourceShape, 0,region);
292
293 // Check results of copy.
294 for (int i=region[0].first;i<region[0].second;i++) {
295 /* CPPUNIT_ASSERT(sourceView(i-region[0].first)==
296 targetView(i));*/
297 CPPUNIT_ASSERT(sourceData[i-region[0].first]==
298 targetData[i]);
299 }
300 }
301
302 {
303 cout << endl;
304 cout << "\tSlice a 1 dimensional slice from a scalar.";
305
306 // Define slice region.
307 DataTypes::RegionType region;
308 region.push_back(DataTypes::RegionType::value_type(2,4));
309
310 // Define shapes of views.
311 DataTypes::ShapeType sourceShape;
312 DataTypes::ShapeType targetShape;
313 targetShape.push_back(6);
314
315 // Create source and target views.
316 int len = DataTypes::noValues(sourceShape);
317 DataVector sourceData(len, 2.0, len);
318 // DataArrayView sourceView(sourceData, sourceShape);
319 sourceData[0]=5;
320
321 len = DataTypes::noValues(targetShape);
322 DataVector targetData(len, 2.0, len);
323 // DataArrayView targetView(targetData, targetShape);
324
325 // Copy source view to target view.
326 // targetView.copySliceFrom(sourceView,region);
327 DataTypes::copySliceFrom(targetData,targetShape,0,sourceData, sourceShape,0,region);
328
329 // Check results of copy.
330 for (int i=region[0].first;i<region[0].second;i++) {
331 CPPUNIT_ASSERT(sourceData[0]==
332 targetData[i]);
333 }
334 }
335
336 {
337 cout << endl;
338 cout << "\tSlice a 2 dimensional slice to a 2 dimensional array.";
339
340 // Define slice region.
341 DataTypes::RegionType region;
342 region.push_back(DataTypes::RegionType::value_type(2,4));
343 region.push_back(DataTypes::RegionType::value_type(0,2));
344
345 // Define shapes of views.
346 DataTypes::ShapeType sourceShape;
347 sourceShape.push_back(6);
348 sourceShape.push_back(3);
349 DataTypes::ShapeType targetShape = DataTypes::getResultSliceShape(region);
350
351 // Create source and target views.
352 int len = DataTypes::noValues(sourceShape);
353 DataVector sourceData(len, 2.0, len);
354 // DataArrayView sourceView(sourceData, sourceShape);
355 int val=0;
356 for (int i=0;i<sourceShape[0];i++) {
357 for (int j=0;j<sourceShape[1];j++) {
358 sourceData[getRelIndex(sourceShape,i,j)]=val++;
359 }
360 }
361
362 len = DataTypes::noValues(targetShape);
363 DataVector targetData(len, 2.0, len);
364 // DataArrayView targetView(targetData, targetShape);
365
366 // Copy source view to target view.
367 copySlice(targetData, targetShape,0,sourceData, sourceShape,0,region);
368
369 // Check results of copy.
370 for (int i=region[0].first;i<region[0].second;i++) {
371 for (int j=region[1].first;j<region[1].second;j++) {
372 CPPUNIT_ASSERT(sourceData[getRelIndex(sourceShape,i,j)]==
373 targetData[getRelIndex(targetShape,i-region[0].first,j-region[1].first)]);
374 }
375 }
376 }
377
378 {
379 cout << endl;
380 cout << "\tSlice a 2 dimensional slice to a 1 dimensional array.";
381
382 // Define slice region.
383 DataTypes::RegionType region;
384 region.push_back(DataTypes::RegionType::value_type(0,3));
385 region.push_back(DataTypes::RegionType::value_type(1,2));
386
387 // Define shapes of views.
388 DataTypes::ShapeType sourceShape;
389 sourceShape.push_back(3);
390 sourceShape.push_back(6);
391 DataTypes::ShapeType targetShape;
392 targetShape.push_back(3);
393
394 // Create source and target views.
395 int len = DataTypes::noValues(sourceShape);
396 DataVector sourceData(len, 2.0, len);
397 // DataArrayView sourceView(sourceData, sourceShape);
398 int val=0;
399 for (int i=0;i<sourceShape[0];i++) {
400 for (int j=0;j<sourceShape[1];j++) {
401 sourceData[getRelIndex(sourceShape,i,j)]=val++;
402 }
403 }
404
405 len = DataTypes::noValues(targetShape);
406 DataVector targetData(len, 2.0, len);
407 // DataArrayView targetView(targetData, targetShape);
408
409 // Copy source view to target view.
410 // targetView.copySlice(sourceView,region);
411 copySlice(targetData, targetShape,0,sourceData,sourceShape,0,region);
412
413 // Check results of copy.
414 for (int i=region[0].first;i<region[0].second;i++) {
415 for (int j=region[1].first;j<region[1].second;j++) {
416 CPPUNIT_ASSERT(sourceData[getRelIndex(sourceShape,i,j)]==
417 targetData[getRelIndex(targetShape,i-region[0].first)]);
418 }
419 }
420 }
421
422 {
423 cout << endl;
424 cout << "\tSlice a 2 dimensional slice to a scalar.";
425
426 // Define slice region.
427 DataTypes::RegionType region;
428 region.push_back(DataTypes::RegionType::value_type(2,3));
429 region.push_back(DataTypes::RegionType::value_type(1,2));
430
431 // Define shapes of views.
432 DataTypes::ShapeType sourceShape;
433 sourceShape.push_back(3);
434 sourceShape.push_back(6);
435 DataTypes::ShapeType targetShape;
436
437 // Create source and target views.
438 int len = DataTypes::noValues(sourceShape);
439 DataVector sourceData(len, 2.0, len);
440 // DataArrayView sourceView(sourceData, sourceShape);
441 int val=0;
442 for (int i=0;i<sourceShape[0];i++) {
443 for (int j=0;j<sourceShape[1];j++) {
444 sourceData[getRelIndex(sourceShape,i,j)]=val++;
445 }
446 }
447
448 len = DataTypes::noValues(targetShape);
449 DataVector targetData(len, 2.0, len);
450 // DataArrayView targetView(targetData, targetShape);
451
452 // Copy source view to target view.
453 // targetView.copySlice(sourceView,region);
454 copySlice(targetData, targetShape,0,sourceData, sourceShape,0,region);
455
456
457 // Check results of copy.
458 for (int i=region[0].first;i<region[0].second;i++) {
459 for (int j=region[1].first;j<region[1].second;j++) {
460 /* CPPUNIT_ASSERT(sourceView(i,j)==
461 targetView());*/
462 CPPUNIT_ASSERT(sourceData[getRelIndex(sourceShape,i,j)]==
463 targetData[0]);
464 }
465 }
466 }
467
468 {
469 cout << endl;
470 cout << "\tSlice a 2 dimensional slice from a 2 dimensional array.";
471
472 // Define slice region.
473 DataTypes::RegionType region;
474 region.push_back(DataTypes::RegionType::value_type(2,4));
475 region.push_back(DataTypes::RegionType::value_type(0,2));
476
477 // Define shapes of views.
478 DataTypes::ShapeType sourceShape = DataTypes::getResultSliceShape(region);
479 DataTypes::ShapeType targetShape;
480 targetShape.push_back(6);
481 targetShape.push_back(3);
482
483 // Create source and target views.
484 int len = DataTypes::noValues(sourceShape);
485 DataVector sourceData(len, 2.0, len);
486 // DataArrayView sourceView(sourceData, sourceShape);
487 int val=0;
488 for (int i=0;i<sourceShape[0];i++) {
489 for (int j=0;j<sourceShape[1];j++) {
490 sourceData[getRelIndex(sourceShape,i,j)]=val++;
491 }
492 }
493
494 len = DataTypes::noValues(targetShape);
495 DataVector targetData(len, 2.0, len);
496 // DataArrayView targetView(targetData, targetShape);
497
498 // Copy source view to target view.
499 // targetView.copySliceFrom(sourceView,region);
500 copySliceFrom(targetData,targetShape,0,sourceData, sourceShape,0,region);
501
502 // Check results of copy.
503 for (int i=region[0].first;i<region[0].second;i++) {
504 for (int j=region[1].first;j<region[1].second;j++) {
505 // CPPUNIT_ASSERT(sourceView(i-region[0].first,j-region[1].first)==
506 // targetView(i,j));
507 CPPUNIT_ASSERT(sourceData[getRelIndex(sourceShape,i-region[0].first,j-region[1].first)]==
508 targetData[getRelIndex(targetShape,i,j)]);
509 }
510 }
511 }
512
513 {
514 cout << endl;
515 cout << "\tSlice a 2 dimensional slice from a scalar.";
516
517 // Define slice region.
518 DataTypes::RegionType region;
519 region.push_back(DataTypes::RegionType::value_type(2,4));
520 region.push_back(DataTypes::RegionType::value_type(0,2));
521
522 // Define shapes of views.
523 DataTypes::ShapeType sourceShape;
524 DataTypes::ShapeType targetShape;
525 targetShape.push_back(6);
526 targetShape.push_back(3);
527
528 // Create source and target views.
529 int len = DataTypes::noValues(sourceShape);
530 DataVector sourceData(len, 2.0, len);
531 // DataArrayView sourceView(sourceData, sourceShape);
532 sourceData[0]=5;
533
534 len = DataTypes::noValues(targetShape);
535 DataVector targetData(len, 2.0, len);
536 // DataArrayView targetView(targetData, targetShape);
537
538 // Copy source view to target view.
539 // targetView.copySliceFrom(sourceView,region);
540 copySliceFrom(targetData,targetShape,0,sourceData,sourceShape,0,region);
541
542 // Check results of copy.
543 for (int i=region[0].first;i<region[0].second;i++) {
544 for (int j=region[1].first;j<region[1].second;j++) {
545 CPPUNIT_ASSERT(sourceData[0]==
546 targetData[getRelIndex(targetShape,i,j)]);
547 }
548 }
549 }
550
551 {
552 cout << endl;
553 cout << "\tSlice a 3 dimensional slice to a 3 dimensional array.";
554
555 // Define slice region.
556 DataTypes::RegionType region;
557 region.push_back(DataTypes::RegionType::value_type(2,4));
558 region.push_back(DataTypes::RegionType::value_type(0,2));
559 region.push_back(DataTypes::RegionType::value_type(5,9));
560
561 // Define shapes of views.
562 DataTypes::ShapeType sourceShape;
563 sourceShape.push_back(6);
564 sourceShape.push_back(3);
565 sourceShape.push_back(13);
566 DataTypes::ShapeType targetShape = DataTypes::getResultSliceShape(region);
567
568 // Create source and target views.
569 int len = DataTypes::noValues(sourceShape);
570 DataVector sourceData(len, 2.0, len);
571 // DataArrayView sourceView(sourceData, sourceShape);
572 int val=0;
573 for (int i=0;i<sourceShape[0];i++) {
574 for (int j=0;j<sourceShape[1];j++) {
575 for (int k=0;k<sourceShape[2];k++) {
576 sourceData[getRelIndex(sourceShape,i,j,k)]=val++;
577 }
578 }
579 }
580
581 len = DataTypes::noValues(targetShape);
582 DataVector targetData(len, 2.0, len);
583 // DataArrayView targetView(targetData, targetShape);
584
585 // Copy source view to target view.
586 // targetView.copySlice(sourceView,region);
587 copySlice(targetData,targetShape,0,sourceData,sourceShape,0,region);
588
589 // Check results of copy.
590 for (int i=region[0].first;i<region[0].second;i++) {
591 for (int j=region[1].first;j<region[1].second;j++) {
592 for (int k=region[2].first;k<region[2].second;k++) {
593 // CPPUNIT_ASSERT(sourceView(i,j,k)==
594 // targetView(i-region[0].first,j-region[1].first,k-region[2].first));
595 CPPUNIT_ASSERT(sourceData[getRelIndex(sourceShape,i,j,k)]==
596 targetData[getRelIndex(targetShape,i-region[0].first,j-region[1].first,k-region[2].first)]);
597 }
598 }
599 }
600 }
601
602 {
603 cout << endl;
604 cout << "\tSlice a 3 dimensional slice to a 2 dimensional array.";
605
606 // Define slice region.
607 DataTypes::RegionType region;
608 region.push_back(DataTypes::RegionType::value_type(2,4));
609 region.push_back(DataTypes::RegionType::value_type(0,1));
610 region.push_back(DataTypes::RegionType::value_type(5,9));
611
612 // Define shapes of views.
613 DataTypes::ShapeType sourceShape;
614 sourceShape.push_back(6);
615 sourceShape.push_back(3);
616 sourceShape.push_back(13);
617 DataTypes::ShapeType targetShape;
618 targetShape.push_back(2);
619 targetShape.push_back(4);
620
621 // Create source and target views.
622 int len = DataTypes::noValues(sourceShape);
623 DataVector sourceData(len, 2.0, len);
624 // DataArrayView sourceView(sourceData, sourceShape);
625 int val=0;
626 for (int i=0;i<sourceShape[0];i++) {
627 for (int j=0;j<sourceShape[1];j++) {
628 for (int k=0;k<sourceShape[2];k++) {
629 sourceData[getRelIndex(sourceShape,i,j,k)]=val++;
630 }
631 }
632 }
633
634 len = DataTypes::noValues(targetShape);
635 DataVector targetData(len, 2.0, len);
636 // DataArrayView targetView(targetData, targetShape);
637
638 // Copy source view to target view.
639 // targetView.copySlice(sourceView,region);
640 copySlice(targetData, targetShape,0,sourceData,sourceShape,0,region);
641
642 // Check results of copy.
643 for (int i=region[0].first;i<region[0].second;i++) {
644 for (int j=region[1].first;j<region[1].second;j++) {
645 for (int k=region[2].first;k<region[2].second;k++) {
646 /* CPPUNIT_ASSERT(sourceView(i,j,k)==
647 targetView(i-region[0].first,k-region[2].first));*/
648 CPPUNIT_ASSERT(sourceData[getRelIndex(sourceShape,i,j,k)]==
649 targetData[getRelIndex(targetShape,i-region[0].first,k-region[2].first)]);
650 }
651 }
652 }
653 }
654
655 {
656 cout << endl;
657 cout << "\tSlice a 3 dimensional slice to a 1 dimensional array.";
658
659 // Define slice region.
660 DataTypes::RegionType region;
661 region.push_back(DataTypes::RegionType::value_type(3,4));
662 region.push_back(DataTypes::RegionType::value_type(0,1));
663 region.push_back(DataTypes::RegionType::value_type(5,9));
664
665 // Define shapes of views.
666 DataTypes::ShapeType sourceShape;
667 sourceShape.push_back(6);
668 sourceShape.push_back(3);
669 sourceShape.push_back(13);
670 DataTypes::ShapeType targetShape;
671 targetShape.push_back(4);
672
673 // Create source and target views.
674 int len = DataTypes::noValues(sourceShape);
675 DataVector sourceData(len, 2.0, len);
676 // DataArrayView sourceView(sourceData, sourceShape);
677 int val=0;
678 for (int i=0;i<sourceShape[0];i++) {
679 for (int j=0;j<sourceShape[1];j++) {
680 for (int k=0;k<sourceShape[2];k++) {
681 sourceData[getRelIndex(sourceShape,i,j,k)]=val++;
682 }
683 }
684 }
685
686 len = DataTypes::noValues(targetShape);
687 DataVector targetData(len, 2.0, len);
688 // DataArrayView targetView(targetData, targetShape);
689
690 // Copy source view to target view.
691 // targetView.copySlice(sourceView,region);
692 copySlice(targetData, targetShape,0,sourceData, sourceShape, 0, region);
693
694 // Check results of copy.
695 for (int i=region[0].first;i<region[0].second;i++) {
696 for (int j=region[1].first;j<region[1].second;j++) {
697 for (int k=region[2].first;k<region[2].second;k++) {
698 CPPUNIT_ASSERT(sourceData[getRelIndex(sourceShape,i,j,k)]==
699 targetData[getRelIndex(targetShape,k-region[2].first)]);
700 }
701 }
702 }
703 }
704
705 {
706 cout << endl;
707 cout << "\tSlice a 3 dimensional slice to a scalar.";
708
709 // Define slice region.
710 DataTypes::RegionType region;
711 region.push_back(DataTypes::RegionType::value_type(3,4));
712 region.push_back(DataTypes::RegionType::value_type(0,1));
713 region.push_back(DataTypes::RegionType::value_type(5,6));
714
715 // Define shapes of views.
716 DataTypes::ShapeType sourceShape;
717 sourceShape.push_back(6);
718 sourceShape.push_back(3);
719 sourceShape.push_back(13);
720 DataTypes::ShapeType targetShape;
721
722 // Create source and target views.
723 int len = DataTypes::noValues(sourceShape);
724 DataVector sourceData(len, 2.0, len);
725 // DataArrayView sourceView(sourceData, sourceShape);
726 int val=0;
727 for (int i=0;i<sourceShape[0];i++) {
728 for (int j=0;j<sourceShape[1];j++) {
729 for (int k=0;k<sourceShape[2];k++) {
730 sourceData[getRelIndex(sourceShape,i,j,k)]=val++;
731 }
732 }
733 }
734
735 len = DataTypes::noValues(targetShape);
736 DataVector targetData(len, 2.0, len);
737 // DataArrayView targetView(targetData, targetShape);
738
739 // Copy source view to target view.
740 // targetView.copySlice(sourceView,region);
741 copySlice(targetData, targetShape,0,sourceData, sourceShape, 0, region);
742
743 // Check results of copy.
744 for (int i=region[0].first;i<region[0].second;i++) {
745 for (int j=region[1].first;j<region[1].second;j++) {
746 for (int k=region[2].first;k<region[2].second;k++) {
747 CPPUNIT_ASSERT(sourceData[getRelIndex(sourceShape, i,j,k)]==
748 targetData[0]);
749 }
750 }
751 }
752 }
753
754 {
755 cout << endl;
756 cout << "\tSlice a 3 dimensional slice from a 3 dimensional array.";
757
758 // Define slice region.
759 DataTypes::RegionType region;
760 region.push_back(DataTypes::RegionType::value_type(4,7));
761 region.push_back(DataTypes::RegionType::value_type(2,5));
762 region.push_back(DataTypes::RegionType::value_type(6,7));
763
764 // Define shapes of views.
765 DataTypes::ShapeType sourceShape = DataTypes::getResultSliceShape(region);
766 DataTypes::ShapeType targetShape;
767 targetShape.push_back(11);
768 targetShape.push_back(8);
769 targetShape.push_back(9);
770
771 // Create source and target views.
772 int len = DataTypes::noValues(sourceShape);
773 DataVector sourceData(len, 2.0, len);
774 // DataArrayView sourceView(sourceData, sourceShape);
775 int val=0;
776 for (int i=0;i<sourceShape[0];i++) {
777 for (int j=0;j<sourceShape[1];j++) {
778 for (int k=0;k<sourceShape[2];k++) {
779 sourceData[getRelIndex(sourceShape,i,j,k)]=val++;
780 }
781 }
782 }
783
784 len = DataTypes::noValues(targetShape);
785 DataVector targetData(len, 2.0, len);
786 // DataArrayView targetView(targetData, targetShape);
787
788 // Copy source view to target view.
789 // targetView.copySliceFrom(sourceView,region);
790 copySliceFrom(targetData, targetShape,0,sourceData,sourceShape,0, region);
791
792 // Check results of copy.
793 for (int i=region[0].first;i<region[0].second;i++) {
794 for (int j=region[1].first;j<region[1].second;j++) {
795 for (int k=region[2].first;k<region[2].second;k++) {
796 CPPUNIT_ASSERT(sourceData[getRelIndex(sourceShape,i-region[0].first,j-region[1].first,k-region[2].first)]==
797 targetData[getRelIndex(targetShape,i,j,k)]);
798 }
799 }
800 }
801 }
802
803 {
804 cout << endl;
805 cout << "\tSlice a 3 dimensional slice from a scalar.";
806
807 // Define slice region.
808 DataTypes::RegionType region;
809 region.push_back(DataTypes::RegionType::value_type(4,7));
810 region.push_back(DataTypes::RegionType::value_type(2,5));
811 region.push_back(DataTypes::RegionType::value_type(6,7));
812
813 // Define shapes of views.
814 DataTypes::ShapeType sourceShape;
815 DataTypes::ShapeType targetShape;
816 targetShape.push_back(11);
817 targetShape.push_back(8);
818 targetShape.push_back(9);
819
820 // Create source and target views.
821 int len = DataTypes::noValues(sourceShape);
822 DataVector sourceData(len, 2.0, len);
823 // DataArrayView sourceView(sourceData, sourceShape);
824 sourceData[0]=5;
825
826 len = DataTypes::noValues(targetShape);
827 DataVector targetData(len, 2.0, len);
828
829 // Copy source view to target view.
830 // targetView.copySliceFrom(sourceView,region);
831 copySliceFrom(targetData, targetShape,0,sourceData, sourceShape, 0, region);
832
833 // Check results of copy.
834 for (int i=region[0].first;i<region[0].second;i++) {
835 for (int j=region[1].first;j<region[1].second;j++) {
836 for (int k=region[2].first;k<region[2].second;k++) {
837 CPPUNIT_ASSERT(sourceData[0]==
838 targetData[getRelIndex(targetShape,i,j,k)]);
839 }
840 }
841 }
842 }
843
844 {
845 cout << endl;
846 cout << "\tSlice a 4 dimensional slice to a 4 dimensional array.";
847
848 // Define slice region.
849 DataTypes::RegionType region;
850 region.push_back(DataTypes::RegionType::value_type(2,4));
851 region.push_back(DataTypes::RegionType::value_type(0,2));
852 region.push_back(DataTypes::RegionType::value_type(5,9));
853 region.push_back(DataTypes::RegionType::value_type(3,5));
854
855 // Define shapes of views.
856 DataTypes::ShapeType sourceShape;
857 sourceShape.push_back(6);
858 sourceShape.push_back(3);
859 sourceShape.push_back(13);
860 sourceShape.push_back(9);
861 DataTypes::ShapeType targetShape = DataTypes::getResultSliceShape(region);
862
863 // Create source and target views.
864 int len = DataTypes::noValues(sourceShape);
865 DataVector sourceData(len, 2.0, len);
866 // DataArrayView sourceView(sourceData, sourceShape);
867 int val=0;
868 for (int i=0;i<sourceShape[0];i++) {
869 for (int j=0;j<sourceShape[1];j++) {
870 for (int k=0;k<sourceShape[2];k++) {
871 for (int l=0;l<sourceShape[3];l++) {
872 sourceData[getRelIndex(sourceShape,i,j,k,l)]=val++;
873 }
874 }
875 }
876 }
877
878 len = DataTypes::noValues(targetShape);
879 DataVector targetData(len, 2.0, len);
880 // DataArrayView targetView(targetData, targetShape);
881
882 // Copy source view to target view.
883 // targetView.copySlice(sourceView,region);
884 copySlice(targetData, targetShape, 0, sourceData, sourceShape,0, region);
885
886 // Check results of copy.
887 for (int i=region[0].first;i<region[0].second;i++) {
888 for (int j=region[1].first;j<region[1].second;j++) {
889 for (int k=region[2].first;k<region[2].second;k++) {
890 for (int l=region[3].first;l<region[3].second;l++) {
891 // CPPUNIT_ASSERT(sourceView(i,j,k,l)==
892 // targetView(i-region[0].first,j-region[1].first,k-region[2].first,l-region[3].first));
893 CPPUNIT_ASSERT(sourceData[getRelIndex(sourceShape,i,j,k,l)]==
894 targetData[getRelIndex(targetShape,i-region[0].first,j-region[1].first,k-region[2].first,l-region[3].first)]);
895 }
896 }
897 }
898 }
899 }
900
901 {
902 cout << endl;
903 cout << "\tSlice a 4 dimensional slice to a 3 dimensional array.";
904
905 // Define slice region.
906 DataTypes::RegionType region;
907 region.push_back(DataTypes::RegionType::value_type(2,4));
908 region.push_back(DataTypes::RegionType::value_type(0,2));
909 region.push_back(DataTypes::RegionType::value_type(5,6));
910 region.push_back(DataTypes::RegionType::value_type(3,5));
911
912 // Define shapes of views.
913 DataTypes::ShapeType sourceShape;
914 sourceShape.push_back(6);
915 sourceShape.push_back(3);
916 sourceShape.push_back(13);
917 sourceShape.push_back(9);
918 DataTypes::ShapeType targetShape;
919 targetShape.push_back(2);
920 targetShape.push_back(2);
921 targetShape.push_back(2);
922
923 // Create source and target views.
924 int len = DataTypes::noValues(sourceShape);
925 DataVector sourceData(len, 2.0, len);
926 // DataArrayView sourceView(sourceData, sourceShape);
927 int val=0;
928 for (int i=0;i<sourceShape[0];i++) {
929 for (int j=0;j<sourceShape[1];j++) {
930 for (int k=0;k<sourceShape[2];k++) {
931 for (int l=0;l<sourceShape[3];l++) {
932 sourceData[getRelIndex(sourceShape,i,j,k,l)]=val++;
933 }
934 }
935 }
936 }
937
938 len = DataTypes::noValues(targetShape);
939 DataVector targetData(len, 2.0, len);
940 // DataArrayView targetView(targetData, targetShape);
941
942 // Copy source view to target view.
943 // targetView.copySlice(sourceView,region);
944 copySlice(targetData, targetShape, 0, sourceData, sourceShape, 0, region);
945
946 // Check results of copy.
947 for (int i=region[0].first;i<region[0].second;i++) {
948 for (int j=region[1].first;j<region[1].second;j++) {
949 for (int k=region[2].first;k<region[2].second;k++) {
950 for (int l=region[3].first;l<region[3].second;l++) {
951 CPPUNIT_ASSERT(sourceData[getRelIndex(sourceShape,i,j,k,l)]==
952 targetData[getRelIndex(targetShape,i-region[0].first,j-region[1].first,l-region[3].first)]);
953 }
954 }
955 }
956 }
957 }
958
959 {
960 cout << endl;
961 cout << "\tSlice a 4 dimensional slice to a 2 dimensional array.";
962
963 // Define slice region.
964 DataTypes::RegionType region;
965 region.push_back(DataTypes::RegionType::value_type(2,4));
966 region.push_back(DataTypes::RegionType::value_type(0,2));
967 region.push_back(DataTypes::RegionType::value_type(5,6));
968 region.push_back(DataTypes::RegionType::value_type(4,5));
969
970 // Define shapes of views.
971 DataTypes::ShapeType sourceShape;
972 sourceShape.push_back(6);
973 sourceShape.push_back(3);
974 sourceShape.push_back(13);
975 sourceShape.push_back(9);
976 DataTypes::ShapeType targetShape;
977 targetShape.push_back(2);
978 targetShape.push_back(2);
979
980 // Create source and target views.
981 int len = DataTypes::noValues(sourceShape);
982 DataVector sourceData(len, 2.0, len);
983 // DataArrayView sourceView(sourceData, sourceShape);
984 int val=0;
985 for (int i=0;i<sourceShape[0];i++) {
986 for (int j=0;j<sourceShape[1];j++) {
987 for (int k=0;k<sourceShape[2];k++) {
988 for (int l=0;l<sourceShape[3];l++) {
989 sourceData[getRelIndex(sourceShape,i,j,k,l)]=val++;
990 }
991 }
992 }
993 }
994
995 len = DataTypes::noValues(targetShape);
996 DataVector targetData(len, 2.0, len);
997 // DataArrayView targetView(targetData, targetShape);
998
999 // Copy source view to target view.
1000 // targetView.copySlice(sourceView,region);
1001 copySlice(targetData, targetShape, 0, sourceData, sourceShape, 0, region);
1002
1003 // Check results of copy.
1004 for (int i=region[0].first;i<region[0].second;i++) {
1005 for (int j=region[1].first;j<region[1].second;j++) {
1006 for (int k=region[2].first;k<region[2].second;k++) {
1007 for (int l=region[3].first;l<region[3].second;l++) {
1008 CPPUNIT_ASSERT(sourceData[getRelIndex(sourceShape,i,j,k,l)]==
1009 targetData[getRelIndex(targetShape,i-region[0].first,j-region[1].first)]);
1010 }
1011 }
1012 }
1013 }
1014 }
1015
1016 {
1017 cout << endl;
1018 cout << "\tSlice a 4 dimensional slice to a 1 dimensional array.";
1019
1020 // Define slice region.
1021 DataTypes::RegionType region;
1022 region.push_back(DataTypes::RegionType::value_type(3,4));
1023 region.push_back(DataTypes::RegionType::value_type(0,2));
1024 region.push_back(DataTypes::RegionType::value_type(5,6));
1025 region.push_back(DataTypes::RegionType::value_type(4,5));
1026
1027 // Define shapes of views.
1028 DataTypes::ShapeType sourceShape;
1029 sourceShape.push_back(6);
1030 sourceShape.push_back(3);
1031 sourceShape.push_back(13);
1032 sourceShape.push_back(9);
1033 DataTypes::ShapeType targetShape;
1034 targetShape.push_back(2);
1035
1036 // Create source and target views.
1037 int len = DataTypes::noValues(sourceShape);
1038 DataVector sourceData(len, 2.0, len);
1039 // DataArrayView sourceView(sourceData, sourceShape);
1040 int val=0;
1041 for (int i=0;i<sourceShape[0];i++) {
1042 for (int j=0;j<sourceShape[1];j++) {
1043 for (int k=0;k<sourceShape[2];k++) {
1044 for (int l=0;l<sourceShape[3];l++) {
1045 sourceData[getRelIndex(sourceShape,i,j,k,l)]=val++;
1046 }
1047 }
1048 }
1049 }
1050
1051 len = DataTypes::noValues(targetShape);
1052 DataVector targetData(len, 2.0, len);
1053 // DataArrayView targetView(targetData, targetShape);
1054
1055 // Copy source view to target view.
1056 // targetView.copySlice(sourceView,region);
1057 copySlice(targetData,targetShape,0, sourceData, sourceShape,0,region);
1058
1059 // Check results of copy.
1060 for (int i=region[0].first;i<region[0].second;i++) {
1061 for (int j=region[1].first;j<region[1].second;j++) {
1062 for (int k=region[2].first;k<region[2].second;k++) {
1063 for (int l=region[3].first;l<region[3].second;l++) {
1064 CPPUNIT_ASSERT(sourceData[getRelIndex(sourceShape,i,j,k,l)]==
1065 targetData[getRelIndex(targetShape,j-region[1].first)]);
1066 }
1067 }
1068 }
1069 }
1070 }
1071
1072 {
1073 cout << endl;
1074 cout << "\tSlice a 4 dimensional slice to a scalar.";
1075
1076 // Define slice region.
1077 DataTypes::RegionType region;
1078 region.push_back(DataTypes::RegionType::value_type(3,4));
1079 region.push_back(DataTypes::RegionType::value_type(1,2));
1080 region.push_back(DataTypes::RegionType::value_type(5,6));
1081 region.push_back(DataTypes::RegionType::value_type(4,5));
1082
1083 // Define shapes of views.
1084 DataTypes::ShapeType sourceShape;
1085 sourceShape.push_back(6);
1086 sourceShape.push_back(3);
1087 sourceShape.push_back(13);
1088 sourceShape.push_back(9);
1089 DataTypes::ShapeType targetShape;
1090
1091 // Create source and target views.
1092 int len = DataTypes::noValues(sourceShape);
1093 DataVector sourceData(len, 2.0, len);
1094 //DataArrayView sourceView(sourceData, sourceShape);
1095 int val=0;
1096 for (int i=0;i<sourceShape[0];i++) {
1097 for (int j=0;j<sourceShape[1];j++) {
1098 for (int k=0;k<sourceShape[2];k++) {
1099 for (int l=0;l<sourceShape[3];l++) {
1100 sourceData[getRelIndex(sourceShape,i,j,k,l)]=val++;
1101 }
1102 }
1103 }
1104 }
1105
1106 len = DataTypes::noValues(targetShape);
1107 DataVector targetData(len, 2.0, len);
1108 // DataArrayView targetView(targetData, targetShape);
1109
1110 // Copy source view to target view.
1111 // targetView.copySlice(sourceView,region);
1112 copySlice(targetData, targetShape, 0, sourceData, sourceShape,0,region);
1113
1114 // Check results of copy.
1115 for (int i=region[0].first;i<region[0].second;i++) {
1116 for (int j=region[1].first;j<region[1].second;j++) {
1117 for (int k=region[2].first;k<region[2].second;k++) {
1118 for (int l=region[3].first;l<region[3].second;l++) {
1119 CPPUNIT_ASSERT(sourceData[getRelIndex(sourceShape,i,j,k,l)]==
1120 targetData[0]);
1121 }
1122 }
1123 }
1124 }
1125 }
1126
1127 {
1128 cout << endl;
1129 cout << "\tSlice a 4 dimensional slice from a 4 dimensional array.";
1130
1131 // Define slice region.
1132 DataTypes::RegionType region;
1133 region.push_back(DataTypes::RegionType::value_type(14,37));
1134 region.push_back(DataTypes::RegionType::value_type(22,57));
1135 region.push_back(DataTypes::RegionType::value_type(63,71));
1136 region.push_back(DataTypes::RegionType::value_type(23,51));
1137
1138 // Define shapes of views.
1139 DataTypes::ShapeType sourceShape = DataTypes::getResultSliceShape(region);
1140 DataTypes::ShapeType targetShape;
1141 targetShape.push_back(50);
1142 targetShape.push_back(65);
1143 targetShape.push_back(80);
1144 targetShape.push_back(90);
1145
1146 // Create source and target views.
1147 int len = DataTypes::noValues(sourceShape);
1148 DataVector sourceData(len, 2.0, len);
1149 // DataArrayView sourceView(sourceData, sourceShape);
1150 int val=0;
1151 for (int i=0;i<sourceShape[0];i++) {
1152 for (int j=0;j<sourceShape[1];j++) {
1153 for (int k=0;k<sourceShape[2];k++) {
1154 for (int l=0;l<sourceShape[3];l++) {
1155 sourceData[getRelIndex(sourceShape,i,j,k,l)]=val++;
1156 }
1157 }
1158 }
1159 }
1160
1161 len = DataTypes::noValues(targetShape);
1162 DataVector targetData(len, 2.0, len);
1163 // DataArrayView targetView(targetData, targetShape);
1164
1165 // Copy source view to target view.
1166 // targetView.copySliceFrom(sourceView,region);
1167 copySliceFrom(targetData, targetShape, 0, sourceData, sourceShape,0,region);
1168
1169 // Check results of copy.
1170 for (int i=region[0].first;i<region[0].second;i++) {
1171 for (int j=region[1].first;j<region[1].second;j++) {
1172 for (int k=region[2].first;k<region[2].second;k++) {
1173 for (int l=region[3].first;l<region[3].second;l++) {
1174 CPPUNIT_ASSERT(sourceData[getRelIndex(sourceShape,i-region[0].first,j-region[1].first,k-region[2].first,l-region[3].first)]==
1175 targetData[getRelIndex(targetShape,i,j,k,l)]);
1176 }
1177 }
1178 }
1179 }
1180 }
1181
1182 {
1183 cout << endl;
1184 cout << "\tSlice a 4 dimensional slice from a scalar.";
1185
1186 // Define slice region.
1187 DataTypes::RegionType region;
1188 region.push_back(DataTypes::RegionType::value_type(14,37));
1189 region.push_back(DataTypes::RegionType::value_type(22,57));
1190 region.push_back(DataTypes::RegionType::value_type(63,71));
1191 region.push_back(DataTypes::RegionType::value_type(23,51));
1192
1193 // Define shapes of views.
1194 DataTypes::ShapeType sourceShape;
1195 DataTypes::ShapeType targetShape;
1196 targetShape.push_back(50);
1197 targetShape.push_back(65);
1198 targetShape.push_back(80);
1199 targetShape.push_back(90);
1200
1201 // Create source and target views.
1202 int len = DataTypes::noValues(sourceShape);
1203 DataVector sourceData(len, 2.0, len);
1204 // DataArrayView sourceView(sourceData, sourceShape);
1205 sourceData[0]=5;
1206
1207 len = DataTypes::noValues(targetShape);
1208 DataVector targetData(len, 2.0, len);
1209 // DataArrayView targetView(targetData, targetShape);
1210
1211 // Copy source view to target view.
1212 // targetView.copySliceFrom(sourceView,region);
1213 copySliceFrom(targetData, targetShape, 0, sourceData, sourceShape, 0, region);
1214
1215 // Check results of copy.
1216 for (int i=region[0].first;i<region[0].second;i++) {
1217 for (int j=region[1].first;j<region[1].second;j++) {
1218 for (int k=region[2].first;k<region[2].second;k++) {
1219 for (int l=region[3].first;l<region[3].second;l++) {
1220 CPPUNIT_ASSERT(sourceData[0]==
1221 targetData[getRelIndex(targetShape,i,j,k,l)]);
1222 }
1223 }
1224 }
1225 }
1226 }
1227
1228 cout << endl;
1229
1230 }
1231
1232 void DataTypesTestCase::testShapeToString() {
1233
1234 cout << endl;
1235 cout << "\tTest shapeToString for a variety of shapes." << endl;
1236
1237 DataTypes::ShapeType shape;
1238 CPPUNIT_ASSERT(DataTypes::shapeToString(shape)=="()");
1239 shape.push_back(5);
1240 CPPUNIT_ASSERT(DataTypes::shapeToString(shape)=="(5)");
1241 shape.push_back(2);
1242 CPPUNIT_ASSERT(DataTypes::shapeToString(shape)=="(5,2)");
1243 shape.push_back(9);
1244 CPPUNIT_ASSERT(DataTypes::shapeToString(shape)=="(5,2,9)");
1245 shape.push_back(4);
1246 CPPUNIT_ASSERT(DataTypes::shapeToString(shape)=="(5,2,9,4)");
1247
1248 }
1249
1250
1251 TestSuite* DataTypesTestCase::suite()
1252 {
1253 //
1254 // create the suite of tests to perform.
1255 TestSuite *testSuite = new TestSuite("DataTypesTestCase");
1256 testSuite->addTest(new TestCaller<DataTypesTestCase>(
1257 "testShapeToString",&DataTypesTestCase::testShapeToString));
1258 testSuite->addTest(new TestCaller<DataTypesTestCase>(
1259 "testResultSliceShape",&DataTypesTestCase::testResultSliceShape));
1260 testSuite->addTest(new TestCaller<DataTypesTestCase>(
1261 "testSlicing",&DataTypesTestCase::testSlicing));
1262 testSuite->addTest(new TestCaller<DataTypesTestCase>(
1263 "testShapeFunctions",&DataTypesTestCase::testShapeFns));
1264 return testSuite;
1265 }
1266

  ViewVC Help
Powered by ViewVC 1.1.26