COOLFluiD  Release kernel
COOLFluiD is a Collaborative Simulation Environment (CSE) focused on complex MultiPhysics simulations.
utest-factory.cpp
Go to the documentation of this file.
1 // Copyright (C) 2010-2013 von Karman Institute for Fluid Dynamics, Belgium
2 //
3 // This software is distributed under the terms of the
4 // GNU Lesser General Public License version 3 (LGPLv3).
5 // See doc/lgpl.txt and doc/gpl.txt for the license text.
6 
7 #define BOOST_TEST_DYN_LINK
8 #define BOOST_TEST_MODULE "Test module for component factory"
9 
10 #include <boost/test/unit_test.hpp>
11 
12 #include "common/Log.hpp"
13 
15 
16 #include "common/Factories.hpp"
17 #include "common/Builder.hpp"
18 #include "common/OptionList.hpp"
19 
20 
21 using namespace std;
22 using namespace boost;
23 using namespace cf3;
24 using namespace cf3::common;
25 
27 
29 {
32 
35 };
36 
38 
39 BOOST_FIXTURE_TEST_SUITE( FactoryTest, FactoryFixture )
40 
41 
43 BOOST_AUTO_TEST_CASE( get_factory )
44 {
45  Handle<Factories> factories(Core::instance().root().get_child("Factories"));
46 
47  BOOST_CHECK( factories->get_factory< CAbstract >() != nullptr );
48 
49 }
50 
52 
53 BOOST_AUTO_TEST_CASE( component_builder )
54 {
57 
58  Handle<Factories> factories(Core::instance().root().get_child("Factories"));
59 
60  Handle< FactoryT<CAbstract> > cabstract_factory = factories->get_factory< CAbstract >();
61  BOOST_CHECK( cabstract_factory != nullptr );
62  BOOST_CHECK_EQUAL( cabstract_factory->factory_type_name() , std::string("CAbstract") );
63 
64  Handle<Builder> cconcrete1_builder(cabstract_factory->get_child( "cf3.common.CConcrete1" ));
65  BOOST_CHECK( cconcrete1_builder != nullptr );
66  BOOST_CHECK_EQUAL( cconcrete1_builder->builder_concrete_type_name() , std::string("CConcrete1") );
67 }
68 
70 
71 BOOST_AUTO_TEST_CASE( LibraryName )
72 {
73  const std::string builder_name1 = "cf3.mesh.neu.Reader";
74  BOOST_CHECK_EQUAL(Builder::extract_library_name(builder_name1), "coolfluid_mesh_neu");
75 
76  const std::string builder_name2 = "cf3.UFEM.Test";
77  BOOST_CHECK_EQUAL(Builder::extract_library_name(builder_name2), "coolfluid_ufem");
78 }
79 
81 
82 BOOST_AUTO_TEST_SUITE_END()
83 
84 
boost::python::object get_child(ComponentWrapper &self, const std::string &name)
BOOST_AUTO_TEST_CASE(get_factory)
Safe pointer to an object. This is the supported method for referring to components.
Definition: Handle.hpp:39
external boost library namespace
Helper class to create the Builder and place it in the factory.
Definition: Builder.hpp:212
STL namespace.
tuple root
Definition: coolfluid.py:24
~FactoryFixture()
common tear-down for each test case
Top-level namespace for coolfluid.
Definition: Action.cpp:18
Handle< FactoryT< CBase > > get_factory()
Definition: Factories.hpp:39
FactoryFixture()
common setup for each test case
Most basic kernel library.
Definition: Action.cpp:19
Send comments to:
COOLFluiD Web Admin