Nektar++
Functions
Nektar::RealComparisonUnitTests Namespace Reference

Functions

 BOOST_AUTO_TEST_CASE (TestRealComparisonSmall)
 
 BOOST_AUTO_TEST_CASE (TestRealComparisonNotSmall)
 
 BOOST_AUTO_TEST_CASE (TestRealComparisonSmallCustomTolerance)
 
 BOOST_AUTO_TEST_CASE (TestRealComparisonNotSmallCustomTolerance)
 
 BOOST_AUTO_TEST_CASE (TestRealComparisonZero)
 
 BOOST_AUTO_TEST_CASE (TestRealComparisonZeroNotZero)
 
 BOOST_AUTO_TEST_CASE (TestRealComparisonRealLiteral)
 
 BOOST_AUTO_TEST_CASE (TestRealComparisonLiteral)
 
 BOOST_AUTO_TEST_CASE (TestRealComparisonConstNotConst)
 
 BOOST_AUTO_TEST_CASE (TestRealComparisonNotConstConst)
 
 BOOST_AUTO_TEST_CASE (TestRealComparisonRef)
 

Function Documentation

◆ BOOST_AUTO_TEST_CASE() [1/11]

Nektar::RealComparisonUnitTests::BOOST_AUTO_TEST_CASE ( TestRealComparisonConstNotConst  )

Definition at line 114 of file TestRealComparison.cpp.

115{
116 // This should return false
117 const double ad1 = 0.0;
118 double ad2 = 1.0;
119 BOOST_CHECK(!LibUtilities::IsRealEqual(ad1, ad2));
120}
bool IsRealEqual(T1 &&lhs, T2 &&rhs, const unsigned int factor=NekConstants::kNekFloatCompFact)
compare reals of same type with relative tolerance

References Nektar::LibUtilities::IsRealEqual().

◆ BOOST_AUTO_TEST_CASE() [2/11]

Nektar::RealComparisonUnitTests::BOOST_AUTO_TEST_CASE ( TestRealComparisonLiteral  )

Definition at line 108 of file TestRealComparison.cpp.

109{
110 // Large difference, should return false
111 BOOST_CHECK(!LibUtilities::IsRealEqual(1.00001, 1.000011));
112}

References Nektar::LibUtilities::IsRealEqual().

◆ BOOST_AUTO_TEST_CASE() [3/11]

Nektar::RealComparisonUnitTests::BOOST_AUTO_TEST_CASE ( TestRealComparisonNotConstConst  )

Definition at line 122 of file TestRealComparison.cpp.

123{
124 // This should return false
125 double ad1 = 0.0;
126 const double ad2 = 1.0;
127 BOOST_CHECK(!LibUtilities::IsRealEqual(ad1, ad2));
128}

References Nektar::LibUtilities::IsRealEqual().

◆ BOOST_AUTO_TEST_CASE() [4/11]

Nektar::RealComparisonUnitTests::BOOST_AUTO_TEST_CASE ( TestRealComparisonNotSmall  )

Definition at line 53 of file TestRealComparison.cpp.

54{
55 // "Large" difference, should return false
56 double ad1 = 1.00001;
57 double ad2 = ad1 * (1.0 + 50 * std::numeric_limits<double>::epsilon());
58 BOOST_CHECK(!LibUtilities::IsRealEqual(ad1, ad2));
59
60 double ad3 = 0.00001;
61 double ad4 = ad3 * (1.0 + 50 * std::numeric_limits<double>::epsilon());
62 BOOST_CHECK(!LibUtilities::IsRealEqual(ad3, ad4));
63}

References Nektar::LibUtilities::IsRealEqual().

◆ BOOST_AUTO_TEST_CASE() [5/11]

Nektar::RealComparisonUnitTests::BOOST_AUTO_TEST_CASE ( TestRealComparisonNotSmallCustomTolerance  )

Definition at line 77 of file TestRealComparison.cpp.

78{
79 // "Large" difference, custom tolerance should return true
80 double ad1 = 1.00001;
81 double ad2 = ad1 * (1.0 + 50 * std::numeric_limits<double>::epsilon());
82 BOOST_CHECK(LibUtilities::IsRealEqual(ad1, ad2, 100));
83}

References Nektar::LibUtilities::IsRealEqual().

◆ BOOST_AUTO_TEST_CASE() [6/11]

Nektar::RealComparisonUnitTests::BOOST_AUTO_TEST_CASE ( TestRealComparisonRealLiteral  )

Definition at line 101 of file TestRealComparison.cpp.

102{
103 // Large difference, should return false
104 double ad1 = 1.00001;
105 BOOST_CHECK(!LibUtilities::IsRealEqual(ad1, 1.000011));
106}

References Nektar::LibUtilities::IsRealEqual().

◆ BOOST_AUTO_TEST_CASE() [7/11]

Nektar::RealComparisonUnitTests::BOOST_AUTO_TEST_CASE ( TestRealComparisonRef  )

Definition at line 130 of file TestRealComparison.cpp.

131{
132 // This should return false
133 double ad1 = 0.0;
134 double &adr = ad1;
135 BOOST_CHECK(!LibUtilities::IsRealEqual(adr, 1.0));
136}

References Nektar::LibUtilities::IsRealEqual().

◆ BOOST_AUTO_TEST_CASE() [8/11]

Nektar::RealComparisonUnitTests::BOOST_AUTO_TEST_CASE ( TestRealComparisonSmall  )

Definition at line 41 of file TestRealComparison.cpp.

42{
43 // Small difference, should return true
44 double ad1 = 1.00001;
45 double ad2 = ad1 * (1.0 + 2 * std::numeric_limits<double>::epsilon());
46 BOOST_CHECK(LibUtilities::IsRealEqual(ad1, ad2));
47
48 double ad3 = 0.00001;
49 double ad4 = ad3 * (1.0 + 2 * std::numeric_limits<double>::epsilon());
50 BOOST_CHECK(LibUtilities::IsRealEqual(ad3, ad4));
51}

References Nektar::LibUtilities::IsRealEqual().

◆ BOOST_AUTO_TEST_CASE() [9/11]

Nektar::RealComparisonUnitTests::BOOST_AUTO_TEST_CASE ( TestRealComparisonSmallCustomTolerance  )

Definition at line 65 of file TestRealComparison.cpp.

66{
67 // Small difference, custom tolerance should return true
68 double ad1 = 1.00001;
69 double ad2 = ad1 * (1.0 + std::numeric_limits<double>::epsilon());
70 BOOST_CHECK(LibUtilities::IsRealEqual(ad1, ad2, 1));
71
72 double ad3 = 0.00001;
73 double ad4 = ad3 * (1.0 + std::numeric_limits<double>::epsilon());
74 BOOST_CHECK(LibUtilities::IsRealEqual(ad3, ad4, 1));
75}

References Nektar::LibUtilities::IsRealEqual().

◆ BOOST_AUTO_TEST_CASE() [10/11]

Nektar::RealComparisonUnitTests::BOOST_AUTO_TEST_CASE ( TestRealComparisonZero  )

Definition at line 85 of file TestRealComparison.cpp.

86{
87 // Both zero, dist and ref value will be zero
88 double ad1 = 0.0;
89 double ad2 = 0.0;
90 BOOST_CHECK(LibUtilities::IsRealEqual(ad1, ad2));
91}

References Nektar::LibUtilities::IsRealEqual().

◆ BOOST_AUTO_TEST_CASE() [11/11]

Nektar::RealComparisonUnitTests::BOOST_AUTO_TEST_CASE ( TestRealComparisonZeroNotZero  )

Definition at line 93 of file TestRealComparison.cpp.

94{
95 // This should return false
96 double ad1 = 0.0;
97 double ad2 = 1.0;
98 BOOST_CHECK(!LibUtilities::IsRealEqual(ad1, ad2));
99}

References Nektar::LibUtilities::IsRealEqual().