From 67b79d920671efeeb0d9bb27d2ad42fd3ceca3e8 Mon Sep 17 00:00:00 2001 From: Mark Olesen <Mark.Olesen@Germany> Date: Thu, 3 Dec 2009 14:40:12 +0100 Subject: [PATCH] commit existing sizeof test --- applications/test/sizeof/Make/files | 3 + applications/test/sizeof/Make/options | 2 + applications/test/sizeof/sizeofTest.C | 105 ++++++++++++++++++++++++++ 3 files changed, 110 insertions(+) create mode 100644 applications/test/sizeof/Make/files create mode 100644 applications/test/sizeof/Make/options create mode 100644 applications/test/sizeof/sizeofTest.C diff --git a/applications/test/sizeof/Make/files b/applications/test/sizeof/Make/files new file mode 100644 index 00000000000..c0a650baca6 --- /dev/null +++ b/applications/test/sizeof/Make/files @@ -0,0 +1,3 @@ +sizeofTest.C + +EXE = $(FOAM_USER_APPBIN)/sizeofTest diff --git a/applications/test/sizeof/Make/options b/applications/test/sizeof/Make/options new file mode 100644 index 00000000000..6a9e9810b3d --- /dev/null +++ b/applications/test/sizeof/Make/options @@ -0,0 +1,2 @@ +/* EXE_INC = -I$(LIB_SRC)/cfdTools/include */ +/* EXE_LIBS = -lfiniteVolume */ diff --git a/applications/test/sizeof/sizeofTest.C b/applications/test/sizeof/sizeofTest.C new file mode 100644 index 00000000000..aa1b720bb5b --- /dev/null +++ b/applications/test/sizeof/sizeofTest.C @@ -0,0 +1,105 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2009-2009 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM 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 General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Description + Test the sizeof various classes. + +\*---------------------------------------------------------------------------*/ + +#include "bool.H" +#include "Switch.H" +#include "string.H" +#include "dictionary.H" +#include "nil.H" +#include "IOstreams.H" +#include "IStringStream.H" + +namespace Foam +{ + class hasBoolClass + { + public: + bool b_; + + hasBoolClass(const bool val=false) + : + b_(false) + {} + }; + +} + + +using namespace Foam; + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +// Main program: + +int main(int argc, char *argv[]) +{ + cout<<"sizeof\n------\n"; + { + nil x; + cout<<"nil:" << sizeof(x) << nl; + } + { + bool x(0); + cout<<"bool:" << sizeof(x) << nl; + } + { + hasBoolClass x(true); + cout<<"hasBoolClass:" << sizeof(x) << nl; + } + + { + Switch x("n"); + cout<<"Switch:" << sizeof(x) << nl; + cout<<"Switch::switchType=" << sizeof(Switch::switchType) << nl; + } + + { + scalar x(0); + cout<<"scalar:" << sizeof(x) << nl; + } + + { + label x(0); + cout<<"label:" << sizeof(x) << nl; + } + + { + cout<<"int:" << sizeof(int) << nl; + cout<<"long:" << sizeof(long) << nl; + cout<<"float:" << sizeof(float) << nl; + cout<<"double:" << sizeof(double) << nl; + } + + + Info << "---\nEnd\n" << endl; + + return 0; +} + + +// ************************************************************************* // -- GitLab