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 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136
|
/*
* Advanced Simulation Library <http://asl.org.il>
*
* Copyright 2015 Avtech Scientific <http://avtechscientific.com>
*
*
* This file is part of Advanced Simulation Library (ASL).
*
* ASL is free software: you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, version 3 of the License.
*
* ASL is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with ASL. If not, see <http://www.gnu.org/licenses/>.
*
*/
/**
\example testABDFormat.cc
*/
#include "writers/aslABDFormat.h"
#include "aslUtilities.h"
#include "math/aslVectors.h"
#include "data/aslBlocks.h"
bool testNumbers()
{
cout << "Test of Numbers..." << flush;
unsigned int aui(3);
int ai(-2);
float af(5);
double ad(4);
asl::ABDFileOut afO("test.abd");
afO << aui << ai << af << ad;
afO.close();
asl::ABDFileIn afI("test.abd");
unsigned int bui(0);
int bi(0);
float bf(0);
double bd(0);
afI >> bui >> bi >> bf >> bd;
bool status((aui==bui) && (ai==bi) && (af==bf) && (ad==bd));
asl::errorMessage(status);
return status;
}
bool testAVec()
{
cout << "Test of AVec..." << flush;
asl::Block b(asl::makeAVec (10,15),0.1,asl::makeAVec (.1,1.));
asl::ABDFileOut afO("test.abd");
afO << b;
afO.close();
asl::ABDFileIn afI("test.abd");
asl::Block bn;
afI >> bn;
bool status((b.getSize() == bn.getSize()) &&
(b.dx == bn.dx) &&
(b.position == bn.position));
asl::errorMessage(status);
return status;
}
bool testString()
{
cout << "Test of String..." << flush;
std::string b("Hello!!");
asl::ABDFileOut afO("test.abd");
afO << b;
afO.close();
asl::ABDFileIn afI("test.abd");
std::string bn;
afI >> bn;
bool status(b == bn);
asl::errorMessage(status);
return status;
}
bool testBlock()
{
cout << "Test of Block..." << flush;
asl::AVec<int> ai(asl::makeAVec(2,3));
asl::AVec<float> af(asl::makeAVec(2.f,3.f));
asl::AVec<double> ad(asl::makeAVec(4.,5.));
asl::ABDFileOut afO("test.abd");
afO << ai << af << ad;
afO.close();
asl::ABDFileIn afI("test.abd");
asl::AVec<int> bi(1);
asl::AVec<float> bf(1);
asl::AVec<double> bd(1);
afI >> bi >> bf >> bd;
bool status((ai == bi) && (af == bf) && (ad == bd));
asl::errorMessage(status);
return status;
}
int main()
{
bool allTestsPassed(true);
allTestsPassed &= testNumbers();
allTestsPassed &= testAVec();
allTestsPassed &= testString();
allTestsPassed &= testBlock();
return allTestsPassed ? EXIT_SUCCESS : EXIT_FAILURE;
}
|