Gromacs  2025-dev-20240614-602a366
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Functions | Variables
testasserts.cpp File Reference
#include "gmxpre.h"
#include "testutils/testasserts.h"
#include <cmath>
#include <cstdio>
#include <limits>
#include <gtest/gtest.h>
#include "gromacs/options/basicoptions.h"
#include "gromacs/options/ioptionscontainer.h"
#include "gromacs/utility/basedefinitions.h"
#include "gromacs/utility/exceptions.h"
#include "gromacs/utility/stringutil.h"
#include "testutils/testoptions.h"
+ Include dependency graph for testasserts.cpp:


Implements floating-point comparison routines from testasserts.h.

Teemu Murtola


void gmx::test::internal::processExpectedException (const std::exception &ex)
 Called for an expected exception from EXPECT_THROW_GMX(). More...
void gmx::test::checkTestNameLength (std::optional< std::string > testName=std::nullopt)
 Gives a GoogleTest assertion if the test's name is too long. More...
Helper functions for computing floating-point differences

These routines are used to initialize FloatingPointDifference. They peek into some internal types from Google Test (gtest-internal.h), and duplicate some other functionality from there, but that is likely a better alternative than just copying all that code here.

template<typename FloatType >
FloatingPoint< FloatType >::Bits gmx::test::anonymous_namespace{testasserts.cpp}::floatingPointToBiasedInteger (const FloatingPoint< FloatType > &value)
 Computes biased integer representation for a floating-point value. More...
template<typename FloatType >
uint64_t gmx::test::anonymous_namespace{testasserts.cpp}::calculateUlpDifference (const FloatingPoint< FloatType > &value1, const FloatingPoint< FloatType > &value2)
 Computes the magnitude of the difference in ULPs between two numbers, treating also values of different sign.
template<typename FloatType >
void gmx::test::anonymous_namespace{testasserts.cpp}::initDifference (FloatType raw1, FloatType raw2, double *absoluteDifference, uint64_t *ulpDifference, bool *bSignDifference)
 Helper to implement the constructors for FloatingPointDifference.
template<typename FloatType >
uint64_t gmx::test::anonymous_namespace{testasserts.cpp}::relativeToleranceToUlp (FloatType tolerance)
 Converts a relative tolerance into an ULP difference.


bool gmx::test::anonymous_namespace{testasserts.cpp}::g_showExpectedExceptions = false
 Whether to print the message from expected exceptions.