Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
testing::gmock_matchers_test::FloatingPointNearTest< RawType > Class Template Reference
Inheritance diagram for testing::gmock_matchers_test::FloatingPointNearTest< RawType >:
Collaboration diagram for testing::gmock_matchers_test::FloatingPointNearTest< RawType >:

Protected Types

typedef FloatingPointTest< RawType > ParentType
 
- Protected Types inherited from testing::gmock_matchers_test::FloatingPointTest< RawType >
typedef testing::internal::FloatingPoint< RawType > Floating
 
typedef Floating::Bits Bits
 

Protected Member Functions

void TestNearMatches (testing::internal::FloatingEqMatcher< RawType >(*matcher_maker)(RawType, RawType))
 
- Protected Member Functions inherited from testing::gmock_matchers_test::FloatingPointTest< RawType >
 FloatingPointTest ()
 
void TestSize ()
 
void TestMatches (testing::internal::FloatingEqMatcher< RawType >(*matcher_maker)(RawType))
 
- Protected Member Functions inherited from testing::Test
 Test ()
 
virtual void SetUp ()
 
virtual void TearDown ()
 

Additional Inherited Members

- Public Types inherited from testing::Test
typedef internal::SetUpTestCaseFunc SetUpTestCaseFunc
 
typedef internal::TearDownTestCaseFunc TearDownTestCaseFunc
 
- Public Member Functions inherited from testing::Test
virtual ~Test ()
 
- Static Public Member Functions inherited from testing::Test
static void SetUpTestCase ()
 
static void TearDownTestCase ()
 
static bool HasFatalFailure ()
 
static bool HasNonfatalFailure ()
 
static bool HasFailure ()
 
static void RecordProperty (const std::string &key, const std::string &value)
 
static void RecordProperty (const std::string &key, int value)
 
- Protected Attributes inherited from testing::gmock_matchers_test::FloatingPointTest< RawType >
const Bits max_ulps_
 
const Bits zero_bits_
 
const Bits one_bits_
 
const Bits infinity_bits_
 
const RawType close_to_positive_zero_
 
const RawType close_to_negative_zero_
 
const RawType further_from_negative_zero_
 
const RawType close_to_one_
 
const RawType further_from_one_
 
const RawType infinity_
 
const RawType close_to_infinity_
 
const RawType further_from_infinity_
 
const RawType max_
 
const RawType nan1_
 
const RawType nan2_
 

Detailed Description

template<typename RawType>
class testing::gmock_matchers_test::FloatingPointNearTest< RawType >

Definition at line 3335 of file gmock-matchers_test.cc.

Member Typedef Documentation

◆ ParentType

template<typename RawType >
FloatingPointTest<RawType> testing::gmock_matchers_test::FloatingPointNearTest< RawType >::ParentType
protected

Definition at line 3337 of file gmock-matchers_test.cc.

Member Function Documentation

◆ TestNearMatches()

template<typename RawType >
void testing::gmock_matchers_test::FloatingPointNearTest< RawType >::TestNearMatches ( testing::internal::FloatingEqMatcher< RawType >(* matcher_maker )(RawType, RawType))
inlineprotected

Definition at line 3341 of file gmock-matchers_test.cc.

3343 {
3344 Matcher<RawType> m1 = matcher_maker(0.0, 0.0);
3345 EXPECT_TRUE(m1.Matches(0.0));
3346 EXPECT_TRUE(m1.Matches(-0.0));
3349 EXPECT_FALSE(m1.Matches(1.0));
3350
3351 Matcher<RawType> m2 = matcher_maker(0.0, 1.0);
3352 EXPECT_TRUE(m2.Matches(0.0));
3353 EXPECT_TRUE(m2.Matches(-0.0));
3354 EXPECT_TRUE(m2.Matches(1.0));
3355 EXPECT_TRUE(m2.Matches(-1.0));
3358
3359 // Check that inf matches inf, regardless of the of the specified max
3360 // absolute error.
3361 Matcher<RawType> m3 = matcher_maker(ParentType::infinity_, 0.0);
3364 EXPECT_FALSE(m3.Matches(-ParentType::infinity_));
3365
3366 Matcher<RawType> m4 = matcher_maker(-ParentType::infinity_, 0.0);
3367 EXPECT_TRUE(m4.Matches(-ParentType::infinity_));
3370
3371 // Test various overflow scenarios.
3372 Matcher<RawType> m5 = matcher_maker(ParentType::max_, ParentType::max_);
3373 EXPECT_TRUE(m5.Matches(ParentType::max_));
3374 EXPECT_FALSE(m5.Matches(-ParentType::max_));
3375
3376 Matcher<RawType> m6 = matcher_maker(-ParentType::max_, ParentType::max_);
3377 EXPECT_FALSE(m6.Matches(ParentType::max_));
3378 EXPECT_TRUE(m6.Matches(-ParentType::max_));
3379
3380 Matcher<RawType> m7 = matcher_maker(ParentType::max_, 0);
3381 EXPECT_TRUE(m7.Matches(ParentType::max_));
3382 EXPECT_FALSE(m7.Matches(-ParentType::max_));
3383
3384 Matcher<RawType> m8 = matcher_maker(-ParentType::max_, 0);
3385 EXPECT_FALSE(m8.Matches(ParentType::max_));
3386 EXPECT_TRUE(m8.Matches(-ParentType::max_));
3387
3388 // The difference between max() and -max() normally overflows to infinity,
3389 // but it should still match if the max_abs_error is also infinity.
3390 Matcher<RawType> m9 = matcher_maker(
3392 EXPECT_TRUE(m8.Matches(-ParentType::max_));
3393
3394 // matcher_maker can produce a Matcher<const RawType&>, which is needed in
3395 // some cases.
3396 Matcher<const RawType&> m10 = matcher_maker(0.0, 1.0);
3397 EXPECT_TRUE(m10.Matches(-0.0));
3400
3401 // matcher_maker can produce a Matcher<RawType&>, which is needed in some
3402 // cases.
3403 Matcher<RawType&> m11 = matcher_maker(0.0, 1.0);
3404 RawType x = 0.0;
3405 EXPECT_TRUE(m11.Matches(x));
3406 x = 1.0f;
3407 EXPECT_TRUE(m11.Matches(x));
3408 x = -1.0f;
3409 EXPECT_TRUE(m11.Matches(x));
3410 x = 1.1f;
3411 EXPECT_FALSE(m11.Matches(x));
3412 x = -1.1f;
3413 EXPECT_FALSE(m11.Matches(x));
3414 }
#define EXPECT_TRUE(condition)
Definition gtest.h:1895
#define EXPECT_FALSE(condition)
Definition gtest.h:1898
Here is the call graph for this function:

The documentation for this class was generated from the following file: