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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1811 - (show annotations)
Thu Sep 25 23:11:13 2008 UTC (10 years, 11 months ago) by ksteube
File size: 4731 byte(s)
Copyright updated in all files

1
2 /*******************************************************
3 *
4 * Copyright (c) 2003-2008 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 "escript/DataFactory.h"
16 #include "escript/Data.h"
17
18 #include "DataFactoryTestCase.h"
19
20 #include <iostream>
21
22 using namespace CppUnitTest;
23 using namespace escript;
24 using namespace std;
25
26 void DataFactoryTestCase::setUp() {
27 //
28 // This is called before each test is run
29
30 }
31
32 void DataFactoryTestCase::tearDown() {
33 //
34 // This is called after each test has been run
35
36 }
37
38 void DataFactoryTestCase::testAll() {
39
40 cout << endl;
41
42 cout << "\tUse DataFactory functions to create some Data objects:" << endl;
43
44 {
45 cout << "\tCreate Data (DataConstant) object with Scalar data points." << endl;
46 Data scalar=Scalar(1.3);
47 //cout << scalar.toString() << endl;
48 assert(scalar.isConstant());
49 assert(scalar.getDataPointRank()==0);
50 assert(scalar.getDataPointShape().empty());
51 }
52
53 {
54 cout << "\tCreate DataExpanded object with Scalar data points." << endl;
55 Data scalar=Scalar(1.5,FunctionSpace(),true);
56 //cout << scalar.toString() << endl;
57 assert(scalar.isExpanded());
58 assert(scalar.getDataPointRank()==0);
59 assert(scalar.getDataPointShape().empty());
60 }
61
62 {
63 cout << "\tCreate Data (DataConstant) object with Vector data points." << endl;
64 Data vector=Vector(1.3);
65 //cout << vector.toString() << endl;
66 assert(vector.isConstant());
67 assert(vector.getDataPointRank()==1);
68 assert(vector.getDataPointShape()[0]==1);;
69 }
70
71 {
72 cout << "\tCreate Data Expanded object with Vector data points." << endl;
73 Data vector=Vector(1.5,FunctionSpace(),true);
74 //cout << vector.toString() << endl;
75 assert(vector.isExpanded());
76 assert(vector.getDataPointRank()==1);
77 assert(vector.getDataPointShape()[0]==1);;
78 }
79
80 {
81 cout << "\tCreate Data (DataConstant) object with Tensor data points." << endl;
82 Data tensor=Tensor(1.3);
83 //cout << tensor.toString() << endl;
84 assert(tensor.isConstant());
85 assert(tensor.getDataPointRank()==2);
86 assert(tensor.getDataPointShape()[0]==1);;
87 assert(tensor.getDataPointShape()[1]==1);;
88 }
89
90 {
91 cout << "\tCreate Data Expanded object with Tensor data points." << endl;
92 Data tensor=Tensor(1.5,FunctionSpace(),true);
93 //cout << tensor.toString() << endl;
94 assert(tensor.isExpanded());
95 assert(tensor.getDataPointRank()==2);
96 assert(tensor.getDataPointShape()[0]==1);;
97 assert(tensor.getDataPointShape()[1]==1);;
98 }
99
100 {
101 cout << "\tCreate Data (DataConstant) object with Tensor3 data points." << endl;
102 Data tensor3=Tensor3(1.3);
103 //cout << tensor3.toString() << endl;
104 assert(tensor3.isConstant());
105 assert(tensor3.getDataPointRank()==3);
106 assert(tensor3.getDataPointShape()[0]==1);;
107 assert(tensor3.getDataPointShape()[1]==1);;
108 assert(tensor3.getDataPointShape()[2]==1);;
109 }
110
111 {
112 cout << "\tCreate Data Expanded object with Tensor3 data points." << endl;
113 Data tensor3=Tensor3(1.5,FunctionSpace(),true);
114 //cout << tensor3.toString() << endl;
115 assert(tensor3.isExpanded());
116 assert(tensor3.getDataPointRank()==3);
117 assert(tensor3.getDataPointShape()[0]==1);;
118 assert(tensor3.getDataPointShape()[1]==1);;
119 assert(tensor3.getDataPointShape()[2]==1);;
120 }
121
122 {
123 cout << "\tCreate Data (DataConstant) object with Tensor4 data points." << endl;
124 Data tensor4=Tensor4(1.3);
125 //cout << tensor4.toString() << endl;
126 assert(tensor4.isConstant());
127 assert(tensor4.getDataPointRank()==4);
128 assert(tensor4.getDataPointShape()[0]==1);;
129 assert(tensor4.getDataPointShape()[1]==1);;
130 assert(tensor4.getDataPointShape()[2]==1);;
131 assert(tensor4.getDataPointShape()[3]==1);;
132 }
133
134 {
135 cout << "\tCreate Data Expanded object with Tensor4 data points." << endl;
136 Data tensor4=Tensor4(1.5,FunctionSpace(),true);
137 //cout << tensor4.toString() << endl;
138 assert(tensor4.isExpanded());
139 assert(tensor4.getDataPointRank()==4);
140 assert(tensor4.getDataPointShape()[0]==1);;
141 assert(tensor4.getDataPointShape()[1]==1);;
142 assert(tensor4.getDataPointShape()[2]==1);;
143 assert(tensor4.getDataPointShape()[3]==1);;
144 }
145
146 }
147
148 TestSuite* DataFactoryTestCase::suite ()
149 {
150 //
151 // create the suite of tests to perform.
152 TestSuite *testSuite = new TestSuite ("DataFactoryTestCase");
153
154 testSuite->addTest (new TestCaller< DataFactoryTestCase>("testAll",&DataFactoryTestCase::testAll));
155 return testSuite;
156 }
157

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26