Hegel 0.3.5
Property-based testing for C++
Loading...
Searching...
No Matches
hegel Namespace Reference

Main namespace. More...

Namespaces

namespace  generators
 Hegel generators.

Classes

class  Database
 Configure the Hegel database. More...
struct  Settings
 Configuration options for hegel::test(). More...
class  TestCase
 Handle to the currently-executing test case. More...

Enumerations

enum class  Verbosity { Quiet , Normal , Verbose , Debug }
 Verbosity levels. More...
enum class  HealthCheck { FilterTooMuch , TooSlow , TestCasesTooLarge , LargeInitialTestCase }
 Health checks. More...

Functions

void test (const std::function< void(TestCase &)> &test_fn, const Settings &settings={})
 Run a Hegel test.
const char * verbosity_to_string (Verbosity v)
 Convert Verbosity enum to command-line string.
std::vector< HealthCheckall_health_checks ()
 All health checks, suitable for full suppression.

Detailed Description

Main namespace.

Enumeration Type Documentation

◆ HealthCheck

enum class hegel::HealthCheck
strong

Health checks.

Enumerator
FilterTooMuch 

Test filters out too many generated examples.

TooSlow 

Test cases are running too slowly.

TestCasesTooLarge 

Generated test cases are too large.

LargeInitialTestCase 

First generated test case is unusually large.

◆ Verbosity

enum class hegel::Verbosity
strong

Verbosity levels.

Enumerator
Quiet 

Minimal output (used by TUI).

Normal 

Default - standard test output.

Verbose 

More detailed output.

Debug 

Maximum verbosity + request/response logging.

Function Documentation

◆ all_health_checks()

std::vector< HealthCheck > hegel::all_health_checks ( )
inline

All health checks, suitable for full suppression.

Returns
A vector containing every HealthCheck variant.

◆ test()

void hegel::test ( const std::function< void(TestCase &)> & test_fn,
const Settings & settings = {} )

Run a Hegel test.

#include "hegel/hegel.h"
int main() {
namespace gs = hegel::generators;
auto x = tc.draw(gs::integers<int>({.min_value = 0, .max_value =
100})); auto y = tc.draw(gs::integers<int>({.min_value = 0, .max_value =
100}));
// Property: x + y >= x (true for non-negative integers)
if (x + y < x) {
throw std::runtime_error("Addition underflow!");
}
}, {.test_cases = 1000});
return 0;
}
Handle to the currently-executing test case.
Definition test_case.h:34
T draw(const generators::Generator< T > &gen) const
Draw a random value from a generator.
Definition core.h:371
Hegel generators.
Definition core.h:16
void test(const std::function< void(TestCase &)> &test_fn, const Settings &settings={})
Run a Hegel test.
Parameters
test_fnThe test function to run repeatedly. Receives a TestCase which it uses to draw values, make assumptions, and record notes.
settingsConfiguration settings (test count, debug mode, etc.)
Exceptions
std::runtime_errorif any test case fails
See also
Settings for configuration settings

◆ verbosity_to_string()

const char * hegel::verbosity_to_string ( Verbosity v)
inline

Convert Verbosity enum to command-line string.

Parameters
vThe verbosity level
Returns
The string representation for CLI argument