|
#define | TEST(function_name) |
| Defines a test function. More...
|
|
#define | TEST_CATCH(function_name, ExceptionType) |
| Same as above, but expects the code to throw an exception of type ExceptionType . More...
|
|
#define | TEST_TYPES(T, test_name, typelist) |
| Define a test function template, with type parameter T, which is specialized for all types in the typelist . More...
|
|
#define | VERIFY(condition) |
| Verifies that condition is true . More...
|
|
#define | COMPARE(test_value, reference) |
| Verifies that test_value is equal to reference . More...
|
|
#define | COMPARE_ABSOLUTE_ERROR(test_value, reference, allowed_difference) |
| Verifies that the difference between test_value and reference is smaller than allowed_difference . More...
|
|
#define | COMPARE_RELATIVE_ERROR(test_value, reference, allowed_relative_difference) |
| Verifies that the difference between test_value and reference is smaller than allowed_relative_difference * reference . More...
|
|
#define | FUZZY_COMPARE(test_value, reference) |
| Verifies that test_value is equal to reference within a pre-defined distance in units of least precision (ulp). More...
|
|
#define | FAIL() |
| Call this to fail a test. More...
|
|
|
void | smash::Test::create_actual_particletypes () |
| Creates the ParticleType list containing the actual particles that SMASH uses. More...
|
|
void | smash::Test::create_actual_decaymodes () |
| Creates the DecayModes list containing the actual decay modes that SMASH uses. More...
|
|
void | smash::Test::create_smashon_particletypes () |
| Creates a ParticleType list containing only the smashon test particle. More...
|
|
void | smash::Test::create_stable_smashon_particletypes () |
| Creates a ParticleType list containing only the smashon test particle with width 0 (stable). More...
|
|
ParticleData | smash::Test::smashon (int id=-1) |
| Create a particle with 0 position and momentum vectors and optionally a given id . More...
|
|
ParticleData | smash::Test::smashon (const Position &position, int id=-1) |
| Create a particle with 0 momentum vector, the given position , and optionally a given id . More...
|
|
ParticleData | smash::Test::smashon (const Momentum &momentum, int id=-1) |
| Create a particle with 0 position vector, the given momentum , and optionally a given id . More...
|
|
ParticleData | smash::Test::smashon (const Position &position, const Momentum &momentum, int id=-1) |
| Create a particle with the given position and momentum vectors, and optionally a given id . More...
|
|
ParticleData | smash::Test::smashon (const Momentum &momentum, const Position &position, int id=-1) |
| Create a particle with the given position and momentum vectors, and optionally a given id . More...
|
|
ParticleData | smash::Test::smashon_random (int id=-1) |
| Create a particle with random position and momentum vectors and optionally a given id . More...
|
|
std::unique_ptr< ExperimentBase > | smash::Test::experiment (Configuration c) |
| Create an experiment given an input configuration. More...
|
|
template<typename G > |
ParticleList | smash::Test::create_particle_list (std::size_t n, G &&generator) |
| Generate a list of particles from the given generator function. More...
|
|
template<typename G > |
ParticlesPtr | smash::Test::create_particles (int n, G &&generator) |
| Creates a Particles object and fills it with n particles generated by the generator function. More...
|
|
ParticlesPtr | smash::Test::create_particles (const std::initializer_list< ParticleData > &init) |
| Creates a Particles object and fills it with the particles passed as initializer_list to this function. More...
|
|
ReactionsBitSet | smash::Test::all_reactions_included () |
| returns BitSet of 2->2 reactions, where everything is on More...
|
|
MultiParticleReactionsBitSet | smash::Test::no_multiparticle_reactions () |
| returns BitSet for multi-particle reactions, where everything is off More...
|
|
ExperimentParameters | smash::Test::default_parameters (int testparticles=1, double dt=0.1, CollisionCriterion crit=CollisionCriterion::Geometric) |
| Creates a standard ExperimentParameters object which works for almost all testing purposes. More...
|
|
ScatterActionsFinderParameters | smash::Test::default_finder_parameters (double elastic_parameter=10, NNbarTreatment nnbar_treatment=NNbarTreatment::NoAnnihilation, ReactionsBitSet included_2to2=all_reactions_included(), bool strings_switch=true, bool use_AQM=false, bool strings_with_probability=false, TotalCrossSectionStrategy xs_strategy=TotalCrossSectionStrategy::BottomUp) |
| Creates a standard ScatterActionsFinderParameters object which works for almost all testing purposes. More...
|
|
EventInfo | smash::Test::default_event_info (double impact_parameter=0.0, bool empty_event=false) |
| Creates default EventInfo object for testing purposes. More...
|
|
std::unique_ptr< StringProcess > | smash::Test::default_string_process_interface () |
| Creates a default StringProcessInterface object for testing. More...
|
|
#define COMPARE_RELATIVE_ERROR |
( |
|
test_value, |
|
|
|
reference, |
|
|
|
allowed_relative_difference |
|
) |
| |
Verifies that the difference between test_value
and reference
is smaller than allowed_relative_difference * reference
.
If the test fails the output will show the actual difference between test_value
and reference
. If this value is positive test_value
is too large. If it is negative test_value
is too small.
The following example tests that a
is no more than 1% different from b
:
#define COMPARE_ABSOLUTE_ERROR(test_value, reference, allowed_difference)
Verifies that the difference between test_value and reference is smaller than allowed_difference.
- Note
- This test macro still works even if
reference
is set to 0. It will then compare the difference against allowed_relative_difference * <smallest positive normalized value of reference type>
.
Definition at line 288 of file unittest.h.
#define FUZZY_COMPARE |
( |
|
test_value, |
|
|
|
reference |
|
) |
| |
Verifies that test_value
is equal to reference
within a pre-defined distance in units of least precision (ulp).
If the test fails it will print the distance in ulp between test_value
and reference
as well as the maximum allowed distance. Often this difference is not visible in the value because the conversion of a double/float to a string needs to round the value to a sensible length.
The allowed distance can be modified by calling:
vir::test::setFuzzyness<float>(4);
vir::test::setFuzzyness<double>(7);
ulp
Unit of least precision is a unit that is derived from the the least significant bit in the mantissa of a floating-point value. Consider a single-precision number (23 mantissa bits) with exponent \(e\). Then 1 ulp is \(2^{e-23}\). Thus, \(\log_2(u)\) signifies the the number incorrect mantissa bits (with \(u\) the distance in ulp).
If test_value
and reference
have a different exponent the meaning of ulp depends on the variable you look at. The FUZZY_COMPARE code always uses reference
to determine the magnitude of 1 ulp.
Example: The value 1.
is 0x3f800000
in binary. The value 1.00000011920928955078125
with binary representation 0x3f800001
therefore has a distance of 1 ulp. A positive distance means the test_value
is larger than the reference
. A negative distance means the test_value
is smaller than the reference
.
FUZZY_COMPARE(1.00000011920928955078125, 1.)
will show a distance of 1
FUZZY_COMPARE(1., 1.00000011920928955078125)
will show a distance of -1
The value 0.999999940395355224609375
with binary representation 0x3f7fffff
has a smaller exponent than 1.
:
FUZZY_COMPARE(0.999999940395355224609375, 1.)
will show a distance of -0.5
FUZZY_COMPARE(1., 0.999999940395355224609375)
will show a distance of 1
Comparing to 0
Distance to 0 is implemented as comparing to std::numeric_limits<T>::min()
instead and adding 1 to the resulting distance.
Definition at line 337 of file unittest.h.