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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3962 - (show annotations)
Tue Sep 11 09:12:07 2012 UTC (6 years, 11 months ago) by jfenwick
File size: 5188 byte(s)
Fix in brick for ambiguous typing.

Python work around for unit tests.
Passing cpp tests as well.

omp is disabled due to a weird linking error.

1
2 /*******************************************************
3 *
4 * Copyright (c) 2003-2012 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 #ifdef BADPYTHONMACROS
15 // This hack is required for BSD/OSX builds with python 2.7
16 // (and possibly others). It must be the first include.
17 // From bug reports online it seems that python redefines
18 // some c macros that are functions in c++.
19 // c++ doesn't like that!
20 #include <Python.h>
21 #undef BADPYTHONMACROS
22 #endif
23
24
25
26 #include "DataFactoryTestCase.h"
27
28 #include "escript/DataFactory.h"
29 #include "escript/Data.h"
30
31 #include <cppunit/TestCaller.h>
32 #include <iostream>
33
34 using namespace CppUnit;
35 using namespace escript;
36 using namespace std;
37
38 void DataFactoryTestCase::testAll()
39 {
40 cout << endl;
41 cout << "\tUse DataFactory functions to create some Data objects:" << endl;
42
43 {
44 cout << "\tCreate Data (DataConstant) object with Scalar data points." << endl;
45 Data scalar=Scalar(1.3);
46 //cout << scalar.toString() << endl;
47 CPPUNIT_ASSERT(scalar.isConstant());
48 CPPUNIT_ASSERT(scalar.getDataPointRank()==0);
49 CPPUNIT_ASSERT(scalar.getDataPointShape().empty());
50 }
51
52 {
53 cout << "\tCreate DataExpanded object with Scalar data points." << endl;
54 Data scalar=Scalar(1.5,FunctionSpace(),true);
55 //cout << scalar.toString() << endl;
56 CPPUNIT_ASSERT(scalar.isExpanded());
57 CPPUNIT_ASSERT(scalar.getDataPointRank()==0);
58 CPPUNIT_ASSERT(scalar.getDataPointShape().empty());
59 }
60
61 {
62 cout << "\tCreate Data (DataConstant) object with Vector data points." << endl;
63 Data vector=Vector(1.3);
64 //cout << vector.toString() << endl;
65 CPPUNIT_ASSERT(vector.isConstant());
66 CPPUNIT_ASSERT(vector.getDataPointRank()==1);
67 CPPUNIT_ASSERT(vector.getDataPointShape()[0]==1);;
68 }
69
70 {
71 cout << "\tCreate Data Expanded object with Vector data points." << endl;
72 Data vector=Vector(1.5,FunctionSpace(),true);
73 //cout << vector.toString() << endl;
74 CPPUNIT_ASSERT(vector.isExpanded());
75 CPPUNIT_ASSERT(vector.getDataPointRank()==1);
76 CPPUNIT_ASSERT(vector.getDataPointShape()[0]==1);;
77 }
78
79 {
80 cout << "\tCreate Data (DataConstant) object with Tensor data points." << endl;
81 Data tensor=Tensor(1.3);
82 //cout << tensor.toString() << endl;
83 CPPUNIT_ASSERT(tensor.isConstant());
84 CPPUNIT_ASSERT(tensor.getDataPointRank()==2);
85 CPPUNIT_ASSERT(tensor.getDataPointShape()[0]==1);;
86 CPPUNIT_ASSERT(tensor.getDataPointShape()[1]==1);;
87 }
88
89 {
90 cout << "\tCreate Data Expanded object with Tensor data points." << endl;
91 Data tensor=Tensor(1.5,FunctionSpace(),true);
92 //cout << tensor.toString() << endl;
93 CPPUNIT_ASSERT(tensor.isExpanded());
94 CPPUNIT_ASSERT(tensor.getDataPointRank()==2);
95 CPPUNIT_ASSERT(tensor.getDataPointShape()[0]==1);;
96 CPPUNIT_ASSERT(tensor.getDataPointShape()[1]==1);;
97 }
98
99 {
100 cout << "\tCreate Data (DataConstant) object with Tensor3 data points." << endl;
101 Data tensor3=Tensor3(1.3);
102 //cout << tensor3.toString() << endl;
103 CPPUNIT_ASSERT(tensor3.isConstant());
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 Expanded object with Tensor3 data points." << endl;
112 Data tensor3=Tensor3(1.5,FunctionSpace(),true);
113 //cout << tensor3.toString() << endl;
114 CPPUNIT_ASSERT(tensor3.isExpanded());
115 CPPUNIT_ASSERT(tensor3.getDataPointRank()==3);
116 CPPUNIT_ASSERT(tensor3.getDataPointShape()[0]==1);;
117 CPPUNIT_ASSERT(tensor3.getDataPointShape()[1]==1);;
118 CPPUNIT_ASSERT(tensor3.getDataPointShape()[2]==1);;
119 }
120
121 {
122 cout << "\tCreate Data (DataConstant) object with Tensor4 data points." << endl;
123 Data tensor4=Tensor4(1.3);
124 //cout << tensor4.toString() << endl;
125 CPPUNIT_ASSERT(tensor4.isConstant());
126 CPPUNIT_ASSERT(tensor4.getDataPointRank()==4);
127 CPPUNIT_ASSERT(tensor4.getDataPointShape()[0]==1);;
128 CPPUNIT_ASSERT(tensor4.getDataPointShape()[1]==1);;
129 CPPUNIT_ASSERT(tensor4.getDataPointShape()[2]==1);;
130 CPPUNIT_ASSERT(tensor4.getDataPointShape()[3]==1);;
131 }
132
133 {
134 cout << "\tCreate Data Expanded object with Tensor4 data points." << endl;
135 Data tensor4=Tensor4(1.5,FunctionSpace(),true);
136 //cout << tensor4.toString() << endl;
137 CPPUNIT_ASSERT(tensor4.isExpanded());
138 CPPUNIT_ASSERT(tensor4.getDataPointRank()==4);
139 CPPUNIT_ASSERT(tensor4.getDataPointShape()[0]==1);;
140 CPPUNIT_ASSERT(tensor4.getDataPointShape()[1]==1);;
141 CPPUNIT_ASSERT(tensor4.getDataPointShape()[2]==1);;
142 CPPUNIT_ASSERT(tensor4.getDataPointShape()[3]==1);;
143 }
144
145 }
146
147 TestSuite* DataFactoryTestCase::suite()
148 {
149 TestSuite *testSuite = new TestSuite("DataFactoryTestCase");
150
151 testSuite->addTest(new TestCaller<DataFactoryTestCase>(
152 "testAll",&DataFactoryTestCase::testAll));
153 return testSuite;
154 }
155

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26