-
Notifications
You must be signed in to change notification settings - Fork 260
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of github.com:p-ranav/argparse
- Loading branch information
Showing
5 changed files
with
110 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
matrix: | ||
include: | ||
- os: linux | ||
dist: bionic | ||
language: cpp | ||
compiler: gcc | ||
- os: osx | ||
osx_image: xcode10.2 | ||
language: cpp | ||
compiler: clang | ||
- os: windows | ||
language: bash | ||
env: CXX=cl.exe | ||
install: | ||
- | | ||
if [[ $TRAVIS_OS_NAME == 'windows' ]]; then | ||
choco install ninja cmake | ||
elif [[ $TRAVIS_OS_NAME == 'osx' ]]; then | ||
export PATH=~/Library/Python/3.7/bin:$PATH | ||
pip3 install --user ninja cmake | ||
else | ||
pip install --user ninja cmake | ||
fi | ||
script: | ||
- | | ||
if [[ $TRAVIS_OS_NAME == 'windows' ]]; then | ||
cmd.exe /C '"C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Auxiliary\Build\vcvarsall.bat" amd64 && cmake -Bbuild -G Ninja -DCMAKE_BUILD_TYPE=Release -DARGPARSE_BUILD_TESTS=ON && ninja -C build' | ||
else | ||
cmake -Bbuild -G Ninja -DCMAKE_BUILD_TYPE=Release -DARGPARSE_BUILD_TESTS=ON && ninja -C build | ||
fi | ||
- ./build/test/tests |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#pragma once | ||
#include <catch.hpp> | ||
#include <argparse.hpp> | ||
|
||
TEST_CASE("Parse required arguments which are not set and don't have default value.", "[required_arguments]") { | ||
argparse::ArgumentParser program("test"); | ||
program.add_argument("--output", "-o").required(); | ||
REQUIRE_THROWS(program.parse_args({ "./main" })); | ||
} | ||
|
||
TEST_CASE("Parse required arguments which are set as empty value and don't have default value.", "[required_arguments]") { | ||
argparse::ArgumentParser program("test"); | ||
program.add_argument("--output", "-o").required(); | ||
REQUIRE_THROWS(program.parse_args({ "./main", "-o" })); | ||
} | ||
|
||
TEST_CASE("Parse required arguments which are set as some value and don't have default value.", "[required_arguments]") { | ||
argparse::ArgumentParser program("test"); | ||
program.add_argument("--output", "-o").required(); | ||
program.parse_args({ "./main", "-o", "filename" }); | ||
REQUIRE(program.get("--output") == "filename"); | ||
REQUIRE(program.get("-o") == "filename"); | ||
} | ||
|
||
TEST_CASE("Parse required arguments which are not set and have default value.", "[required_arguments]") { | ||
argparse::ArgumentParser program("test"); | ||
program.add_argument("--output", "-o").required().default_value(std::string("filename")); | ||
program.parse_args({ "./main" }); | ||
REQUIRE(program.get("--output") == "filename"); | ||
REQUIRE(program.get("-o") == "filename"); | ||
} | ||
|
||
TEST_CASE("Parse required arguments which are set as empty and have default value.", "[required_arguments]") { | ||
argparse::ArgumentParser program("test"); | ||
program.add_argument("--output", "-o").required().default_value(std::string("filename")); | ||
REQUIRE_THROWS(program.parse_args({ "./main", "-o" })); | ||
} | ||
|
||
TEST_CASE("Parse required arguments which are set as some value and have default value.", "[required_arguments]") { | ||
argparse::ArgumentParser program("test"); | ||
program.add_argument("--output", "-o").required().default_value(std::string("filename")); | ||
program.parse_args({ "./main", "-o", "anotherfile" }); | ||
REQUIRE(program.get("--output") == "anotherfile"); | ||
REQUIRE(program.get("-o") == "anotherfile"); | ||
} |