From 10f767388887db3c0faae5ef071b79dba257c100 Mon Sep 17 00:00:00 2001 From: tslettebo Date: Mon, 7 Oct 2002 13:21:04 +0000 Subject: [PATCH] no message git-svn-id: svn://svn.code.sf.net/p/loki-lib/code/trunk@64 7ec92016-0320-0410-acc4-a06ded1c099a --- tools/RegressionTest/DataGeneratorsTest.h | 70 +++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 tools/RegressionTest/DataGeneratorsTest.h diff --git a/tools/RegressionTest/DataGeneratorsTest.h b/tools/RegressionTest/DataGeneratorsTest.h new file mode 100644 index 0000000..b19f06e --- /dev/null +++ b/tools/RegressionTest/DataGeneratorsTest.h @@ -0,0 +1,70 @@ +//DataGeneratorsTest.h + + +#ifndef DATAGENERATORSTEST_H +#define DATAGENERATORSTEST_H + +#include +#include +#include "UnitTest.h" + +template +T& remove_const(const T& t) + { + return const_cast(t); + } + + +struct DataGeneratorsTest : public Test + { + DataGeneratorsTest() : Test("DataGeneratorsTest.h") + {} + virtual void execute(TestResult& result) + { + this->printName(result); + + using namespace Loki; + using namespace Loki::TL; + + bool b; + typedef MakeTypelist<>::Result null_tl; + typedef MakeTypelist::Result char_types; + int n = Length::value; + + std::vector names; + names.reserve(n); + //Some fascist decided that all temporaries should be const. + //The following line of code stupidity is a direct result of the half-baked idea + iterate_types(remove_const(std::back_inserter(names))); + b = names.size() == n; + testAssert("iterate_types - Check Length", b, result); + + std::vector sizes; + sizes.reserve(n); + typedef MakeTypelist::Result some_types; + iterate_types(remove_const(std::back_inserter(sizes))); + size_t apriori_size[] = {sizeof(char), sizeof(short), sizeof(int), sizeof(double)}; + b = true; + for(int i=0; i(sizes); + b = sizes.size() == 0; + testAssert("iterate_types - Degenerate Case 1 - Null List", b, result); + + sizes.resize(0); + iterate_types(sizes); + b = sizes.size() == 0; + testAssert("iterate_types - Degenerate Case 2 - NullType", b, result); + } + }; + +#endif //DATAGENERATORSTEST_H