ProteoWizard
Functions
almost_equal_test.cpp File Reference
#include "Std.hpp"
#include "almost_equal.hpp"
#include "pwiz/utility/misc/unit.hpp"

Go to the source code of this file.

Functions

void test_default_float ()
 
void test_default_double ()
 
void test_multiplier ()
 
void test ()
 
int main (int argc, char *argv[])
 

Function Documentation

◆ test_default_float()

void test_default_float ( )

Definition at line 32 of file almost_equal_test.cpp.

33{
34 float a = 2.0f;
35 a += numeric_limits<float>::epsilon();
36 a *= 10.0f;
37 unit_assert(almost_equal(a, 20.0f));
38}
bool almost_equal(float_type a, float_type b, int multiplier=1)
#define unit_assert(x)
Definition unit.hpp:85

References pwiz::util::almost_equal(), and unit_assert.

Referenced by test().

◆ test_default_double()

void test_default_double ( )

Definition at line 41 of file almost_equal_test.cpp.

42{
43 double a = 2.0;
44 a += numeric_limits<double>::epsilon();
45 a *= 10.0;
46 unit_assert(almost_equal(a, 20.0));
47}

References pwiz::util::almost_equal(), and unit_assert.

Referenced by test().

◆ test_multiplier()

void test_multiplier ( )

Definition at line 50 of file almost_equal_test.cpp.

51{
52 float a = 1.0f;
53 a += numeric_limits<float>::epsilon() * 2;
54 a *= 10.0f;
55 unit_assert(!almost_equal(a, 10.0f));
56 unit_assert(almost_equal(a, 10.0f, 2));
57}

References pwiz::util::almost_equal(), and unit_assert.

Referenced by test().

◆ test()

void test ( )

Definition at line 60 of file almost_equal_test.cpp.

61{
65}
void test_multiplier()
void test_default_float()
void test_default_double()

References test_default_double(), test_default_float(), and test_multiplier().

Referenced by main().

◆ main()

int main ( int  argc,
char *  argv[] 
)

Definition at line 68 of file almost_equal_test.cpp.

69{
70 TEST_PROLOG(argc, argv)
71
72 try
73 {
74 test();
75 }
76 catch (exception& e)
77 {
78 TEST_FAILED(e.what())
79 }
80 catch (...)
81 {
82 TEST_FAILED("Caught unknown exception.")
83 }
84
86}
void test()
#define TEST_EPILOG
Definition unit.hpp:183
#define TEST_FAILED(x)
Definition unit.hpp:177
#define TEST_PROLOG(argc, argv)
Definition unit.hpp:175

References test(), TEST_EPILOG, TEST_FAILED, and TEST_PROLOG.