332#include "test_case.h"
334#include "generators/builds.h"
335#include "generators/collections.h"
336#include "generators/combinators.h"
337#include "generators/default.h"
338#include "generators/formats.h"
339#include "generators/numeric.h"
340#include "generators/primitives.h"
341#include "generators/random.h"
342#include "generators/stateful.h"
343#include "generators/strings.h"
347#if defined(__GNUC__) || defined(__clang__) || \
348 (defined(_MSC_VER) && _MSC_VER >= 1927)
349#define HEGEL_CALLER_FILE __builtin_FILE()
350#define HEGEL_CALLER_FUNCTION __builtin_FUNCTION()
351#define HEGEL_CALLER_LINE __builtin_LINE()
353#define HEGEL_CALLER_FILE ""
354#define HEGEL_CALLER_FUNCTION ""
355#define HEGEL_CALLER_LINE 0
389 class FailureOrigin {
391 FailureOrigin() =
default;
392 virtual ~FailureOrigin() =
default;
397 FailureOrigin&
operator=(
const FailureOrigin&) =
default;
474 const std::vector<std::string>& failure_blobs = {},
475 const char* caller_file = HEGEL_CALLER_FILE,
476 const char* caller_function = HEGEL_CALLER_FUNCTION,
477 int caller_line = HEGEL_CALLER_LINE);
501 const std::vector<std::string>& failure_blobs = {});
506 struct FrameworkHooks {
508 std::string (*current_test_name)() =
nullptr;
511 void (*run_case)(
const std::function<void()>&) =
nullptr;
517 bool install_framework_hooks(
const FrameworkHooks& hooks);
520 bool register_blob(
const char* name, std::vector<const char*> blobs);
522 std::vector<std::string> reproduce_blobs_for(
const char* name);
525 void test_from_macro(
const std::function<
void(TestCase&)>& test_fn,
526 const TestLocation& location,
527 const Settings& settings,
528 const std::vector<std::string>& failure_blobs);
575#define HEGEL_TEST(name, ...) \
576 static void hegel_test_body_##name(::hegel::TestCase&); \
577 static void name(::hegel::Settings settings = \
578 ::hegel::Settings(__VA_ARGS__)) { \
579 if (!settings.database_key.has_value()) { \
580 settings.database_key = __FILE__ "::" #name; \
582 ::hegel::internal::test_from_macro( \
583 hegel_test_body_##name, \
584 ::hegel::TestLocation{#name, __FILE__, __LINE__}, settings, \
585 ::hegel::internal::reproduce_blobs_for(__FILE__ "::" #name)); \
587 static void hegel_test_body_##name
613#define HEGEL_REPRODUCE_FAILURE(name, blob, ...) \
614 [[maybe_unused]] static const bool hegel_reproduce_registered_##name = \
615 ::hegel::internal::register_blob(__FILE__ "::" #name, \
616 {blob, __VA_ARGS__});
621#if defined(GTEST_TEST)
FailureOrigin(const FailureOrigin &)=default
Copy-constructs. An origin holds no state of its own.
virtual std::string failure_origin() const =0
The origin grouping this failure.
FailureOrigin & operator=(const FailureOrigin &)=default
Handle to the currently-executing test case.
Definition test_case.h:40
Main namespace.
Definition config.h:29
void test(const std::function< void(TestCase &)> &test_fn, const Settings &settings={}, const std::vector< std::string > &failure_blobs={}, const char *caller_file=HEGEL_CALLER_FILE, const char *caller_function=HEGEL_CALLER_FUNCTION, int caller_line=HEGEL_CALLER_LINE)
Run a Hegel test.
Configuration options for hegel::test().
Definition settings.h:198
Where a test is defined.
Definition hegel.h:415
int line
Line the test is defined on.
Definition hegel.h:421
std::string name
Test name, as it appears in the report header.
Definition hegel.h:417
std::string file
Source file the test is defined in.
Definition hegel.h:419