Skip to content

Commit

Permalink
Remove more MSVC 2015 workarounds and fix string_view checks
Browse files Browse the repository at this point in the history
  • Loading branch information
vitaut committed Nov 15, 2024
1 parent bfd9539 commit b1a0547
Showing 1 changed file with 11 additions and 18 deletions.
29 changes: 11 additions & 18 deletions test/base-test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -645,9 +645,7 @@ TEST(base_test, is_formattable) {
EXPECT_TRUE(fmt::is_formattable<const const_formattable&>::value);

EXPECT_TRUE(fmt::is_formattable<nonconst_formattable&>::value);
#if !FMT_MSC_VERSION || FMT_MSC_VERSION >= 1910
EXPECT_FALSE(fmt::is_formattable<const nonconst_formattable&>::value);
#endif

EXPECT_FALSE(fmt::is_formattable<convertible_to_pointer>::value);
const auto f = convertible_to_pointer_formattable();
Expand Down Expand Up @@ -745,19 +743,6 @@ TEST(base_test, no_implicit_conversion_to_string_view) {
fmt::is_formattable<implicitly_convertible_to_string_view>::value);
}

#ifdef FMT_USE_STRING_VIEW
struct implicitly_convertible_to_std_string_view {
operator std::string_view() const { return "foo"; }
};

TEST(base_test, no_implicit_conversion_to_std_string_view) {
EXPECT_FALSE(
fmt::is_formattable<implicitly_convertible_to_std_string_view>::value);
}
#endif

// std::is_constructible is broken in MSVC until version 2015.
#if !FMT_MSC_VERSION || FMT_MSC_VERSION >= 1900
struct explicitly_convertible_to_string_view {
explicit operator fmt::string_view() const { return "foo"; }
};
Expand All @@ -769,7 +754,16 @@ TEST(base_test, format_explicitly_convertible_to_string_view) {
!fmt::is_formattable<explicitly_convertible_to_string_view>::value, "");
}

# ifdef FMT_USE_STRING_VIEW
#if FMT_CPLUSPLUS >= 201703L
struct implicitly_convertible_to_std_string_view {
operator std::string_view() const { return "foo"; }
};

TEST(base_test, no_implicit_conversion_to_std_string_view) {
EXPECT_FALSE(
fmt::is_formattable<implicitly_convertible_to_std_string_view>::value);
}

struct explicitly_convertible_to_std_string_view {
explicit operator std::string_view() const { return "foo"; }
};
Expand All @@ -781,8 +775,7 @@ TEST(base_test, format_explicitly_convertible_to_std_string_view) {
!fmt::is_formattable<explicitly_convertible_to_std_string_view>::value,
"");
}
# endif
#endif
#endif // FMT_CPLUSPLUS >= 201703L

TEST(base_test, has_formatter) {
EXPECT_TRUE((fmt::detail::has_formatter<const const_formattable, char>()));
Expand Down

0 comments on commit b1a0547

Please sign in to comment.