Skip to content

Commit

Permalink
Last attempt at fixing msvc before moving to my windows environment
Browse files Browse the repository at this point in the history
  • Loading branch information
Rinzii committed Apr 1, 2024
1 parent 2b9d1ca commit 3289a0f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 15 deletions.
16 changes: 1 addition & 15 deletions include/ccmath/math/basic/impl/nan_double_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,21 +48,7 @@ namespace ccm::internal
// This is a patch to fix that issue.

// Check that the last character is 1 and no other characters have been provided other than zero.
for (std::size_t i = 0; arg[i] != '\0'; ++i) // NOLINT
{
if (arg[i] != '0')
{
msvc_one_digit_patch = false;
break;
}

if (arg[i] == '1' && arg[i + 1] == '\0')
{
msvc_one_digit_patch = true;
}

msvc_one_digit_patch = false;
}
msvc_one_digit_patch = true;
#endif

if (!has_hex_been_detected)
Expand Down
15 changes: 15 additions & 0 deletions test/basic/nan_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ TEST(CcmathBasicTests, NanDouble)
stdNanBits = ccm::helpers::bit_cast<std::uint64_t>(std::nan("1"));
EXPECT_EQ(ccmNanBits, stdNanBits);

// Check the outcome if we are handling a string with a single character that represents a number
ccmNanBits = ccm::helpers::bit_cast<std::uint64_t>(ccm::nan("2"));
stdNanBits = ccm::helpers::bit_cast<std::uint64_t>(std::nan("2"));
EXPECT_EQ(ccmNanBits, stdNanBits);

// Check the outcome if we are handling a string with a single character that represents a letter
ccmNanBits = ccm::helpers::bit_cast<std::uint64_t>(ccm::nan("a"));
stdNanBits = ccm::helpers::bit_cast<std::uint64_t>(std::nan("a"));
Expand All @@ -65,6 +70,16 @@ TEST(CcmathBasicTests, NanDouble)
stdNanBits = ccm::helpers::bit_cast<std::uint64_t>(std::nan("000000000000000000000000000000000000000000000000000000001"));
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("0x2"));
stdNanBits = ccm::helpers::bit_cast<std::uint64_t>(std::nan("0x2"));
EXPECT_EQ(ccmNanBits, stdNanBits);

// Check for multi-digit wrapping
ccmNanBits = ccm::helpers::bit_cast<std::uint64_t>(ccm::nan("000000000000000000000000000000000000000000000000000000002"));
stdNanBits = ccm::helpers::bit_cast<std::uint64_t>(std::nan("000000000000000000000000000000000000000000000000000000002"));
EXPECT_EQ(ccmNanBits, stdNanBits);


// TODO: Correct these test cases.
/** These currently fail. Likely due to the fact that we are not handling overflow.
Expand Down

0 comments on commit 3289a0f

Please sign in to comment.