ASL 0.1.7
Advanced Simulation Library
Loading...
Searching...
No Matches
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
29#include "aslUtilities.h"
30#include "math/aslVectors.h"
31#include "data/aslBlocks.h"
32
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
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
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
103{
104 cout << "Test of Block..." << flush;
106 asl::AVec<float> af(asl::makeAVec(2.f,3.f));
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
126int 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}
useful common utilities
definition of class АVec<T>
ABD (ASL Binary Dump) file, input.
Definition: aslABDFormat.h:49
ABD (ASL Binary Dump) file, output.
Definition: aslABDFormat.h:59
double dx
Definition: aslBlocks.h:66
const DV & getSize() const
Definition: aslBlocks.h:208
void errorMessage(cl_int status, const char *errorMessage)
Prints errorMessage and exits depending on the status.
AVec< T > makeAVec(T a1)
bool testBlock()
bool testNumbers()
bool testString()
int main()
bool testAVec()