ASL
0.1.7
Advanced Simulation Library
Loading...
Searching...
No Matches
test
testABD
testABDFormat.cc
Go to the documentation of this file.
1
/*
2
* Advanced Simulation Library <http://asl.org.il>
3
*
4
* Copyright 2015 Avtech Scientific <http://avtechscientific.com>
5
*
6
*
7
* This file is part of Advanced Simulation Library (ASL).
8
*
9
* ASL is free software: you can redistribute it and/or modify it
10
* under the terms of the GNU Affero General Public License as
11
* published by the Free Software Foundation, version 3 of the License.
12
*
13
* ASL is distributed in the hope that it will be useful,
14
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
* GNU Affero General Public License for more details.
17
*
18
* You should have received a copy of the GNU Affero General Public License
19
* along with ASL. If not, see <http://www.gnu.org/licenses/>.
20
*
21
*/
22
23
28
#include "writers/aslABDFormat.h"
29
#include "aslUtilities.h"
30
#include "math/aslVectors.h"
31
#include "data/aslBlocks.h"
32
33
bool
testNumbers
()
34
{
35
cout <<
"Test of Numbers..."
<< flush;
36
unsigned
int
aui(3);
37
int
ai(-2);
38
float
af(5);
39
double
ad(4);
40
41
asl::ABDFileOut
afO(
"test.abd"
);
42
afO << aui << ai << af << ad;
43
afO.close();
44
45
asl::ABDFileIn
afI(
"test.abd"
);
46
unsigned
int
bui(0);
47
int
bi(0);
48
float
bf(0);
49
double
bd(0);
50
51
afI >> bui >> bi >> bf >> bd;
52
53
bool
status((aui==bui) && (ai==bi) && (af==bf) && (ad==bd));
54
asl::errorMessage
(status);
55
56
return
status;
57
}
58
59
bool
testAVec
()
60
{
61
cout <<
"Test of AVec..."
<< flush;
62
asl::Block
b(
asl::makeAVec
(10,15),0.1,
asl::makeAVec
(.1,1.));
63
64
asl::ABDFileOut
afO(
"test.abd"
);
65
afO << b;
66
afO.close();
67
68
asl::ABDFileIn
afI(
"test.abd"
);
69
asl::Block
bn;
70
71
afI >> bn;
72
73
bool
status((b.
getSize
() == bn.
getSize
()) &&
74
(b.
dx
== bn.
dx
) &&
75
(b.
position
== bn.
position
));
76
asl::errorMessage
(status);
77
78
return
status;
79
}
80
81
bool
testString
()
82
{
83
cout <<
"Test of String..."
<< flush;
84
std::string b(
"Hello!!"
);
85
86
asl::ABDFileOut
afO(
"test.abd"
);
87
afO << b;
88
afO.close();
89
90
asl::ABDFileIn
afI(
"test.abd"
);
91
std::string bn;
92
93
afI >> bn;
94
95
bool
status(b == bn);
96
asl::errorMessage
(status);
97
98
return
status;
99
}
100
101
102
bool
testBlock
()
103
{
104
cout <<
"Test of Block..."
<< flush;
105
asl::AVec<int>
ai(
asl::makeAVec
(2,3));
106
asl::AVec<float>
af(
asl::makeAVec
(2.f,3.f));
107
asl::AVec<double>
ad(
asl::makeAVec
(4.,5.));
108
109
asl::ABDFileOut
afO(
"test.abd"
);
110
afO << ai << af << ad;
111
afO.close();
112
113
asl::ABDFileIn
afI(
"test.abd"
);
114
asl::AVec<int>
bi(1);
115
asl::AVec<float>
bf(1);
116
asl::AVec<double>
bd(1);
117
118
afI >> bi >> bf >> bd;
119
120
bool
status((ai == bi) && (af == bf) && (ad == bd));
121
asl::errorMessage
(status);
122
123
return
status;
124
}
125
126
int
main
()
127
{
128
bool
allTestsPassed(
true
);
129
130
allTestsPassed &=
testNumbers
();
131
allTestsPassed &=
testAVec
();
132
allTestsPassed &=
testString
();
133
allTestsPassed &=
testBlock
();
134
135
return
allTestsPassed ? EXIT_SUCCESS : EXIT_FAILURE;
136
}
asl::ABDFileIn
ABD (ASL Binary Dump) file, input.
Definition
aslABDFormat.h:49
asl::ABDFileOut
ABD (ASL Binary Dump) file, output.
Definition
aslABDFormat.h:59
asl::AVec
Definition
aslVectorsDynamicLength.h:40
asl::Block
Definition
aslBlocks.h:57
asl::Block::dx
double dx
Definition
aslBlocks.h:66
asl::Block::getSize
const DV & getSize() const
Definition
aslBlocks.h:208
asl::Block::position
V position
Definition
aslBlocks.h:65
asl::errorMessage
void errorMessage(cl_int status, const char *errorMessage)
Prints errorMessage and exits depending on the status.
asl::makeAVec
AVec< T > makeAVec(T a1)
Definition
aslVectorsDynamicLength.h:176
testBlock
bool testBlock()
Definition
testABDFormat.cc:102
testNumbers
bool testNumbers()
Definition
testABDFormat.cc:33
testString
bool testString()
Definition
testABDFormat.cc:81
main
int main()
Definition
testABDFormat.cc:126
testAVec
bool testAVec()
Definition
testABDFormat.cc:59
Generated by
1.9.8