Commit d88be8ef authored by Milo Yip's avatar Milo Yip

Fix #905 unable to set writeFlags for PrettyWriter

parent 430e8d4c
......@@ -47,7 +47,7 @@ enum PrettyFormatOptions {
template<typename OutputStream, typename SourceEncoding = UTF8<>, typename TargetEncoding = UTF8<>, typename StackAllocator = CrtAllocator, unsigned writeFlags = kWriteDefaultFlags>
class PrettyWriter : public Writer<OutputStream, SourceEncoding, TargetEncoding, StackAllocator, writeFlags> {
public:
typedef Writer<OutputStream, SourceEncoding, TargetEncoding, StackAllocator> Base;
typedef Writer<OutputStream, SourceEncoding, TargetEncoding, StackAllocator, writeFlags> Base;
typedef typename Base::Ch Ch;
//! Constructor
......
......@@ -258,6 +258,49 @@ TEST(PrettyWriter, InvalidEventSequence) {
}
}
TEST(PrettyWriter, NaN) {
double nan = std::numeric_limits<double>::quiet_NaN();
EXPECT_TRUE(internal::Double(nan).IsNan());
StringBuffer buffer;
{
PrettyWriter<StringBuffer> writer(buffer);
EXPECT_FALSE(writer.Double(nan));
}
{
PrettyWriter<StringBuffer, UTF8<>, UTF8<>, CrtAllocator, kWriteNanAndInfFlag> writer(buffer);
EXPECT_TRUE(writer.Double(nan));
EXPECT_STREQ("NaN", buffer.GetString());
}
GenericStringBuffer<UTF16<> > buffer2;
PrettyWriter<GenericStringBuffer<UTF16<> > > writer2(buffer2);
EXPECT_FALSE(writer2.Double(nan));
}
TEST(PrettyWriter, Inf) {
double inf = std::numeric_limits<double>::infinity();
EXPECT_TRUE(internal::Double(inf).IsInf());
StringBuffer buffer;
{
PrettyWriter<StringBuffer> writer(buffer);
EXPECT_FALSE(writer.Double(inf));
}
{
PrettyWriter<StringBuffer> writer(buffer);
EXPECT_FALSE(writer.Double(-inf));
}
{
PrettyWriter<StringBuffer, UTF8<>, UTF8<>, CrtAllocator, kWriteNanAndInfFlag> writer(buffer);
EXPECT_TRUE(writer.Double(inf));
}
{
PrettyWriter<StringBuffer, UTF8<>, UTF8<>, CrtAllocator, kWriteNanAndInfFlag> writer(buffer);
EXPECT_TRUE(writer.Double(-inf));
}
EXPECT_STREQ("Infinity-Infinity", buffer.GetString());
}
TEST(PrettyWriter, Issue_889) {
char buf[100] = "Hello";
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment