ASL  0.1.7
Advanced Simulation Library
testABDFormat.cc
/*
* 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/>.
*
*/
#include "aslUtilities.h"
#include "data/aslBlocks.h"
{
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));
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");
afI >> bn;
bool status((b.getSize() == bn.getSize()) &&
(b.dx == bn.dx) &&
(b.position == bn.position));
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);
return status;
}
bool testBlock()
{
cout << "Test of Block..." << flush;
asl::ABDFileOut afO("test.abd");
afO << ai << af << ad;
afO.close();
asl::ABDFileIn afI("test.abd");
afI >> bi >> bf >> bd;
bool status((ai == bi) && (af == bf) && (ad == bd));
return status;
}
int main()
{
bool allTestsPassed(true);
allTestsPassed &= testNumbers();
allTestsPassed &= testAVec();
allTestsPassed &= testString();
allTestsPassed &= testBlock();
return allTestsPassed ? EXIT_SUCCESS : EXIT_FAILURE;
}