Skip to content

Commit

Permalink
avoid assumption in ConvTest that string_view::iterator is pointer
Browse files Browse the repository at this point in the history
Summary: Under MSVC, it may not be a pointer. However, member `data()` always returns a pointer.

Reviewed By: Gownta

Differential Revision: D64643992

fbshipit-source-id: 51204ad1cf874b72c5b276f91b8f9cfef3003c4e
  • Loading branch information
yfeldblum authored and facebook-github-bot committed Oct 23, 2024
1 parent a10f130 commit 3772054
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
3 changes: 1 addition & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1076,8 +1076,7 @@ if (BUILD_TESTS OR BUILD_BENCHMARKS)
# Builds but fails test on constexpr_exp_floating std::exp(471.L)
TEST constexpr_math_test WINDOWS_DISABLED
SOURCES ConstexprMathTest.cpp
TEST conv_test WINDOWS_DISABLED
SOURCES ConvTest.cpp
TEST conv_test SOURCES ConvTest.cpp
TEST cpu_id_test SOURCES CpuIdTest.cpp
TEST demangle_test SOURCES DemangleTest.cpp
TEST deterministic_schedule_test SOURCES DeterministicScheduleTest.cpp
Expand Down
8 changes: 4 additions & 4 deletions folly/test/ConvTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1847,18 +1847,18 @@ TEST(Conv, TryIntToFloat) {
template <class String>
void tryTo() noexcept {
String sp1("1000000000000000000000000000000");
auto rv1 = folly::tryTo<int>(sp1.begin(), sp1.end());
auto rv1 = folly::tryTo<int>(sp1.data(), sp1.data() + sp1.size());
EXPECT_FALSE(rv1.hasValue());
String sp2("4711");
auto rv2 = folly::tryTo<int>(sp2.begin(), sp2.end());
auto rv2 = folly::tryTo<int>(sp2.data(), sp2.data() + sp2.size());
EXPECT_TRUE(rv2.hasValue());
EXPECT_EQ(rv2.value(), 4711);
String sp3("-4711");
auto rv3 = folly::tryTo<int>(sp3.begin(), sp3.end());
auto rv3 = folly::tryTo<int>(sp3.data(), sp3.data() + sp3.size());
EXPECT_TRUE(rv3.hasValue());
EXPECT_EQ(rv3.value(), -4711);
String sp4("4711");
auto rv4 = folly::tryTo<uint16_t>(sp4.begin(), sp4.end());
auto rv4 = folly::tryTo<uint16_t>(sp4.data(), sp4.data() + sp4.size());
EXPECT_TRUE(rv4.hasValue());
EXPECT_EQ(rv4.value(), 4711);
}
Expand Down

0 comments on commit 3772054

Please sign in to comment.