1 |
jgs |
97 |
// $Id$ |
2 |
jgs |
82 |
/* |
3 |
|
|
***************************************************************************** |
4 |
|
|
* * |
5 |
|
|
* COPYRIGHT ACcESS - All Rights Reserved * |
6 |
|
|
* * |
7 |
|
|
* This software is the property of ACcESS. No part of this code * |
8 |
|
|
* may be copied in any form or by any means without the expressed written * |
9 |
|
|
* consent of ACcESS. Copying, use or modification of this software * |
10 |
|
|
* by any unauthorised person is illegal unless that person has a software * |
11 |
|
|
* license agreement with ACcESS. * |
12 |
|
|
* * |
13 |
|
|
***************************************************************************** |
14 |
|
|
*/ |
15 |
|
|
#include "escript/Data/DataAlgorithm.h" |
16 |
|
|
#include "DataAlgorithmAdapterTestCase.h" |
17 |
|
|
|
18 |
|
|
#include <iostream> |
19 |
|
|
#include <algorithm> |
20 |
|
|
#include <math.h> |
21 |
|
|
#include <limits> |
22 |
|
|
|
23 |
|
|
using namespace CppUnitTest; |
24 |
|
|
using namespace std; |
25 |
|
|
using namespace escript; |
26 |
|
|
|
27 |
|
|
void DataAlgorithmAdapterTestCase::setUp() { |
28 |
|
|
// |
29 |
|
|
// This is called before each test is run |
30 |
|
|
|
31 |
|
|
} |
32 |
|
|
|
33 |
|
|
void DataAlgorithmAdapterTestCase::tearDown() { |
34 |
|
|
// |
35 |
|
|
// This is called after each test has been run |
36 |
|
|
|
37 |
|
|
} |
38 |
|
|
|
39 |
|
|
void DataAlgorithmAdapterTestCase::testAll() { |
40 |
jgs |
97 |
|
41 |
jgs |
82 |
cout << endl; |
42 |
jgs |
97 |
|
43 |
|
|
cout << "\tTesting FMax." << endl; |
44 |
jgs |
82 |
DataAlgorithmAdapter<FMax> myMax(numeric_limits<double>::min()); |
45 |
|
|
myMax(1); |
46 |
|
|
myMax(2); |
47 |
jgs |
97 |
myMax(14); |
48 |
jgs |
82 |
myMax(3); |
49 |
jgs |
97 |
assert(myMax.getResult()==14); |
50 |
|
|
|
51 |
|
|
cout << "\tTesting AbsMax." << endl; |
52 |
|
|
DataAlgorithmAdapter<AbsMax> Lsup(0); |
53 |
jgs |
82 |
Lsup(-2); |
54 |
|
|
Lsup(2); |
55 |
|
|
Lsup(5); |
56 |
jgs |
97 |
Lsup(-10); |
57 |
|
|
assert(Lsup.getResult()==10); |
58 |
|
|
|
59 |
|
|
cout << "\tTesting FMin." << endl; |
60 |
jgs |
82 |
DataAlgorithmAdapter<FMin> inf(numeric_limits<double>::max()); |
61 |
|
|
inf(1); |
62 |
jgs |
97 |
inf(12); |
63 |
jgs |
82 |
inf(2); |
64 |
jgs |
97 |
inf(99); |
65 |
|
|
assert(inf.getResult()==1); |
66 |
|
|
|
67 |
|
|
cout << "\tSize: " << sizeof(DataAlgorithmAdapter<FMin>) << endl; |
68 |
|
|
|
69 |
jgs |
82 |
} |
70 |
|
|
|
71 |
|
|
TestSuite* DataAlgorithmAdapterTestCase::suite () |
72 |
|
|
{ |
73 |
|
|
// |
74 |
|
|
// create the suite of tests to perform. |
75 |
|
|
TestSuite *testSuite = new TestSuite ("DataAlgorithmAdapterTestCase"); |
76 |
|
|
|
77 |
|
|
testSuite->addTest (new TestCaller< DataAlgorithmAdapterTestCase>("testAll",&DataAlgorithmAdapterTestCase::testAll)); |
78 |
|
|
return testSuite; |
79 |
|
|
} |
80 |
|
|
|