mirror of
https://github.com/fmtlib/fmt.git
synced 2024-11-10 05:10:05 +00:00
Depreate strtod and remove problematic tests
This commit is contained in:
parent
74c1118964
commit
729a44e67d
@ -502,7 +502,7 @@ class locale {
|
||||
|
||||
// Converts string to floating-point number and advances str past the end
|
||||
// of the parsed input.
|
||||
double strtod(const char*& str) const {
|
||||
FMT_DEPRECATED double strtod(const char*& str) const {
|
||||
char* end = nullptr;
|
||||
double result = strtod_l(str, &end, locale_);
|
||||
str = end;
|
||||
|
@ -548,13 +548,4 @@ TEST(file_test, fdopen) {
|
||||
int read_fd = read_end.descriptor();
|
||||
EXPECT_EQ(read_fd, FMT_POSIX(fileno(read_end.fdopen("r").get())));
|
||||
}
|
||||
|
||||
# ifdef FMT_LOCALE
|
||||
TEST(locale_test, strtod) {
|
||||
fmt::locale loc;
|
||||
const char *start = "4.2", *ptr = start;
|
||||
EXPECT_EQ(4.2, loc.strtod(ptr));
|
||||
EXPECT_EQ(start + 3, ptr);
|
||||
}
|
||||
# endif
|
||||
#endif // FMT_USE_FCNTL
|
||||
|
@ -467,9 +467,6 @@ struct locale_mock {
|
||||
MOCK_METHOD3(newlocale, locale_type(int category_mask, const char* locale,
|
||||
locale_type base));
|
||||
MOCK_METHOD1(freelocale, void(locale_type locale));
|
||||
|
||||
MOCK_METHOD3(strtod_l,
|
||||
double(const char* nptr, char** endptr, locale_type locale));
|
||||
} * locale_mock::instance;
|
||||
|
||||
# ifdef _MSC_VER
|
||||
@ -487,10 +484,6 @@ _locale_t _create_locale(int category, const char* locale) {
|
||||
void _free_locale(_locale_t locale) {
|
||||
locale_mock::instance->freelocale(locale);
|
||||
}
|
||||
|
||||
double _strtod_l(const char* nptr, char** endptr, _locale_t locale) {
|
||||
return locale_mock::instance->strtod_l(nptr, endptr, locale);
|
||||
}
|
||||
# ifdef __clang__
|
||||
# pragma clang diagnostic pop
|
||||
# endif
|
||||
@ -516,11 +509,6 @@ FreeLocaleResult freelocale(locale_type locale) FMT_LOCALE_THROW {
|
||||
return FreeLocaleResult();
|
||||
}
|
||||
|
||||
double strtod_l(const char* nptr, char** endptr,
|
||||
locale_type locale) FMT_LOCALE_THROW {
|
||||
return locale_mock::instance->strtod_l(nptr, endptr, locale);
|
||||
}
|
||||
|
||||
# undef FMT_LOCALE_THROW
|
||||
|
||||
# ifndef _WIN32
|
||||
@ -549,18 +537,4 @@ TEST(locale_test, locale) {
|
||||
EXPECT_EQ(impl, loc.get());
|
||||
}
|
||||
|
||||
TEST(locale_test, strtod) {
|
||||
scoped_mock<locale_mock> mock;
|
||||
EXPECT_CALL(mock, newlocale(_, _, _))
|
||||
.WillOnce(Return(reinterpret_cast<locale_type>(42)));
|
||||
EXPECT_CALL(mock, freelocale(_));
|
||||
fmt::locale loc;
|
||||
const char* str = "4.2";
|
||||
char end = 'x';
|
||||
EXPECT_CALL(mock, strtod_l(str, _, loc.get()))
|
||||
.WillOnce(testing::DoAll(testing::SetArgPointee<1>(&end), Return(777)));
|
||||
EXPECT_EQ(777, loc.strtod(str));
|
||||
EXPECT_EQ(&end, str);
|
||||
}
|
||||
|
||||
#endif // FMT_LOCALE
|
||||
|
Loading…
Reference in New Issue
Block a user