lumiera_/src/lib/test/test-helper.cpp

67 lines
1.8 KiB
C++
Raw Normal View History

/*
Test-Helper - collection of functions supporting unit testing
2010-12-17 23:28:49 +01:00
Copyright (C) Lumiera.org
2009, Hermann Vosseler <Ichthyostega@web.de>
2010-12-17 23:28:49 +01:00
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
2010-12-17 23:28:49 +01:00
published by the Free Software Foundation; either version 2 of
the License, or (at your option) any later version.
This program 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.
2010-12-17 23:28:49 +01:00
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
2010-12-17 23:28:49 +01:00
* *****************************************************/
#include "lib/test/test-helper.hpp"
#include "lib/test/testdummy.hpp"
#include "lib/format-string.hpp"
#include <string>
using std::string;
2009-05-31 02:41:00 +02:00
namespace lib {
namespace test{
string
showSizeof (size_t siz, const char* name)
{
static util::_Fmt fmt ("sizeof( %s ) %|30t|= %3d");
return string (fmt % (name? name:"?") % siz);
}
2009-10-30 03:53:51 +01:00
/** @todo probably this can be done in a more clever way. Anyone...?
*/
string
randStr (size_t len)
{
static const string alpha ("aaaabbccddeeeeffgghiiiijjkkllmmnnooooppqqrrssttuuuuvvwwxxyyyyzz0123456789");
static const size_t MAXAL (alpha.size());
string garbage(len,'\0');
size_t p = len;
while (p)
garbage[--p] = alpha[rand() % MAXAL];
return garbage;
}
2009-10-30 03:53:51 +01:00
/** storage for test-dummy flags */
long Dummy::_local_checksum = 0;
bool Dummy::_throw_in_ctor = false;
2009-10-30 03:53:51 +01:00
}} // namespace lib::test