Nix
2.36.0
Nix, the purely functional package manager; unstable internal interfaces
Toggle main menu visibility
Loading...
Searching...
No Matches
gtest-with-params.hh
Go to the documentation of this file.
1
#pragma once
2
// SPDX-FileCopyrightText: 2014 Emil Eriksson
3
//
4
// SPDX-License-Identifier: BSD-2-Clause
5
//
6
// The lion's share of this code is copy pasted directly out of RapidCheck
7
// headers, so the copyright is set accordingly.
15
16
#include <gtest/gtest.h>
17
#include <rapidcheck/gtest.h>
18
#include <rapidcheck/gen/Arbitrary.hpp>
19
20
namespace
rc::detail {
21
22
using
MakeTestParams = TestParams (*)();
23
24
template
<
typename
Testable>
25
void
checkGTestWith(Testable && testable, MakeTestParams makeTestParams)
26
{
27
const
auto
testInfo = ::testing::UnitTest::GetInstance()->current_test_info();
28
detail::TestMetadata metadata;
29
metadata.id = std::string(testInfo->test_case_name()) +
"/"
+ std::string(testInfo->name());
30
metadata.description = std::string(testInfo->name());
31
32
const
auto
result = checkTestable(std::forward<Testable>(testable), metadata, makeTestParams());
33
34
if
(result.template is<detail::SuccessResult>()) {
35
const
auto
success = result.template get<detail::SuccessResult>();
36
if
(!success.distribution.empty()) {
37
printResultMessage(result, std::cout);
38
std::cout << std::endl;
39
}
40
}
else
{
41
std::ostringstream ss;
42
printResultMessage(result, ss);
43
throw
std::runtime_error(ss.str());
44
}
45
}
46
}
// namespace rc::detail
47
48
#define RC_GTEST_PROP_WITH_PARAMS(TestCase, Name, MakeParams, ArgList) \
49
void rapidCheck_propImpl_##TestCase##_##Name ArgList; \
50
\
51
TEST(TestCase, Name) \
52
{ \
53
::rc::detail::checkGTestWith(&rapidCheck_propImpl_##TestCase##_##Name, MakeParams); \
54
} \
55
\
56
void rapidCheck_propImpl_##TestCase##_##Name ArgList
libutil-test-support
include
nix
util
tests
gtest-with-params.hh
Generated by
1.18.0