Skip to content

Commit 7820cb3

Browse files
authored
Merge pull request #5 from jamolnng/ci
CI
2 parents b938894 + c9269c2 commit 7820cb3

3 files changed

Lines changed: 51 additions & 24 deletions

File tree

.travis.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
dist: bionic
2+
sudo: require
3+
language: cpp
4+
compiler: gcc
5+
addons:
6+
apt:
7+
sources:
8+
- ubuntu-toolchain-r-test
9+
packages:
10+
- gcc-6
11+
- g++-6
12+
- cmake-data
13+
- cmake
14+
script:
15+
- sudo ln -s /usr/bin/gcc-6 /usr/local/bin/gcc
16+
- sudo ln -s /usr/bin/g++-6 /usr/local/bin/g++
17+
- gcc -v && g++ -v && cmake --version
18+
- mkdir build && cd build
19+
- cmake ../
20+
- make
21+
- ./tests

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
# argparse
2+
[![Build Status](https://travis-ci.org/jamolnng/argparse.svg?branch=master)](https://travis-ci.org/jamolnng/argparse)
3+
24
A simple header only command line argument parser
35

46
## Usage

tests.cpp

Lines changed: 28 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,14 @@ struct result {
2626
code return {true, 0, "", "", ""}; \
2727
}
2828

29+
TEST(no_args, {
30+
try {
31+
parser.parse(argc, argv);
32+
} catch (const ArgumentParser::ArgumentNotFound& ex) {
33+
TASSERT(false, ex.what())
34+
}
35+
}, )
36+
2937
TEST(short_optional_flag_exists,
3038
{
3139
parser.add_argument("-f", "a flag", false);
@@ -38,17 +46,15 @@ TEST(short_optional_flag_exists,
3846
},
3947
"-f")
4048

41-
TEST(short_optional_flag_does_not_exist,
42-
{
43-
parser.add_argument("-f", "a flag", false);
44-
try {
45-
parser.parse(argc, argv);
46-
} catch (const ArgumentParser::ArgumentNotFound& ex) {
47-
TASSERT(false, ex.what())
48-
}
49-
TASSERT(!parser.exists("f"), "flag found")
50-
},
51-
"")
49+
TEST(short_optional_flag_does_not_exist, {
50+
parser.add_argument("-f", "a flag", false);
51+
try {
52+
parser.parse(argc, argv);
53+
} catch (const ArgumentParser::ArgumentNotFound& ex) {
54+
TASSERT(false, ex.what())
55+
}
56+
TASSERT(!parser.exists("f"), "flag found")
57+
}, )
5258

5359
TEST(short_required_flag_exists,
5460
{
@@ -62,18 +68,16 @@ TEST(short_required_flag_exists,
6268
},
6369
"-f")
6470

65-
TEST(short_required_flag_does_not_exist,
66-
{
67-
parser.add_argument("-f", "a flag", true);
68-
bool failed = false;
69-
try {
70-
parser.parse(argc, argv);
71-
} catch (const ArgumentParser::ArgumentNotFound& ex) {
72-
failed = true;
73-
}
74-
TASSERT(failed, "required flag found")
75-
},
76-
"")
71+
TEST(short_required_flag_does_not_exist, {
72+
parser.add_argument("-f", "a flag", true);
73+
bool failed = false;
74+
try {
75+
parser.parse(argc, argv);
76+
} catch (const ArgumentParser::ArgumentNotFound&) {
77+
failed = true;
78+
}
79+
TASSERT(failed, "required flag found")
80+
}, )
7781

7882
#define TT(name) \
7983
{ #name, name }
@@ -113,5 +117,5 @@ int main(int argc, const char* argv[]) {
113117
}
114118
}
115119
std::cout << "Passed: " << passed << "/" << results.size() << std::endl;
116-
return 0;
120+
return static_cast<int>(results.size() - passed);
117121
}

0 commit comments

Comments
 (0)