/[escript]/trunk/esys2/escript/test/DataExpanded/DataExpandedTestCase.cpp
ViewVC logotype

Annotation of /trunk/esys2/escript/test/DataExpanded/DataExpandedTestCase.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 82 - (hide annotations)
Tue Oct 26 06:53:54 2004 UTC (15 years, 1 month ago) by jgs
File size: 3840 byte(s)
Initial revision

1 jgs 82 /*
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/Data/FunctionSpace.h"
15     #include "escript/Data/DataExpanded.h"
16     #include "esysUtils/EsysException.h"
17     #include "DataExpandedTestCase.h"
18    
19     #include <iostream>
20    
21     using namespace CppUnitTest;
22     using namespace escript;
23     using namespace std;
24     using namespace esysUtils;
25    
26     void DataExpandedTestCase::setUp() {
27     //
28     // This is called before each test is run
29    
30     }
31    
32     void DataExpandedTestCase::tearDown() {
33     //
34     // This is called after each test has been run
35    
36     }
37    
38     void DataExpandedTestCase::testReshape() {
39    
40     cout << endl;
41    
42     //
43     // Create a scalar pointData
44     DataArrayView::ShapeType shape;
45     DataArrayView::ValueType data(DataArrayView::noValues(shape),0);
46     DataArrayView pointData(data,shape);
47    
48     //
49     // assign an arbitrary value
50     pointData()=1.0;
51    
52     int noDataPointsPerSample=10;
53     int noSamples=1000;
54    
55     //
56     // Test construction
57     cout << "Test DataExpanded constructor." << endl;
58     DataExpanded testData(pointData,FunctionSpace());
59    
60     cout << "Test reshapeDataPoint." << endl;
61     shape.push_back(2);
62     testData.reshapeDataPoint(shape);
63     assert(testData.getPointDataView().getRank() == 1);
64    
65     //for (int i=0;i<noSamples;++i) {
66     // for (int j=0;j<noDataPointsPerSample;++j) {
67     // assert(testData.getDataPoint(i,j)(0) == pointData());
68     // assert(testData.getDataPoint(i,j)(1) == pointData());
69     //}
70     //}
71    
72     try {
73     cout << "Test illegal reshape." << endl;
74     testData.reshapeDataPoint(shape);
75     assert(false);
76     }
77     catch (EsysException& e) {
78     cout << e.toString() << endl;
79     assert(true);
80     }
81    
82     cout << "Test toString." << endl;
83     cout << testData.toString() << endl;
84    
85     cout << "Test DataExpanded destructor." << endl;
86    
87     }
88    
89     void DataExpandedTestCase::testAll() {
90    
91     cout << endl;
92    
93     //
94     // Create a scalar pointData
95     DataArrayView::ShapeType shape;
96     shape.push_back(3);
97     DataArrayView::ValueType data(DataArrayView::noValues(shape),0);
98     DataArrayView pointData(data,shape);
99    
100     //
101     // assign an arbitrary value
102     pointData(0)=0.0;
103     pointData(1)=1.0;
104     pointData(2)=2.0;
105    
106     int noDataPointsPerSample=10;
107     int noSamples=1000;
108    
109     //
110     // Test construction
111     cout << "Test DataExpanded constructor." << endl;
112     DataExpanded testData(pointData,FunctionSpace());
113    
114     cout << "Test toString." << endl;
115     cout << testData.toString() << endl;
116    
117     //for (int i=0;i<noSamples;++i) {
118     //for (int j=0;j<noDataPointsPerSample;++j) {
119     //assert(testData.getDataPoint(i,j) == pointData);
120     //}
121     //}
122    
123     cout << "Test toString." << endl;
124     cout << testData.toString() << endl;
125    
126     cout << "Test DataExpanded destructor." << endl;
127    
128     }
129    
130     TestSuite* DataExpandedTestCase::suite ()
131     {
132     //
133     // create the suite of tests to perform.
134     TestSuite *testSuite = new TestSuite ("DataExpandedTestCase");
135    
136     testSuite->addTest (new TestCaller< DataExpandedTestCase>("testAll",&DataExpandedTestCase::testAll));
137     testSuite->addTest (new TestCaller< DataExpandedTestCase>("testReshape",&DataExpandedTestCase::testReshape));
138     return testSuite;
139     }
140    
141    

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26