/
test_adolc.cpp
55 lines (42 loc) · 1011 Bytes
/
test_adolc.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
//g++ -Iadolc-1.11.0-trunk/include/ -Wl,--rpath -Wl,${PWD}/adolc-1.11.0-trunk/lib -Ladolc-1.11.0-trunk/lib -ladolc -o test -O3 test.cpp
#include "adolc.h"
#include <iostream>
#include <string>
using namespace std;
int test_condassign_on_adouble(){
adouble a(2.);
adouble cond(3.);
adouble cond2(-3.);
adouble b(4.);
adouble c(5.);
condassign(a,cond,b,c);
if(a != b)return -1;
condassign(a,cond2,b,c);
if(a != c)return -1;
return 0;
}
int test_condassign_on_double(){
double a(2.);
double cond(3.);
double cond2(-3.);
double b(4.);
double c(5.);
condassign(a,cond,b,c);
if(a != b) return -1;
condassign(a,cond2,b,c);
if(a != c) return -1;
return 0;
}
void check(int error, string test_name){
if(error != 0){
cout<<"Test "<<test_name<<" : failed!"<<endl;
}
else{
cout<<"Test "<<test_name<<" : OK!"<<endl;
}
}
int main(){
check(test_condassign_on_adouble(),"test_condassign_on_adouble");
check(test_condassign_on_double(),"test_condassign_on_double");
return 0;
}