Skip to content

Commit a14f9a7

Browse files
committed
fixed Args::any()
1 parent 561beac commit a14f9a7

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

kit/args/args.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,8 @@ class Args
6262

6363
bool any(const std::vector<std::string>& v) const {
6464
for(auto&& s: v)
65-
return kit::has(m_Args, s);
65+
if(kit::has(m_Args, s))
66+
return true;
6667
return false;
6768
}
6869
bool has(const std::string& s) const {

tests/args.test.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,16 @@ TEST_CASE("Args","[args]") {
6363
REQUIRE(args.has('c', "cchar"));
6464
}
6565

66+
SECTION("any") {
67+
Args args;
68+
args = Args(vector<string>{"foo", "bar"});
69+
REQUIRE(not args.any({"bin"}));
70+
REQUIRE(not args.any({"bin","baz"}));
71+
REQUIRE(args.any({"bar","bin"}));
72+
REQUIRE(args.any({"bin","bar"}));
73+
REQUIRE(args.any({"foo","bar"}));
74+
}
75+
6676
SECTION("key-value") {
6777
Args args;
6878
REQUIRE_NOTHROW(args = Args(vector<string>{"--foo=bar"}));

0 commit comments

Comments
 (0)