<commit_before>#if HAVE_CMATH
#   include <cmath>
#else
#   include <math.h>
#endif

#include <cppunit/TestAssert.h>


CPPUNIT_NS_BEGIN


void 
assertDoubleEquals( double expected,
                    double actual,
                    double delta,
                    SourceLine sourceLine,
                    const std::string &message )
{
  AdditionalMessage msg( "Delta   : " + 
                         assertion_traits<double>::toString(delta) );
  msg.addDetail( AdditionalMessage(message) );

  Asserter::failNotEqualIf( fabs( expected - actual ) > delta,
                            assertion_traits<double>::toString(expected),
                            assertion_traits<double>::toString(actual),
                            sourceLine, 
                            msg, 
                            "double equality assertion failed" );
}


CPPUNIT_NS_END<commit_msg>Account for non-finite values in assertDoubleEquals().<commit_after>#include <cppunit/TestAssert.h>

#include <math.h>

#if !defined(CPPUNIT_HAVE_ISFINITE)

    static inline bool isfinite( double x )
    {
#if defined(CPPUNIT_HAVE_FINITE)
	return finite( x );
#else
        return ( x * 0.0 ) == 0.0;
#endif
    }

#endif

CPPUNIT_NS_BEGIN


void 
assertDoubleEquals( double expected,
                    double actual,
                    double delta,
                    SourceLine sourceLine,
                    const std::string &message )
{
  AdditionalMessage msg( "Delta   : " + 
                         assertion_traits<double>::toString(delta) );
  msg.addDetail( AdditionalMessage(message) );

  bool equal;
  if ( isfinite(expected) && isfinite(actual) )
      equal = fabs( expected - actual ) <= delta;
  else
      equal = expected == actual;

  Asserter::failNotEqualIf( !equal,
                            assertion_traits<double>::toString(expected),
                            assertion_traits<double>::toString(actual),
                            sourceLine, 
                            msg, 
                            "double equality assertion failed" );
}


CPPUNIT_NS_END
{'fraction_non_alphanumeric': 0.09204218600191755, 'fraction_numerical': 0.0019175455417066154, 'mean_word_length': 1.7938420348058903, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4595698', 'n_tokens_mistral': 579, 'n_tokens_neox': 537, 'n_words': 117}