1
0
mirror of https://github.com/CLIUtils/CLI11.git synced 2025-04-29 20:23:55 +00:00
CLI11/tests/TrueFalseTest.cpp
Philip Top 27da2f952e
Container options (#423)
* Update options.md book chapter and the readme to better reflect current usage and the modifications to the add_options templates.

add support in add_option for wrapper types, such as std::optional, boost::optional or other types with a value_type trait.  Add support for generalized containers beyond vector,  add support for nested tuples and vectors, and complex numbers directly in add_option.  This includes several new type traits and object categories.

Upgrade the google test version to better support templated tests.

add support for vector argument separator `%%`

* update formatting to match recent changes

* Apply suggestions from code review

Co-authored-by: Henry Schreiner <HenrySchreinerIII@gmail.com>
2020-03-22 14:06:34 -04:00

31 lines
1.0 KiB
C++

#include "app_helper.hpp"
/// This allows a set of strings to be run over by a test
struct TApp_TBO : public TApp_base, testing::TestWithParam<const char *> {};
TEST_P(TApp_TBO, TrueBoolOption) {
bool value{false}; // Not used, but set just in case
app.add_option("-b,--bool", value);
args = {"--bool", GetParam()};
run();
EXPECT_EQ(1u, app.count("--bool"));
EXPECT_TRUE(value);
}
// Change to INSTANTIATE_TEST_SUITE_P in GTest master
INSTANTIATE_TEST_SUITE_P(TrueBoolOptions_test, TApp_TBO, testing::Values("true", "on", "True", "ON"));
/// This allows a set of strings to be run over by a test
struct TApp_FBO : public TApp_base, public ::testing::TestWithParam<const char *> {};
TEST_P(TApp_FBO, FalseBoolOptions) {
bool value{true}; // Not used, but set just in case
app.add_option("-b,--bool", value);
args = {"--bool", GetParam()};
run();
EXPECT_EQ(1u, app.count("--bool"));
EXPECT_FALSE(value);
}
INSTANTIATE_TEST_SUITE_P(FalseBoolOptions_test, TApp_FBO, ::testing::Values("false", "off", "False", "OFF"));