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