11 #define BOOST_TEST_MODULE ( MultipleChoiceSelection_test ) 12 #include <boost/test/unit_test.hpp> 30 { Color::black,
"black" },
34 BOOST_TEST(
options.size() == 2U);
37 options.addAlias(Color::white,
"blanche"),
38 OptionSelector_t::UnknownOptionError
41 auto const& opWhite0 =
options.addOption(Color::white,
"white");
42 auto const& opWhite0again =
options.addAlias(Color::white,
"blanche");
43 BOOST_TEST(&opWhite0again == &opWhite0);
44 BOOST_TEST(
options.size() == 3U);
48 BOOST_TEST(
options.hasOption(Color::white));
51 BOOST_TEST(
options.hasOption(
"white"));
52 BOOST_TEST(
options.hasOption(
"blanche"));
53 BOOST_TEST(
options.hasOption(
"wHite"));
54 BOOST_TEST(!
options.hasOption(
"blue"));
59 BOOST_TEST(
options.hasOption(opWhite0));
61 auto const opWhite1 =
options.parse(
"white");
62 static_assert(std::is_same_v
63 <std::decay_t<decltype(opWhite1)>, OptionSelector_t::Option_t>
65 BOOST_TEST((opWhite1 == Color::white));
66 BOOST_TEST(opWhite1 ==
"white");
67 BOOST_TEST(opWhite1 == opWhite0);
69 auto const opWhite2 =
options.parse(
"blanche");
70 static_assert(std::is_same_v
71 <std::decay_t<decltype(opWhite2)>, OptionSelector_t::Option_t>
73 BOOST_TEST((opWhite2 == Color::white));
74 BOOST_TEST(opWhite2 ==
"white");
75 BOOST_TEST(opWhite2 ==
"blanche");
76 BOOST_TEST(opWhite2 ==
"Blanche");
77 BOOST_TEST(opWhite2 == opWhite0);
79 auto const opWhite3 =
options.get(
"white");
80 static_assert(std::is_same_v
81 <std::decay_t<decltype(opWhite1)>, OptionSelector_t::Option_t>
83 BOOST_TEST(opWhite3 ==
"white");
88 auto const opGray0 =
options.get(
"gray");
89 static_assert(std::is_same_v
90 <std::decay_t<decltype(opWhite1)>, OptionSelector_t::Option_t>
92 BOOST_TEST(opWhite0 ==
"white");
94 auto const opGray1 =
options.parse(
"gray");
95 static_assert(std::is_same_v
96 <std::decay_t<decltype(opWhite1)>, OptionSelector_t::Option_t>
99 BOOST_TEST(opGray1 ==
"gray");
100 BOOST_TEST(opGray1 ==
"grey");
101 BOOST_TEST(opGray1 == opGray0);
109 BOOST_CHECK_THROW(
options.get(
"blue"), OptionSelector_t::UnknownOptionError);
111 (
options.parse(
"blue"), OptionSelector_t::UnknownOptionError);
Helper to select an string option among a set of allowed choices.
BOOST_AUTO_TEST_CASE(MultipleChoiceSelection_testcase)
std::size_t color(std::string const &procname)
void MultipleChoiceSelection_test()
Helper to select one among multiple choices via strings.
QTextStream & endl(QTextStream &s)