-
Notifications
You must be signed in to change notification settings - Fork 189
Expand file tree
/
Copy pathCreateTests.cpp
More file actions
36 lines (30 loc) · 938 Bytes
/
Copy pathCreateTests.cpp
File metadata and controls
36 lines (30 loc) · 938 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include <catch2/catch.hpp>
#include <rapidcheck/catch.h>
#include "rapidcheck/gen/Create.h"
#include "util/ArbitraryRandom.h"
#include "util/GenUtils.h"
using namespace rc;
using namespace rc::test;
TEST_CASE("gen::just") {
prop("returns value without shrinks regardless of params",
[](const GenParams ¶ms, int value) {
RC_ASSERT(gen::just(value)(params.random, params.size) ==
shrinkable::just(value));
});
}
TEST_CASE("gen::lazy") {
SECTION("does not call callable on creation") {
bool called = false;
const auto gen = gen::lazy([&] {
called = true;
return gen::just(1);
});
REQUIRE_FALSE(called);
}
prop("passes parameters unchanged",
[](const GenParams ¶ms) {
const auto gen = gen::lazy(&genPassedParams);
const auto value = gen(params.random, params.size).value();
RC_ASSERT(value == params);
});
}