Make copyfmt not throw (#1666)
This commit is contained in:
parent
59fe455f36
commit
8f511fc12f
@ -101,8 +101,8 @@ void format_value(buffer<Char>& buf, const T& value,
|
||||
#if !defined(FMT_STATIC_THOUSANDS_SEPARATOR)
|
||||
if (loc) output.imbue(loc.get<std::locale>());
|
||||
#endif
|
||||
output.exceptions(std::ios_base::failbit | std::ios_base::badbit);
|
||||
output << value;
|
||||
output.exceptions(std::ios_base::failbit | std::ios_base::badbit);
|
||||
buf.resize(buf.size());
|
||||
}
|
||||
|
||||
|
@ -21,9 +21,9 @@ template <> struct formatter<test> : formatter<int> {
|
||||
};
|
||||
} // namespace fmt
|
||||
|
||||
#include "fmt/ostream.h"
|
||||
|
||||
#include <sstream>
|
||||
|
||||
#include "fmt/ostream.h"
|
||||
#include "gmock.h"
|
||||
#include "gtest-extra.h"
|
||||
#include "util.h"
|
||||
@ -269,7 +269,7 @@ std::ostream& operator<<(std::ostream& os,
|
||||
return os << "bar";
|
||||
}
|
||||
|
||||
TEST(FormatterTest, FormatExplicitlyConvertibleToStringLike) {
|
||||
TEST(OStreamTest, FormatExplicitlyConvertibleToStringLike) {
|
||||
EXPECT_EQ("bar", fmt::format("{}", explicitly_convertible_to_string_like()));
|
||||
}
|
||||
|
||||
@ -285,8 +285,20 @@ std::ostream& operator<<(std::ostream& os,
|
||||
return os << "bar";
|
||||
}
|
||||
|
||||
TEST(FormatterTest, FormatExplicitlyConvertibleToStdStringView) {
|
||||
TEST(OStreamTest, FormatExplicitlyConvertibleToStdStringView) {
|
||||
EXPECT_EQ("bar", fmt::format("{}", explicitly_convertible_to_string_like()));
|
||||
}
|
||||
|
||||
#endif // FMT_USE_STRING_VIEW
|
||||
|
||||
struct copyfmt_test {};
|
||||
|
||||
std::ostream& operator<<(std::ostream& os, copyfmt_test) {
|
||||
std::ios ios(nullptr);
|
||||
ios.copyfmt(os);
|
||||
return os << "foo";
|
||||
}
|
||||
|
||||
TEST(OStreamTest, CopyFmt) {
|
||||
EXPECT_EQ("foo", fmt::format("{}", copyfmt_test()));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user