Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the compile issues with the boost<optional> tests and catch #646

Merged
merged 2 commits into from
Sep 28, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,34 @@ jobs:
submodules: true
- name: Add wget
run: apt-get update && apt-get install -y wget
- name: Setup cmake
- name: Get cmake
uses: jwlawson/[email protected]
- name: Configure
run: cmake -S . -B build -DCLI11_CUDA_TESTS=ON
- name: Build
run: cmake --build build -j2


boost-build:
name: Boost build
runs-on: ubuntu-latest
container: zouzias/boost:1.76.0
steps:
- uses: actions/checkout@v1
with:
submodules: true
- name: Add deps
run: apt-get update && apt-get install make
- name: Get CMake
uses: jwlawson/[email protected]
- name: Configure
run: cmake -S . -B build -DCLI11_BOOST=ON
- name: Build
run: cmake --build build -j2
- name: Run tests
run: ctest --output-on-failure
working-directory: build

cmake-config:
name: CMake config check
runs-on: ubuntu-latest
Expand Down
24 changes: 16 additions & 8 deletions tests/OptionalTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -258,11 +258,13 @@ TEST_CASE_METHOD(TApp, "BoostOptionalVector", "[optional]") {
"-v,--vec", [&opt](const std::vector<int> &v) { opt = v; }, "some vector")
->expected(3);
run();
CHECK(!opt);
bool checkOpt = static_cast<bool>(opt);
CHECK(!checkOpt);

args = {"-v", "1", "4", "5"};
run();
CHECK(opt);
checkOpt = static_cast<bool>(opt);
CHECK(checkOpt);
std::vector<int> expV{1, 4, 5};
CHECK(expV == *opt);
}
Expand All @@ -272,14 +274,17 @@ TEST_CASE_METHOD(TApp, "BoostOptionalVectorEmpty", "[optional]") {
app.add_option<decltype(opt), std::vector<int>>("-v,--vec", opt)->expected(0, 3)->allow_extra_args();
// app.add_option("-v,--vec", opt)->expected(0, 3)->allow_extra_args();
run();
CHECK(!opt);
bool checkOpt = static_cast<bool>(opt);
CHECK(!checkOpt);
args = {"-v"};
opt = std::vector<int>{4, 3};
run();
CHECK(!opt);
checkOpt = static_cast<bool>(opt);
CHECK(!checkOpt);
args = {"-v", "1", "4", "5"};
run();
CHECK(opt);
checkOpt = static_cast<bool>(opt);
CHECK(checkOpt);
std::vector<int> expV{1, 4, 5};
CHECK(expV == *opt);
}
Expand All @@ -289,14 +294,17 @@ TEST_CASE_METHOD(TApp, "BoostOptionalVectorEmptyDirect", "[optional]") {
app.add_option_no_stream("-v,--vec", opt)->expected(0, 3)->allow_extra_args();
// app.add_option("-v,--vec", opt)->expected(0, 3)->allow_extra_args();
run();
CHECK(!opt);
bool checkOpt = static_cast<bool>(opt);
CHECK(!checkOpt);
args = {"-v"};
opt = std::vector<int>{4, 3};
run();
CHECK(!opt);
checkOpt = static_cast<bool>(opt);
CHECK(!checkOpt);
args = {"-v", "1", "4", "5"};
run();
CHECK(opt);
checkOpt = static_cast<bool>(opt);
CHECK(checkOpt);
std::vector<int> expV{1, 4, 5};
CHECK(expV == *opt);
}
Expand Down