mirror of
https://github.com/CLIUtils/CLI11.git
synced 2025-04-28 19:53:52 +00:00
* work on the flags book chapter and making sure the values are initialized properly. * Fix initialization of values used in flags or options * update some formatting and more brace initialization * update more formatting and fix a incorrect initializer * more formatting and some error fixes * more formatting * Small formatting fix Co-authored-by: Henry Schreiner <HenrySchreinerIII@gmail.com>
31 lines
1.0 KiB
C++
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, public ::testing::WithParamInterface<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_CASE_P(TrueBoolOptions, 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, public ::testing::WithParamInterface<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_CASE_P(FalseBoolOptions, TApp_FBO, ::testing::Values("false", "off", "False", "OFF"), );
|