00001 /*************************************************************************** 00002 tag: The SourceWorks Tue Sep 7 00:54:57 CEST 2010 typekit_test.cpp 00003 00004 typekit_test.cpp - description 00005 ------------------- 00006 begin : Tue September 07 2010 00007 copyright : (C) 2010 The SourceWorks 00008 email : peter@thesourceworks.com 00009 00010 *************************************************************************** 00011 * * 00012 * This program is free software; you can redistribute it and/or modify * 00013 * it under the terms of the GNU General Public License as published by * 00014 * the Free Software Foundation; either version 2 of the License, or * 00015 * (at your option) any later version. * 00016 * * 00017 ***************************************************************************/ 00018 00019 00027 #include "unit.hpp" 00028 00029 #include <types/TemplateTypeInfo.hpp> 00030 #include <types/TemplateConstructor.hpp> 00031 #include <types/Operators.hpp> 00032 #include <types/OperatorTypes.hpp> 00033 00034 #include <types/VectorTemplateComposition.hpp> 00035 00036 struct TypekitFixture 00037 { 00038 }; 00039 00040 // Registers the fixture into the 'registry' 00041 BOOST_FIXTURE_TEST_SUITE( TypekitTestSuite, TypekitFixture ) 00042 00043 00044 BOOST_AUTO_TEST_CASE( testVectorTypeInfo ) 00045 { 00046 Types()->addType( new types::StdVectorTemplateTypeInfo<std::string,true>("strings") ); 00047 Types()->type("strings")->addConstructor(newConstructor(types::stdvector_ctor<std::string>() ) ); 00048 Types()->type("strings")->addConstructor(newConstructor(types::stdvector_ctor2<std::string>() ) ); 00049 Types()->type("strings")->addConstructor(new types::StdVectorBuilder<std::string>() ); 00050 00051 #if 1 00052 Types()->addType( new types::StdVectorTemplateTypeInfo<bool,true>("bools") ); 00053 Types()->type("bools")->addConstructor(newConstructor(types::stdvector_ctor<bool>() ) ); 00054 Types()->type("bools")->addConstructor(newConstructor(types::stdvector_ctor2<bool>() ) ); 00055 Types()->type("bools")->addConstructor(new types::StdVectorBuilder<bool>() ); 00056 #endif 00057 00058 Types()->addType( new types::StdVectorTemplateTypeInfo<int,true>("ints") ); 00059 Types()->type("ints")->addConstructor(newConstructor(types::stdvector_ctor<int>() ) ); 00060 Types()->type("ints")->addConstructor(newConstructor(types::stdvector_ctor2<int>() ) ); 00061 Types()->type("ints")->addConstructor(new types::StdVectorBuilder<int>() ); 00062 } 00063 00064 BOOST_AUTO_TEST_CASE( testComposeDecompose ) 00065 { 00066 vector<string> names = Types()->getTypes(); 00067 for(vector<string>::iterator it = names.begin(); it != names.end(); ++it) { 00068 TypeInfo* ti = Types()->type(*it); 00069 BOOST_REQUIRE(ti); 00070 // might return null in case of void: 00071 PropertyBase* input = ti->buildProperty("A","B"); 00072 PropertyBase* output = ti->buildProperty("C","D"); 00073 // if it's decomposable, compose it as well. 00074 if ( input && output && ti->decomposeType(input->getDataSource()) ) 00075 BOOST_CHECK( ti->composeType( ti->decomposeType(input->getDataSource()), output->getDataSource()) ); 00076 } 00077 } 00078 00079 BOOST_AUTO_TEST_SUITE_END()