/[escript]/trunk/esys2/escript/test/DataConstant/DataConstantTestCase.cpp
ViewVC logotype

Contents of /trunk/esys2/escript/test/DataConstant/DataConstantTestCase.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 100 - (show annotations)
Wed Dec 15 03:48:48 2004 UTC (18 years, 3 months ago) by jgs
File size: 2899 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/DataConstant.h"
16 #include "escript/Data/FunctionSpace.h"
17 #include "esysUtils/EsysException.h"
18
19 #include "DataConstantTestCase.h"
20
21 #include <iostream>
22
23 using namespace CppUnitTest;
24 using namespace escript;
25 using namespace std;
26 using namespace esysUtils;
27
28 void DataConstantTestCase::setUp() {
29 //
30 // This is called before each test is run
31
32 }
33
34 void DataConstantTestCase::tearDown() {
35 //
36 // This is called after each test has been run
37
38 }
39
40 void DataConstantTestCase::testAll() {
41
42 cout << endl;
43
44 //
45 // Create a scalar pointData
46 DataArrayView::ShapeType shape;
47 DataArrayView::ValueType data(DataArrayView::noValues(shape),0);
48 DataArrayView pointData(data,shape);
49 DataArrayView::RegionType region;
50
51 //
52 // assign an arbitrary value
53 pointData()=1.0;
54
55 //
56 // Test construction
57 cout << "\tTesting default constructor." << endl;
58 DataConstant testData(pointData, FunctionSpace());
59
60 cout << "\tTest reshape." << endl;
61 shape.push_back(2);
62 shape.push_back(3);
63 shape.push_back(21);
64 testData.reshapeDataPoint(shape);
65 assert(testData.getPointDataView().getRank()==shape.size());
66
67 cout << "\tTest getPointDataView." << endl;
68 for (int k=0;k<shape[1];++k) {
69 for (int j=0;j<shape[1];++j) {
70 for (int i=0;i<shape[0];++i) {
71 assert(testData.getPointDataView()(i,j,k)==pointData());
72 }
73 }
74 }
75
76 try {
77 cout << "\tTest illegal reshape." << endl;
78 testData.reshapeDataPoint(shape);
79 assert(false);
80 }
81 catch (EsysException& e) {
82 //cout << e.toString() << endl;
83 assert(true);
84 }
85
86 cout << "\tTesting copy constructor." << endl;
87 DataConstant testData2(testData);
88
89 cout << "\tTest getLength." << endl;
90 assert(testData2.getLength() == 126);
91
92 }
93
94 TestSuite* DataConstantTestCase::suite ()
95 {
96 //
97 // create the suite of tests to perform.
98 TestSuite *testSuite = new TestSuite ("DataConstantTestCase");
99
100 testSuite->addTest (new TestCaller< DataConstantTestCase>("testAll",&DataConstantTestCase::testAll));
101 return testSuite;
102 }

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26