-
Notifications
You must be signed in to change notification settings - Fork 365
/
Copy pathTrueFalseTest.cpp
30 lines (26 loc) · 981 Bytes
/
TrueFalseTest.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
// Copyright (c) 2017-2025, University of Cincinnati, developed by Henry Schreiner
// under NSF AWARD 1414736 and by the respective contributors.
// All rights reserved.
//
// SPDX-License-Identifier: BSD-3-Clause
#include "app_helper.hpp"
#include <string>
TEST_CASE_METHOD(TApp, "True Bool Option", "[bool][flag]") {
// Strings needed here due to MSVC 2015.
auto param = GENERATE(as<std::string>{}, "true", "on", "True", "ON");
bool value{false}; // Not used, but set just in case
app.add_option("-b,--bool", value);
args = {"--bool", param};
run();
CHECK(app.count("--bool") == 1u);
CHECK(value);
}
TEST_CASE_METHOD(TApp, "False Bool Option", "[bool][flag]") {
auto param = GENERATE(as<std::string>{}, "false", "off", "False", "OFF");
bool value{true}; // Not used, but set just in case
app.add_option("-b,--bool", value);
args = {"--bool", param};
run();
CHECK(app.count("--bool") == 1u);
CHECK_FALSE(value);
}