Skip to content

Commit

Permalink
Add logical_or
Browse files Browse the repository at this point in the history
  • Loading branch information
abedra committed Aug 14, 2021
1 parent c6b9d44 commit ce8a34c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
7 changes: 7 additions & 0 deletions simple_http.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,13 @@ Predicate<A> between_inclusive(const A &a, const A &b) {
};
}

template<class A>
Predicate<A> logical_or(const A &a, const A &b) {
return [a, b](const A &other) {
return other == a || other == b;
};
}

// Information Responses
inline static HttpStatusCode CONTINUE = HttpStatusCode{100};
inline static HttpStatusCode SWITCHING_PROTOCOL = HttpStatusCode{101};
Expand Down
11 changes: 11 additions & 0 deletions test/unit_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,17 @@ TEST_CASE("Predicates")
CHECK(!subject(11));
}

SECTION("logical_or")
{
SimpleHttp::Predicate<int> subject = SimpleHttp::logical_or(1, 2);

CHECK(subject(1));
CHECK(subject(2));
CHECK(!subject(3));
CHECK(!subject(-1));
CHECK(!subject(-2));
}

SECTION("informational")
{
SimpleHttp::Predicate<SimpleHttp::HttpStatusCode> informational = SimpleHttp::informational();
Expand Down

0 comments on commit ce8a34c

Please sign in to comment.