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

Contents of /trunk/escript/test/multi_arrayTestCase.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: 1788 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 "boost/multi_array.hpp"
16 #include "multi_arrayTestCase.h"
17
18 #include <iostream>
19
20 using namespace CppUnitTest;
21 using namespace std;
22
23 void multi_arrayTestCase::setUp() {
24 //
25 // This is called before each test is run
26
27 }
28
29 void multi_arrayTestCase::tearDown() {
30 //
31 // This is called after each test has been run
32
33 }
34
35 void multi_arrayTestCase::testAll() {
36 //
37 // Test boost multi_array
38 typedef boost::multi_array<double, 3> ArrayType;
39 typedef ArrayType::index_range range;
40 ArrayType testArr(boost::extents[1][2][3]);
41 cout << endl;
42 for (ArrayType::index i=0;i!=1;++i) {
43 for (ArrayType::index j=0;j!=2;++j) {
44 for (ArrayType::index k=0;k!=3;++k) {
45 testArr[i][j][k]=k+j*3+i*(1*2);
46 cout << "(" << i << "," << j << "," << k << ") "
47 << testArr[i][j][k] << endl;
48 }
49 }
50 }
51 ArrayType::index_gen indices;
52 ArrayType::array_view<2>::type OneView=testArr[ indices[range()][range()][1] ];
53 for (ArrayType::index i=0;i!=1;++i) {
54 for (ArrayType::index j=0;j!=2;++j) {
55 cout << "(" << i << "," << j << ",1) " << OneView[i][j] << endl;
56 }
57 }
58
59 }
60
61 TestSuite* multi_arrayTestCase::suite ()
62 {
63 //
64 // create the suite of tests to perform.
65 TestSuite *testSuite = new TestSuite ("multi_arrayTestCase");
66
67 testSuite->addTest (new TestCaller< multi_arrayTestCase>("testAll",&multi_arrayTestCase::testAll));
68 return testSuite;
69 }
70

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26