Changeset 117:5783af72224e in finroc_plugins_data_ports


Ignore:
Timestamp:
17.05.2017 20:28:17 (2 years ago)
Author:
Tobias Föhst <foehst@…>
Branch:
17.03
Phase:
public
Message:

Adds test for port packs

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tests/test_collection.cpp

    r106 r117  
    4444#include "plugins/data_ports/tProxyPort.h" 
    4545#include "plugins/data_ports/tThreadLocalBufferManagement.h" 
     46#include "plugins/data_ports/tPortPack.h" 
    4647 
    4748//---------------------------------------------------------------------- 
     
    372373  RRLIB_UNIT_TESTS_BEGIN_SUITE(DataPortsTestCollection); 
    373374  RRLIB_UNIT_TESTS_ADD_TEST(Test); 
     375  RRLIB_UNIT_TESTS_ADD_TEST(PortPack); 
    374376  RRLIB_UNIT_TESTS_END_SUITE; 
    375377 
     
    398400    TestGenericPorts<bool>(true, false); 
    399401  } 
     402 
     403  void PortPack() 
     404  { 
     405    auto parent = new core::tFrameworkElement(&core::tRuntimeEnvironment::GetInstance(), "TestPortPack"); 
     406 
     407    using tTypeList = rrlib::util::tTypeList<int, double, std::string, bool>; 
     408    data_ports::tPortPack<tInputPort, tTypeList> ports(parent, "X"); 
     409 
     410    RRLIB_UNIT_TESTS_EQUALITY(tTypeList::cSIZE, ports.NumberOfPorts()); 
     411 
     412    for (size_t i = 0; i < tTypeList::cSIZE; ++i) 
     413    { 
     414      RRLIB_UNIT_TESTS_EQUALITY("X" + std::to_string(i + 1), ports.GetPort(i).GetName()); 
     415    } 
     416 
     417    std::array<std::string, tTypeList::cSIZE> names {"foo", "bar", "baz", "fnord"}; 
     418    data_ports::tPortPack<tInputPort, tTypeList> named_ports(parent, names.begin(), names.end()); 
     419 
     420    for (size_t i = 0; i < tTypeList::cSIZE; ++i) 
     421    { 
     422      RRLIB_UNIT_TESTS_EQUALITY(names[i], named_ports.GetPort(i).GetName()); 
     423    } 
     424  } 
    400425}; 
    401426 
Note: See TracChangeset for help on using the changeset viewer.