Namespaces | |
| vir | |
Classes | |
| struct | smash::Test::Position |
| A FourVector that is marked as a position vector. More... | |
| struct | smash::Test::Momentum |
| A FourVector that is marked as a momentum vector. More... | |
Macros | |
| #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... | |
Typedefs | |
| using | smash::Test::ParticlesPtr = std::unique_ptr< Particles > |
| A type alias for a unique_ptr of Particles. More... | |
Functions | |
| 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... | |
| 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... | |
| Configuration | smash::Test::configuration (std::string overrides={}) |
| Return a configuration object filled with data from src/config.yaml. More... | |
| std::unique_ptr< ExperimentBase > | smash::Test::experiment (const Configuration &c=configuration()) |
| Create an experiment. More... | |
| std::unique_ptr< ExperimentBase > | smash::Test::experiment (const char *configOverrides) |
Creates an experiment using the default config and the specified configOverrides. 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... | |
| ExperimentParameters | smash::Test::default_parameters (int testparticles=1, double dt=0.1) |
| Creates a standard ExperimentParameters object which works for almost all testing purposes. More... | |
Variables | |
| static constexpr double | smash::Test::smashon_mass = 0.123 |
| The mass of the smashon particle. More... | |
| static constexpr double | smash::Test::smashon_width = 1.2 |
| The decay width of the smashon particle. More... | |
| static constexpr const char | smash::Test::smashon_pdg_string [] = "661" |
| The PDG code of the smashon particle. More... | |
| #define TEST | ( | function_name | ) |
Defines a test function.
Consider this to expand to void function_name(). The function_name will also be the name that appears in the output after PASS/FAIL.
Definition at line 229 of file unittest.h.
| #define TEST_CATCH | ( | function_name, | |
| ExceptionType | |||
| ) |
Same as above, but expects the code to throw an exception of type ExceptionType.
If the code does not throw (or throws a different exception), the test is considered failed.
Definition at line 238 of file unittest.h.
| #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.
Definition at line 244 of file unittest.h.
| #define VERIFY | ( | condition | ) |
Verifies that condition is true.
Definition at line 249 of file unittest.h.
| #define COMPARE | ( | test_value, | |
| reference | |||
| ) |
Verifies that test_value is equal to reference.
Definition at line 254 of file unittest.h.
| #define COMPARE_ABSOLUTE_ERROR | ( | test_value, | |
| reference, | |||
| allowed_difference | |||
| ) |
Verifies that the difference between test_value and reference is smaller than allowed_difference.
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.
Definition at line 264 of file unittest.h.
| #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:
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 283 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:
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 1FUZZY_COMPARE(1., 1.00000011920928955078125) will show a distance of -1The value 0.999999940395355224609375 with binary representation 0x3f7fffff has a smaller exponent than 1.:
FUZZY_COMPARE(0.999999940395355224609375, 1.) will show a distance of -0.5FUZZY_COMPARE(1., 0.999999940395355224609375) will show a distance of 1Distance to 0 is implemented as comparing to std::numeric_limits<T>::min() instead and adding 1 to the resulting distance.
Definition at line 332 of file unittest.h.
| #define FAIL | ( | ) |
Call this to fail a test.
Definition at line 337 of file unittest.h.
| using smash::Test::ParticlesPtr = typedef std::unique_ptr<Particles> |
|
inline |
Creates the ParticleType list containing the actual particles that SMASH uses.
Definition at line 35 of file setup.h.
|
inline |
Creates the DecayModes list containing the actual decay modes that SMASH uses.
Definition at line 47 of file setup.h.
|
inline |
Creates a ParticleType list containing only the smashon test particle.
Definition at line 65 of file setup.h.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Return a configuration object filled with data from src/config.yaml.
Note that a change to that file may affect test results if you use it.
If you want specific values in the config for testing simply overwrite the relevant settings e.g. with:
Definition at line 161 of file setup.h.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Creates a standard ExperimentParameters object which works for almost all testing purposes.
If needed you can set the testparticles parameter to a different value than 1.
Definition at line 242 of file setup.h.
|
staticconstexpr |
|
staticconstexpr |