/[escript]/trunk/weipa/test/EscriptDatasetTestCase.cpp
ViewVC logotype

Contents of /trunk/weipa/test/EscriptDatasetTestCase.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3129 - (show annotations)
Wed Sep 1 07:58:23 2010 UTC (8 years, 10 months ago) by caltinay
File size: 2748 byte(s)
Fixed unit test.

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 "escript/DataFactory.h"
16 #include "finley/CppAdapter/MeshAdapterFactory.h"
17 #include "weipa/EscriptDataset.h"
18 #include "EscriptDatasetTestCase.h"
19
20 using namespace CppUnitTest;
21 using namespace escript;
22 using namespace finley;
23 using namespace weipa;
24 using namespace std;
25
26 void EscriptDatasetTestCase::setUp()
27 {
28 // This is called before each test is run
29 }
30
31 void EscriptDatasetTestCase::tearDown()
32 {
33 // This is called after each test has been run
34 }
35
36 void EscriptDatasetTestCase::testAll()
37 {
38 cout << endl;
39 cout << "\tTest default constructor." << endl;
40 EscriptDataset_ptr dataset(new EscriptDataset());
41
42 cout << "\tTest saveSilo without data." << endl;
43 assert(dataset->saveSilo("dummy") == false);
44
45 cout << "\tTest saveVTK without data." << endl;
46 assert(dataset->saveVTK("dummy") == false);
47
48 cout << "\tTest getConvertedDomain without data." << endl;
49 assert(dataset->getConvertedDomain().size() == 0);
50
51 cout << "\tTest getVariables without data." << endl;
52 assert(dataset->getVariables().size() == 0);
53
54 cout << "\tTest getMeshVariables without data." << endl;
55 assert(dataset->getMeshVariables().size() == 0);
56
57 // instantiate a domain and data
58 Domain_ptr dom2d(rectangle());
59 //Domain_ptr dom3d(brick());
60 escript::Data dataOn2d = Scalar(0.0, continuousFunction(*dom2d), true);
61 //escript::Data dataOn3d = Scalar(0.0, continuousFunction(*dom3d), true);
62
63 cout << "\tTest addData with NULL domain." << endl;
64 assert(dataset->addData(dataOn2d, "foo", "bar") == false);
65
66 cout << "\tTest setDomain." << endl;
67 assert(dataset->setDomain(dom2d.get()) == true);
68
69 cout << "\tTest bogus setDomain call." << endl;
70 assert(dataset->setDomain(dom2d.get()) == false);
71
72 cout << "\tTest getConvertedDomain." << endl;
73 assert(dataset->getConvertedDomain().size() > 0);
74
75 cout << "\tTest addData with valid data." << endl;
76 assert(dataset->addData(dataOn2d, "test2d", "") == true);
77 assert(dataset->getVariables().size() == 1);
78 }
79
80 TestSuite* EscriptDatasetTestCase::suite()
81 {
82 //
83 // create the suite of tests to perform.
84 TestSuite *testSuite = new TestSuite("EscriptDatasetTestCase");
85
86 testSuite->addTest(new TestCaller<EscriptDatasetTestCase>(
87 "testAll",&EscriptDatasetTestCase::testAll));
88 return testSuite;
89 }
90

  ViewVC Help
Powered by ViewVC 1.1.26