LCOV - code coverage report
Current view: top level - tests/module - module_test.cpp (source / functions) Hit Total Coverage
Test: wfc-coverage.info Lines: 25 27 92.6 %
Date: 2019-09-17 Functions: 29 78 37.2 %

          Line data    Source code
       1             : #define IOW_DISABLE_LOG
       2             : #include <iow/logger.hpp>
       3             : #include <wfc/domain_object.hpp>
       4             : #include <wfc/module/instance.hpp>
       5             : #include <wfc/module/singleton.hpp>
       6             : #include <wfc/module/package.hpp>
       7             : #include <wfc/module/component_list.hpp>
       8             : #include <wfc/module/module_list.hpp>
       9             : #include <wfc/json.hpp>
      10             : 
      11             : template<typename Name, bool Singleton>
      12             : struct helper
      13             : {
      14           8 :   struct options
      15             :   {
      16             :     std::string value;
      17             :     int test = 33;
      18             :     
      19           8 :     options()
      20           8 :       : value( Name()() )
      21           8 :       {}
      22             :   };
      23             :   
      24           2 :   struct itest: 
      25             :     public wfc::iinterface
      26             :   {
      27           0 :     ~itest(){}
      28             :     virtual void doit() = 0;
      29             :   };
      30             :   
      31             :   
      32             :   struct options_json
      33             :   {
      34           2 :     JSON_NAME(test)
      35             :     JSON_NAME(value)
      36             :     typedef wfc::json::object<
      37             :       options,
      38             :       typename fas::type_list_n<
      39             :         wfc::json::member<n_test, options, int, &options::test>
      40             :       >::type
      41             :     > type;
      42             : 
      43             :     typedef typename type::member_list member_list;
      44             :     typedef typename type::target target;
      45             :     typedef typename type::serializer serializer;
      46             : 
      47             :   };
      48             : 
      49           0 :   class test:
      50             :     public wfc::domain_object<itest, options>
      51             :   {
      52             :   public:
      53             :     int doit_count = 0;
      54           2 :     virtual void doit()  override
      55             :     {
      56           2 :       ++doit_count;
      57           2 :     }
      58             :     
      59           2 :     test() {  this->doit();  } //cppcheck
      60             :   };
      61             :   
      62           4 :   class object: public ::wfc::basic_component< Name, wfc::instance<test>, options_json, Singleton, wfc::nostat_json > {};
      63             : };
      64             : 
      65             : 
      66             : JSON_NAME(package1)
      67           1 : JSON_NAME(module1)
      68           8 : JSON_NAME(object1)
      69           8 : JSON_NAME(object2)
      70           1 : JSON_NAME(object3)
      71           1 : JSON_NAME(object4)
      72             : 
      73           1 : class test_module: public ::wfc::component_list<
      74             :     n_module1,
      75             :     helper<n_object1, true>::object,
      76             :     helper<n_object2, true>::object,
      77             :     helper<n_object3, false>::object,
      78             :     helper<n_object4, false>::object
      79             :   >
      80             : {
      81             : };
      82             : 
      83           2 : class test_package: public wfc::module_list< wfc::build_info< wfc::empty_build_info>, test_module> {};
      84             : 
      85           1 : int main()
      86             : {
      87           1 :   auto t = std::make_shared<wfc::package>( std::make_shared<test_package>() ) ;
      88           2 :   iow::asio::io_service io;
      89           2 :   auto g = std::make_shared< wfc::wfcglobal>(io);
      90           1 :   t->create(g);
      91           2 :   std::cout << g->registry.size() << std::endl;
      92           4 : }

Generated by: LCOV version 1.10