1
0
mirror of https://github.com/CLIUtils/CLI11.git synced 2025-04-29 20:23:55 +00:00
CLI11/tests/TrueFalseTest.cpp
Henry Schreiner c9123811d1
CLI::IsMember (#222)
* Adding first draft of Sets

Use IsMember now

Using IsMember as backend for Set

Non-const validator backend

Move set tests to set

Clearer inits

* Drop shortcut

Tighten up classes a bit for MSVC

Check with GCC 4.8 too

* Simpler templates, but more of them

Dropping more type safety for older compilers

Shortcut string set

* Adding shortcut init

Making g++ 4.7 docker image happy

Fix Clang tidy issue with last commit

Adding one more shortcut, adding a couple of tests

* Dropping dual pointer versions of code

* Smarter shortcut syntax

* Adding slighly faster choices

* Cleanup to make InMember simpler

* Drop choices for now, adding some tests

* ValidationError is now always the error from a validator

* Support for other types of initializer lists, including enums

* Factor out type utilities, single version of IsMember code

* Adding a few tests for #224

* Minor cleanup for Validation Error

* Adding tests, moved deprecated tests

* Docs updates
2019-02-19 09:56:02 +01: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, 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"), );