test_display.cc
Go to the documentation of this file.
00001 #include <boost/test/auto_unit_test.hpp>
00002 #include <boost/test/floating_point_comparison.hpp>
00003 
00004 #include <lang/csupport/standard_types.hh>
00005 
00006 #include <test/testsuite.hh>
00007 #include <typelib/utilmm/configset.hh>
00008 #include <typelib/pluginmanager.hh>
00009 #include <typelib/typemodel.hh>
00010 #include <typelib/registry.hh>
00011 #include <typelib/csvoutput.hh>
00012 using namespace Typelib;
00013 using namespace std;
00014 
00015 #include "test_cimport.1"
00016 
00017 
00018 BOOST_AUTO_TEST_CASE(test_csv)
00019 {
00020     {
00021         Registry registry;
00022         Typelib::CXX::addStandardTypes(registry);
00023 
00024         float    f32  = 0.52;
00025         Type const& type = *registry.get("float");
00026         
00027         ostringstream stream;
00028         stream << csv_header(type, "base");
00029         BOOST_CHECK_EQUAL("base", stream.str());
00030 
00031         stream.str("");
00032         stream << csv(type, &f32);
00033         BOOST_CHECK_CLOSE(0.52f, boost::lexical_cast<float>(stream.str()), 0.00001);
00034     }
00035     
00036     {
00037         // Get the test file into repository
00038         utilmm::config_set config;
00039         auto_ptr<Registry> registry(PluginManager::self()->load("tlb", TEST_DATA_PATH("test_cimport.tlb"), config));
00040 
00041         {
00042             ostringstream stream;
00043             Type const& display_type = *registry->get("/DisplayTest");
00044             stream << csv_header(display_type, "t");
00045             BOOST_CHECK_EQUAL("t.fields[0] t.fields[1] t.fields[2] t.fields[3] t.f t.d t.a.a t.a.b t.a.c t.a.d t.mode", stream.str());
00046         }
00047     }
00048 }
00049 


typelib
Author(s): Sylvain Joyeux/sylvain.joyeux@m4x.org
autogenerated on Sat Jun 8 2019 18:49:22