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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3597 - (show annotations)
Thu Sep 15 06:03:17 2011 UTC (7 years, 7 months ago) by caltinay
File size: 4868 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 "DataFactoryTestCase.h"
16
17 #include "escript/DataFactory.h"
18 #include "escript/Data.h"
19
20 #include <cppunit/TestCaller.h>
21 #include <iostream>
22
23 using namespace CppUnit;
24 using namespace escript;
25 using namespace std;
26
27 void DataFactoryTestCase::testAll()
28 {
29 cout << endl;
30 cout << "\tUse DataFactory functions to create some Data objects:" << endl;
31
32 {
33 cout << "\tCreate Data (DataConstant) object with Scalar data points." << endl;
34 Data scalar=Scalar(1.3);
35 //cout << scalar.toString() << endl;
36 CPPUNIT_ASSERT(scalar.isConstant());
37 CPPUNIT_ASSERT(scalar.getDataPointRank()==0);
38 CPPUNIT_ASSERT(scalar.getDataPointShape().empty());
39 }
40
41 {
42 cout << "\tCreate DataExpanded object with Scalar data points." << endl;
43 Data scalar=Scalar(1.5,FunctionSpace(),true);
44 //cout << scalar.toString() << endl;
45 CPPUNIT_ASSERT(scalar.isExpanded());
46 CPPUNIT_ASSERT(scalar.getDataPointRank()==0);
47 CPPUNIT_ASSERT(scalar.getDataPointShape().empty());
48 }
49
50 {
51 cout << "\tCreate Data (DataConstant) object with Vector data points." << endl;
52 Data vector=Vector(1.3);
53 //cout << vector.toString() << endl;
54 CPPUNIT_ASSERT(vector.isConstant());
55 CPPUNIT_ASSERT(vector.getDataPointRank()==1);
56 CPPUNIT_ASSERT(vector.getDataPointShape()[0]==1);;
57 }
58
59 {
60 cout << "\tCreate Data Expanded object with Vector data points." << endl;
61 Data vector=Vector(1.5,FunctionSpace(),true);
62 //cout << vector.toString() << endl;
63 CPPUNIT_ASSERT(vector.isExpanded());
64 CPPUNIT_ASSERT(vector.getDataPointRank()==1);
65 CPPUNIT_ASSERT(vector.getDataPointShape()[0]==1);;
66 }
67
68 {
69 cout << "\tCreate Data (DataConstant) object with Tensor data points." << endl;
70 Data tensor=Tensor(1.3);
71 //cout << tensor.toString() << endl;
72 CPPUNIT_ASSERT(tensor.isConstant());
73 CPPUNIT_ASSERT(tensor.getDataPointRank()==2);
74 CPPUNIT_ASSERT(tensor.getDataPointShape()[0]==1);;
75 CPPUNIT_ASSERT(tensor.getDataPointShape()[1]==1);;
76 }
77
78 {
79 cout << "\tCreate Data Expanded object with Tensor data points." << endl;
80 Data tensor=Tensor(1.5,FunctionSpace(),true);
81 //cout << tensor.toString() << endl;
82 CPPUNIT_ASSERT(tensor.isExpanded());
83 CPPUNIT_ASSERT(tensor.getDataPointRank()==2);
84 CPPUNIT_ASSERT(tensor.getDataPointShape()[0]==1);;
85 CPPUNIT_ASSERT(tensor.getDataPointShape()[1]==1);;
86 }
87
88 {
89 cout << "\tCreate Data (DataConstant) object with Tensor3 data points." << endl;
90 Data tensor3=Tensor3(1.3);
91 //cout << tensor3.toString() << endl;
92 CPPUNIT_ASSERT(tensor3.isConstant());
93 CPPUNIT_ASSERT(tensor3.getDataPointRank()==3);
94 CPPUNIT_ASSERT(tensor3.getDataPointShape()[0]==1);;
95 CPPUNIT_ASSERT(tensor3.getDataPointShape()[1]==1);;
96 CPPUNIT_ASSERT(tensor3.getDataPointShape()[2]==1);;
97 }
98
99 {
100 cout << "\tCreate Data Expanded object with Tensor3 data points." << endl;
101 Data tensor3=Tensor3(1.5,FunctionSpace(),true);
102 //cout << tensor3.toString() << endl;
103 CPPUNIT_ASSERT(tensor3.isExpanded());
104 CPPUNIT_ASSERT(tensor3.getDataPointRank()==3);
105 CPPUNIT_ASSERT(tensor3.getDataPointShape()[0]==1);;
106 CPPUNIT_ASSERT(tensor3.getDataPointShape()[1]==1);;
107 CPPUNIT_ASSERT(tensor3.getDataPointShape()[2]==1);;
108 }
109
110 {
111 cout << "\tCreate Data (DataConstant) object with Tensor4 data points." << endl;
112 Data tensor4=Tensor4(1.3);
113 //cout << tensor4.toString() << endl;
114 CPPUNIT_ASSERT(tensor4.isConstant());
115 CPPUNIT_ASSERT(tensor4.getDataPointRank()==4);
116 CPPUNIT_ASSERT(tensor4.getDataPointShape()[0]==1);;
117 CPPUNIT_ASSERT(tensor4.getDataPointShape()[1]==1);;
118 CPPUNIT_ASSERT(tensor4.getDataPointShape()[2]==1);;
119 CPPUNIT_ASSERT(tensor4.getDataPointShape()[3]==1);;
120 }
121
122 {
123 cout << "\tCreate Data Expanded object with Tensor4 data points." << endl;
124 Data tensor4=Tensor4(1.5,FunctionSpace(),true);
125 //cout << tensor4.toString() << endl;
126 CPPUNIT_ASSERT(tensor4.isExpanded());
127 CPPUNIT_ASSERT(tensor4.getDataPointRank()==4);
128 CPPUNIT_ASSERT(tensor4.getDataPointShape()[0]==1);;
129 CPPUNIT_ASSERT(tensor4.getDataPointShape()[1]==1);;
130 CPPUNIT_ASSERT(tensor4.getDataPointShape()[2]==1);;
131 CPPUNIT_ASSERT(tensor4.getDataPointShape()[3]==1);;
132 }
133
134 }
135
136 TestSuite* DataFactoryTestCase::suite()
137 {
138 TestSuite *testSuite = new TestSuite("DataFactoryTestCase");
139
140 testSuite->addTest(new TestCaller<DataFactoryTestCase>(
141 "testAll",&DataFactoryTestCase::testAll));
142 return testSuite;
143 }
144

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26