Skip to content

Commit ce8a34c

Browse files
committed
Add logical_or
1 parent c6b9d44 commit ce8a34c

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

simple_http.hpp

+7
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,13 @@ Predicate<A> between_inclusive(const A &a, const A &b) {
287287
};
288288
}
289289

290+
template<class A>
291+
Predicate<A> logical_or(const A &a, const A &b) {
292+
return [a, b](const A &other) {
293+
return other == a || other == b;
294+
};
295+
}
296+
290297
// Information Responses
291298
inline static HttpStatusCode CONTINUE = HttpStatusCode{100};
292299
inline static HttpStatusCode SWITCHING_PROTOCOL = HttpStatusCode{101};

test/unit_tests.cpp

+11
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,17 @@ TEST_CASE("Predicates")
2222
CHECK(!subject(11));
2323
}
2424

25+
SECTION("logical_or")
26+
{
27+
SimpleHttp::Predicate<int> subject = SimpleHttp::logical_or(1, 2);
28+
29+
CHECK(subject(1));
30+
CHECK(subject(2));
31+
CHECK(!subject(3));
32+
CHECK(!subject(-1));
33+
CHECK(!subject(-2));
34+
}
35+
2536
SECTION("informational")
2637
{
2738
SimpleHttp::Predicate<SimpleHttp::HttpStatusCode> informational = SimpleHttp::informational();

0 commit comments

Comments
 (0)