ChimeraTK-DeviceAccess  03.18.00
testAccessModeFlags.cc
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Deutsches Elektronen-Synchrotron DESY, MSK, ChimeraTK Project <chimeratk-support@desy.de>
2 // SPDX-License-Identifier: LGPL-3.0-or-later
3 
4 #define BOOST_TEST_DYN_LINK
5 #define BOOST_TEST_MODULE AccessModeFlagsTest
6 
7 #include "AccessMode.h"
8 #include "Exception.h"
9 
10 #include <boost/test/unit_test.hpp>
11 
12 #include <iostream>
13 
14 namespace ctk = ChimeraTK;
15 
16 BOOST_AUTO_TEST_SUITE(AccessModeFlagsTestSuite)
17 
18 BOOST_AUTO_TEST_CASE(testSerialize) {
19  auto flags = ctk::AccessModeFlags{ctk::AccessMode::wait_for_new_data, ctk::AccessMode::raw};
20  BOOST_CHECK(flags.serialize() == "raw,wait_for_new_data");
21 
22  flags = {};
23  BOOST_CHECK(flags.serialize().empty());
24 }
25 
26 BOOST_AUTO_TEST_CASE(testDeSerialize) {
27  auto flags = ctk::AccessModeFlags::deserialize("wait_for_new_data,raw");
28  BOOST_CHECK(flags.has(ctk::AccessMode::raw) == true);
29  BOOST_CHECK(flags.has(ctk::AccessMode::wait_for_new_data) == true);
30 
31  BOOST_CHECK_THROW(std::ignore = ctk::AccessModeFlags::deserialize("bogus_flag"), ctk::logic_error);
32 }
33 
34 BOOST_AUTO_TEST_SUITE_END()
ChimeraTK::AccessModeFlags::deserialize
static AccessModeFlags deserialize(const std::string &listOfflags)
Get an AcessModeFlags object from a comma seperated list of flag strings.
Definition: AccessMode.cc:87
AccessMode.h
ChimeraTK::AccessModeFlags
Set of AccessMode flags with additional functionality for an easier handling.
Definition: AccessMode.h:48
Exception.h
BOOST_AUTO_TEST_CASE
BOOST_AUTO_TEST_CASE(testSerialize)
Definition: testAccessModeFlags.cc:18
ChimeraTK
Definition: DummyBackend.h:16
ChimeraTK::logic_error
Exception thrown when a logic error has occured.
Definition: Exception.h:51