Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix DLL visibility of count_digits<4>(internal::uintptr_t) in format-inl.h #1147

Merged
merged 10 commits into from
May 7, 2019
Merged
4 changes: 4 additions & 0 deletions test/custom-formatter-test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
//
// For the license information refer to format.h.

#ifndef _CRT_SECURE_NO_WARNINGS
# define _CRT_SECURE_NO_WARNINGS
#endif

#include "fmt/format.h"
#include "gtest-extra.h"

Expand Down
16 changes: 16 additions & 0 deletions test/format-impl-test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -237,3 +237,19 @@ TEST(FormatTest, FormatErrorCode) {
TEST(FormatTest, CountCodePoints) {
EXPECT_EQ(4, fmt::internal::count_code_points(fmt::u8string_view("ёжик")));
}

// Tests fmt::internal::count_digits for integer type Int.
template <typename Int> void test_count_digits() {
for (Int i = 0; i < 10; ++i) EXPECT_EQ(1u, fmt::internal::count_digits(i));
for (Int i = 1, n = 1, end = std::numeric_limits<Int>::max() / 10; n <= end;
++i) {
n *= 10;
EXPECT_EQ(i, fmt::internal::count_digits(n - 1));
EXPECT_EQ(i + 1, fmt::internal::count_digits(n));
}
}

TEST(UtilTest, CountDigits) {
test_count_digits<uint32_t>();
test_count_digits<uint64_t>();
}
16 changes: 0 additions & 16 deletions test/format-test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -140,22 +140,6 @@ template <typename Char> struct WriteChecker {
EXPECT_PRED_FORMAT1(WriteChecker<wchar_t>(), value)
} // namespace

// Tests fmt::internal::count_digits for integer type Int.
template <typename Int> void test_count_digits() {
for (Int i = 0; i < 10; ++i) EXPECT_EQ(1u, fmt::internal::count_digits(i));
for (Int i = 1, n = 1, end = std::numeric_limits<Int>::max() / 10; n <= end;
++i) {
n *= 10;
EXPECT_EQ(i, fmt::internal::count_digits(n - 1));
EXPECT_EQ(i + 1, fmt::internal::count_digits(n));
}
}

TEST(UtilTest, CountDigits) {
test_count_digits<uint32_t>();
test_count_digits<uint64_t>();
}

struct uint32_pair {
uint32_t u[2];
};
Expand Down
2 changes: 1 addition & 1 deletion test/posix-mock-test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// For the license information refer to format.h.

// Disable bogus MSVC warnings.
#ifdef _MSC_VER
#ifndef _CRT_SECURE_NO_WARNINGS
# define _CRT_SECURE_NO_WARNINGS
#endif

Expand Down