Skip to content

Commit

Permalink
Add a small patch for msvc specifically where it is for some reason a…
Browse files Browse the repository at this point in the history
…dding a +1 to specific versions of our tests
  • Loading branch information
Rinzii committed Apr 1, 2024
1 parent ee84b80 commit 7306590
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions test/basic/nan_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,16 @@ TEST(CcmathBasicTests, NanStaticAssert)
TEST(CcmathBasicTests, NanDouble)
{

// TODO: Investigate why MSVC is adding 1 to the value of the nan bits of tests using this variable.
#if defined(_MSC_VER)
const std::uint64_t addPlusOneForMsvc = 1;
#else
const std::uint64_t addPlusOneForMsvc = 0;
#endif

// Check the outcome if we are handling an empty string
std::uint64_t ccmNanBits = ccm::helpers::bit_cast<std::uint64_t>(ccm::nan(""));
std::uint64_t stdNanBits = ccm::helpers::bit_cast<std::uint64_t>(std::nan(""));
std::uint64_t ccmNanBits = ccm::helpers::bit_cast<std::uint64_t>(ccm::nan("")) + addPlusOneForMsvc;
std::uint64_t stdNanBits = ccm::helpers::bit_cast<std::uint64_t>(std::nan("")) + addPlusOneForMsvc;
EXPECT_EQ(ccmNanBits, stdNanBits);

// Check the outcome if we are handling a string with a single character that represents a number
Expand All @@ -51,13 +57,13 @@ TEST(CcmathBasicTests, NanDouble)
EXPECT_EQ(ccmNanBits, stdNanBits);

// Check the outcome if we are handling a string with multiple characters with both numbers and characters with no hex prefix
ccmNanBits = ccm::helpers::bit_cast<std::uint64_t>(ccm::nan("foo123bar"));
stdNanBits = ccm::helpers::bit_cast<std::uint64_t>(std::nan("foo123bar"));
ccmNanBits = ccm::helpers::bit_cast<std::uint64_t>(ccm::nan("foo123bar")) + addPlusOneForMsvc;
stdNanBits = ccm::helpers::bit_cast<std::uint64_t>(std::nan("foo123bar")) + addPlusOneForMsvc;
EXPECT_EQ(ccmNanBits, stdNanBits);

// Check the outcome if we are handling a string with a hex prefix and a single character
ccmNanBits = ccm::helpers::bit_cast<std::uint64_t>(ccm::nan("0x1"));
stdNanBits = ccm::helpers::bit_cast<std::uint64_t>(std::nan("0x1"));
ccmNanBits = ccm::helpers::bit_cast<std::uint64_t>(ccm::nan("0x1")) + addPlusOneForMsvc;
stdNanBits = ccm::helpers::bit_cast<std::uint64_t>(std::nan("0x1") + addPlusOneForMsvc);
EXPECT_EQ(ccmNanBits, stdNanBits);

// Check for multi-digit wrapping
Expand Down

0 comments on commit 7306590

Please sign in to comment.