#include #include #include #include #include Void::Testing::Test lt_le_gt_ge_match_appropriately() { using namespace Void::TestingMock; MockFunction fn{"f"}; fn.expect(Lt(10)).returns(1).times(1); fn.expect(Le(20)).returns(2).times(1); fn.expect(Gt(30)).returns(3).times(1); fn.expect(Ge(40)).returns(4).times(1); Void::Testing::expect_eq(fn(5), 1); Void::Testing::expect_eq(fn(15), 2); Void::Testing::expect_eq(fn(35), 3); Void::Testing::expect_eq(fn(40), 4); } Void::Testing::Test range_matches_inclusive_bounds() { using namespace Void::TestingMock; MockFunction fn{"in_range"}; fn.expect(Range(10, 20)).returns(99).times(3); Void::Testing::expect_eq(fn(10), 99); // lower bound Void::Testing::expect_eq(fn(15), 99); // middle Void::Testing::expect_eq(fn(20), 99); // upper bound } Void::Testing::Test pred_matcher_invokes_user_callable() { using namespace Void::TestingMock; MockFunction fn{"is_even"}; fn.expect(Pred([](const int& v) { return v % 2 == 0; })) .returns(1) .times(2); Void::Testing::expect_eq(fn(4), 1); Void::Testing::expect_eq(fn(8), 1); } Void::Testing::Test starts_with_matches_string_prefix() { using namespace Void::TestingMock; MockFunction fn{"prefix"}; fn.expect(StartsWith("hello")).returns(1).times(2); Void::Testing::expect_eq(fn("hello world"), 1); Void::Testing::expect_eq(fn("hello"), 1); } Void::Testing::Test contains_matches_substring() { using namespace Void::TestingMock; MockFunction fn{"contains"}; fn.expect(Contains("foo")).returns(1).times(2); Void::Testing::expect_eq(fn("a foo b"), 1); Void::Testing::expect_eq(fn("foobar"), 1); }