From cb4335e59fbeec397a0143c313161d8a12f38ac7 Mon Sep 17 00:00:00 2001 From: Dennis Klein Date: Fri, 5 Mar 2021 01:24:42 +0100 Subject: [PATCH] Add test coverage for --channel-config name selector --- test/CMakeLists.txt | 1 + test/properties/_suboptparser.cxx | 36 +++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 test/properties/_suboptparser.cxx diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 0b12f3ec..d0adae70 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -217,6 +217,7 @@ add_testsuite(Properties SOURCES ${CMAKE_CURRENT_BINARY_DIR}/runner.cxx properties/_properties.cxx + properties/_suboptparser.cxx LINKS FairMQ INCLUDES ${CMAKE_CURRENT_SOURCE_DIR} diff --git a/test/properties/_suboptparser.cxx b/test/properties/_suboptparser.cxx new file mode 100644 index 00000000..423bf077 --- /dev/null +++ b/test/properties/_suboptparser.cxx @@ -0,0 +1,36 @@ +/******************************************************************************** + * Copyright (C) 2021 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * * + * This software is distributed under the terms of the * + * GNU Lesser General Public Licence (LGPL) version 3, * + * copied verbatim in the file "LICENSE" * + ********************************************************************************/ + +#include +#include +#include +#include +#include + +namespace { + +using namespace std; +using namespace fair::mq; + +auto contains(Properties const& parsed, string_view key, string_view value) -> bool +{ + return PropertyHelper::ConvertPropertyToString(parsed.at(string(key))) == value; +} + +TEST(SuboptParser, ChannelNameSelector) +{ + Properties parsed(SuboptParser({"name=foo-data,address=tcp://0.0.0.0:6000,type=push", + "bar-data:address=tcp://0.0.0.0:7000,type=pull"}, + "foo")); + ASSERT_TRUE(contains(parsed, "chans.foo-data.0.address", "tcp://0.0.0.0:6000")); + ASSERT_TRUE(contains(parsed, "chans.foo-data.0.type", "push")); + ASSERT_TRUE(contains(parsed, "chans.bar-data.0.address", "tcp://0.0.0.0:7000")); + ASSERT_TRUE(contains(parsed, "chans.bar-data.0.type", "pull")); +} + +} // namespace