Changeset 112:4756cdcbb205 in finroc_plugins_data_ports


Ignore:
Timestamp:
17.05.2017 20:28:17 (22 months ago)
Author:
Tobias Föhst <foehst@…>
Branch:
14.08
Children:
113:938e71ac0af4, 116:a842f5afb76b
Phase:
public
Message:

Adds test for port packs

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tests/test_collection.cpp

    r68 r112  
    4444#include "plugins/data_ports/tProxyPort.h" 
    4545#include "plugins/data_ports/tThreadLocalBufferManagement.h" 
     46#include "plugins/data_ports/tPortPack.h" 
    4647 
    4748//---------------------------------------------------------------------- 
     
    242243  RRLIB_UNIT_TESTS_BEGIN_SUITE(DataPortsTestCollection); 
    243244  RRLIB_UNIT_TESTS_ADD_TEST(Test); 
     245  RRLIB_UNIT_TESTS_ADD_TEST(PortPack); 
    244246  RRLIB_UNIT_TESTS_END_SUITE; 
    245247 
     
    257259    TestPortListeners<int>(1); 
    258260  } 
     261 
     262  void PortPack() 
     263  { 
     264    auto parent = new core::tFrameworkElement(&core::tRuntimeEnvironment::GetInstance(), "TestPortPack"); 
     265 
     266    using tTypeList = rrlib::util::tTypeList<int, double, std::string, bool>; 
     267    data_ports::tPortPack<tInputPort, tTypeList> ports(parent, "X"); 
     268 
     269    RRLIB_UNIT_TESTS_EQUALITY(tTypeList::cSIZE, ports.NumberOfPorts()); 
     270 
     271    for (size_t i = 0; i < tTypeList::cSIZE; ++i) 
     272    { 
     273      RRLIB_UNIT_TESTS_EQUALITY("X" + std::to_string(i + 1), ports.GetPort(i).GetName()); 
     274    } 
     275 
     276    std::array<std::string, tTypeList::cSIZE> names {"foo", "bar", "baz", "fnord"}; 
     277    data_ports::tPortPack<tInputPort, tTypeList> named_ports(parent, names.begin(), names.end()); 
     278 
     279    for (size_t i = 0; i < tTypeList::cSIZE; ++i) 
     280    { 
     281      RRLIB_UNIT_TESTS_EQUALITY(names[i], named_ports.GetPort(i).GetName()); 
     282    } 
     283  } 
    259284}; 
    260285 
Note: See TracChangeset for help on using the changeset viewer.