Commit 453eda5f authored by Philipp A. Hartmann's avatar Philipp A. Hartmann

tabs to 4 spaces (following 0dbcc1cf)

parent d84c0515
...@@ -121,25 +121,27 @@ concept Handler { ...@@ -121,25 +121,27 @@ concept Handler {
//! Default implementation of Handler. //! Default implementation of Handler.
/*! This can be used as base class of any reader handler. /*! This can be used as base class of any reader handler.
\note implements Handler concept \note implements Handler concept
*/ */
template<typename Encoding = UTF8<>, typename Derived = void> template<typename Encoding = UTF8<>, typename Derived = void>
struct BaseReaderHandler { struct BaseReaderHandler {
typedef typename Encoding::Ch Ch; typedef typename Encoding::Ch Ch;
bool Default() { return true; } typedef typename internal::SelectIf<internal::IsSame<Derived, void>, BaseReaderHandler, Derived>::Type Override;
bool Null() { return static_cast<Override&>(*this).Default(); }
bool Bool(bool) { return static_cast<Override&>(*this).Default(); } bool Default() { return true; }
bool Int(int) { return static_cast<Override&>(*this).Default(); } bool Null() { return static_cast<Override&>(*this).Default(); }
bool Uint(unsigned) { return static_cast<Override&>(*this).Default(); } bool Bool(bool) { return static_cast<Override&>(*this).Default(); }
bool Int64(int64_t) { return static_cast<Override&>(*this).Default(); } bool Int(int) { return static_cast<Override&>(*this).Default(); }
bool Uint64(uint64_t) { return static_cast<Override&>(*this).Default(); } bool Uint(unsigned) { return static_cast<Override&>(*this).Default(); }
bool Double(double) { return static_cast<Override&>(*this).Default(); } bool Int64(int64_t) { return static_cast<Override&>(*this).Default(); }
bool String(const Ch*, SizeType, bool) { return static_cast<Override&>(*this).Default(); } bool Uint64(uint64_t) { return static_cast<Override&>(*this).Default(); }
bool StartObject() { return static_cast<Override&>(*this).Default(); } bool Double(double) { return static_cast<Override&>(*this).Default(); }
bool EndObject(SizeType) { return static_cast<Override&>(*this).Default(); } bool String(const Ch*, SizeType, bool) { return static_cast<Override&>(*this).Default(); }
bool StartArray() { return static_cast<Override&>(*this).Default(); } bool StartObject() { return static_cast<Override&>(*this).Default(); }
bool EndArray(SizeType) { return static_cast<Override&>(*this).Default(); } bool EndObject(SizeType) { return static_cast<Override&>(*this).Default(); }
bool StartArray() { return static_cast<Override&>(*this).Default(); }
bool EndArray(SizeType) { return static_cast<Override&>(*this).Default(); }
}; };
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
...@@ -382,7 +384,7 @@ public: ...@@ -382,7 +384,7 @@ public:
RAPIDJSON_PARSE_ERROR_EARLY_RETURN(parseResult_); RAPIDJSON_PARSE_ERROR_EARLY_RETURN(parseResult_);
} }
else { else {
ParseValue<parseFlags>(is, handler); ParseValue<parseFlags>(is, handler);
RAPIDJSON_PARSE_ERROR_EARLY_RETURN(parseResult_); RAPIDJSON_PARSE_ERROR_EARLY_RETURN(parseResult_);
if (!(parseFlags & kParseStopWhenDoneFlag)) { if (!(parseFlags & kParseStopWhenDoneFlag)) {
...@@ -904,8 +906,8 @@ private: ...@@ -904,8 +906,8 @@ private:
IterativeParsingElementDelimiterState, IterativeParsingElementDelimiterState,
IterativeParsingArrayFinishState, IterativeParsingArrayFinishState,
// Single value state // Single value state
IterativeParsingValueState, IterativeParsingValueState,
cIterativeParsingStateCount cIterativeParsingStateCount
}; };
...@@ -965,11 +967,11 @@ private: ...@@ -965,11 +967,11 @@ private:
IterativeParsingErrorState, // Right curly bracket IterativeParsingErrorState, // Right curly bracket
IterativeParsingErrorState, // Comma IterativeParsingErrorState, // Comma
IterativeParsingErrorState, // Colon IterativeParsingErrorState, // Colon
IterativeParsingValueState, // String IterativeParsingValueState, // String
IterativeParsingValueState, // False IterativeParsingValueState, // False
IterativeParsingValueState, // True IterativeParsingValueState, // True
IterativeParsingValueState, // Null IterativeParsingValueState, // Null
IterativeParsingValueState // Number IterativeParsingValueState // Number
}, },
// Finish(sink state) // Finish(sink state)
{ {
...@@ -1106,12 +1108,12 @@ private: ...@@ -1106,12 +1108,12 @@ private:
IterativeParsingErrorState, IterativeParsingErrorState, IterativeParsingErrorState, IterativeParsingErrorState, IterativeParsingErrorState, IterativeParsingErrorState, IterativeParsingErrorState, IterativeParsingErrorState, IterativeParsingErrorState, IterativeParsingErrorState,
IterativeParsingErrorState, IterativeParsingErrorState, IterativeParsingErrorState, IterativeParsingErrorState, IterativeParsingErrorState, IterativeParsingErrorState, IterativeParsingErrorState, IterativeParsingErrorState, IterativeParsingErrorState, IterativeParsingErrorState,
IterativeParsingErrorState IterativeParsingErrorState
}, },
// Single Value (sink state) // Single Value (sink state)
{ {
IterativeParsingErrorState, IterativeParsingErrorState, IterativeParsingErrorState, IterativeParsingErrorState, IterativeParsingErrorState, IterativeParsingErrorState, IterativeParsingErrorState, IterativeParsingErrorState, IterativeParsingErrorState, IterativeParsingErrorState,
IterativeParsingErrorState, IterativeParsingErrorState, IterativeParsingErrorState, IterativeParsingErrorState, IterativeParsingErrorState, IterativeParsingErrorState, IterativeParsingErrorState, IterativeParsingErrorState, IterativeParsingErrorState, IterativeParsingErrorState,
IterativeParsingErrorState IterativeParsingErrorState
} }
}; // End of G }; // End of G
...@@ -1248,13 +1250,13 @@ private: ...@@ -1248,13 +1250,13 @@ private:
} }
} }
case IterativeParsingValueState: case IterativeParsingValueState:
// Must be non-compound value. Or it would be ObjectInitial or ArrayInitial state. // Must be non-compound value. Or it would be ObjectInitial or ArrayInitial state.
ParseValue<parseFlags>(is, handler); ParseValue<parseFlags>(is, handler);
if (HasParseError()) { if (HasParseError()) {
return IterativeParsingErrorState; return IterativeParsingErrorState;
} }
return IterativeParsingFinishState; return IterativeParsingFinishState;
default: default:
RAPIDJSON_ASSERT(false); RAPIDJSON_ASSERT(false);
...@@ -1270,7 +1272,7 @@ private: ...@@ -1270,7 +1272,7 @@ private:
} }
switch (src) { switch (src) {
case IterativeParsingStartState: RAPIDJSON_PARSE_ERROR(kParseErrorDocumentEmpty, is.Tell()); case IterativeParsingStartState: RAPIDJSON_PARSE_ERROR(kParseErrorDocumentEmpty, is.Tell());
case IterativeParsingFinishState: RAPIDJSON_PARSE_ERROR(kParseErrorDocumentRootNotSingular, is.Tell()); case IterativeParsingFinishState: RAPIDJSON_PARSE_ERROR(kParseErrorDocumentRootNotSingular, is.Tell());
case IterativeParsingObjectInitialState: case IterativeParsingObjectInitialState:
case IterativeParsingMemberDelimiterState: RAPIDJSON_PARSE_ERROR(kParseErrorObjectMissName, is.Tell()); case IterativeParsingMemberDelimiterState: RAPIDJSON_PARSE_ERROR(kParseErrorObjectMissName, is.Tell());
......
...@@ -46,8 +46,8 @@ TEST(JsonChecker, Reader) { ...@@ -46,8 +46,8 @@ TEST(JsonChecker, Reader) {
// jsonchecker/failXX.json // jsonchecker/failXX.json
for (int i = 1; i <= 33; i++) { for (int i = 1; i <= 33; i++) {
if (i == 1) // fail1.json is valid in rapidjson, which has no limitation on type of root element (RFC 7159). if (i == 1) // fail1.json is valid in rapidjson, which has no limitation on type of root element (RFC 7159).
continue; continue;
if (i == 18) // fail18.json is valid in rapidjson, which has no limitation on depth of nesting. if (i == 18) // fail18.json is valid in rapidjson, which has no limitation on depth of nesting.
continue; continue;
...@@ -59,17 +59,17 @@ TEST(JsonChecker, Reader) { ...@@ -59,17 +59,17 @@ TEST(JsonChecker, Reader) {
json = ReadFile(filename, length); json = ReadFile(filename, length);
if (!json) { if (!json) {
printf("jsonchecker file %s not found", filename); printf("jsonchecker file %s not found", filename);
ADD_FAILURE(); ADD_FAILURE();
continue; continue;
} }
} }
GenericDocument<UTF8<>, CrtAllocator> document; // Use Crt allocator to check exception-safety (no memory leak) GenericDocument<UTF8<>, CrtAllocator> document; // Use Crt allocator to check exception-safety (no memory leak)
document.Parse((const char*)json); document.Parse((const char*)json);
EXPECT_TRUE(document.HasParseError()); EXPECT_TRUE(document.HasParseError());
document.Parse<kParseIterativeFlag>((const char*)json); document.Parse<kParseIterativeFlag>((const char*)json);
EXPECT_TRUE(document.HasParseError()); EXPECT_TRUE(document.HasParseError());
free(json); free(json);
} }
...@@ -90,10 +90,10 @@ TEST(JsonChecker, Reader) { ...@@ -90,10 +90,10 @@ TEST(JsonChecker, Reader) {
GenericDocument<UTF8<>, CrtAllocator> document; // Use Crt allocator to check exception-safety (no memory leak) GenericDocument<UTF8<>, CrtAllocator> document; // Use Crt allocator to check exception-safety (no memory leak)
document.Parse((const char*)json); document.Parse((const char*)json);
EXPECT_FALSE(document.HasParseError()); EXPECT_FALSE(document.HasParseError());
document.Parse<kParseIterativeFlag>((const char*)json); document.Parse<kParseIterativeFlag>((const char*)json);
EXPECT_FALSE(document.HasParseError()); EXPECT_FALSE(document.HasParseError());
free(json); free(json);
} }
......
...@@ -45,7 +45,7 @@ TEST(Reader, ParseTrue) { ...@@ -45,7 +45,7 @@ TEST(Reader, ParseTrue) {
StringStream s("true"); StringStream s("true");
ParseBoolHandler<true> h; ParseBoolHandler<true> h;
Reader reader; Reader reader;
reader.Parse(s, h); reader.Parse(s, h);
EXPECT_EQ(1u, h.step_); EXPECT_EQ(1u, h.step_);
} }
...@@ -53,7 +53,7 @@ TEST(Reader, ParseFalse) { ...@@ -53,7 +53,7 @@ TEST(Reader, ParseFalse) {
StringStream s("false"); StringStream s("false");
ParseBoolHandler<false> h; ParseBoolHandler<false> h;
Reader reader; Reader reader;
reader.Parse(s, h); reader.Parse(s, h);
EXPECT_EQ(1u, h.step_); EXPECT_EQ(1u, h.step_);
} }
...@@ -108,7 +108,7 @@ TEST(Reader, ParseNumberHandler) { ...@@ -108,7 +108,7 @@ TEST(Reader, ParseNumberHandler) {
StringStream s(str); \ StringStream s(str); \
Handler h; \ Handler h; \
Reader reader; \ Reader reader; \
reader.Parse(s, h); \ reader.Parse(s, h); \
EXPECT_EQ(1u, h.step_); \ EXPECT_EQ(1u, h.step_); \
EXPECT_EQ(double(x), h.actual_); \ EXPECT_EQ(double(x), h.actual_); \
} }
...@@ -118,7 +118,7 @@ TEST(Reader, ParseNumberHandler) { ...@@ -118,7 +118,7 @@ TEST(Reader, ParseNumberHandler) {
StringStream s(str); \ StringStream s(str); \
ParseDoubleHandler h; \ ParseDoubleHandler h; \
Reader reader; \ Reader reader; \
reader.Parse(s, h); \ reader.Parse(s, h); \
EXPECT_EQ(1u, h.step_); \ EXPECT_EQ(1u, h.step_); \
EXPECT_DOUBLE_EQ(x, h.actual_); \ EXPECT_DOUBLE_EQ(x, h.actual_); \
} }
...@@ -178,11 +178,11 @@ TEST(Reader, ParseNumber_Error) { ...@@ -178,11 +178,11 @@ TEST(Reader, ParseNumber_Error) {
#define TEST_NUMBER_ERROR(errorCode, str) \ #define TEST_NUMBER_ERROR(errorCode, str) \
{ \ { \
char buffer[1001]; \ char buffer[1001]; \
sprintf(buffer, "%s", str); \ sprintf(buffer, "%s", str); \
InsituStringStream s(buffer); \ InsituStringStream s(buffer); \
BaseReaderHandler<> h; \ BaseReaderHandler<> h; \
Reader reader; \ Reader reader; \
EXPECT_FALSE(reader.Parse(s, h)); \ EXPECT_FALSE(reader.Parse(s, h)); \
EXPECT_EQ(errorCode, reader.GetParseErrorCode());\ EXPECT_EQ(errorCode, reader.GetParseErrorCode());\
} }
...@@ -242,14 +242,14 @@ TEST(Reader, ParseString) { ...@@ -242,14 +242,14 @@ TEST(Reader, ParseString) {
GenericInsituStringStream<Encoding> is(buffer); \ GenericInsituStringStream<Encoding> is(buffer); \
ParseStringHandler<Encoding> h; \ ParseStringHandler<Encoding> h; \
GenericReader<Encoding, Encoding> reader; \ GenericReader<Encoding, Encoding> reader; \
reader.Parse<kParseInsituFlag | kParseValidateEncodingFlag>(is, h); \ reader.Parse<kParseInsituFlag | kParseValidateEncodingFlag>(is, h); \
EXPECT_EQ(0, StrCmp<Encoding::Ch>(e, h.str_)); \ EXPECT_EQ(0, StrCmp<Encoding::Ch>(e, h.str_)); \
EXPECT_EQ(StrLen(e), h.length_); \ EXPECT_EQ(StrLen(e), h.length_); \
free(buffer); \ free(buffer); \
GenericStringStream<Encoding> s(x); \ GenericStringStream<Encoding> s(x); \
ParseStringHandler<Encoding> h2; \ ParseStringHandler<Encoding> h2; \
GenericReader<Encoding, Encoding> reader2; \ GenericReader<Encoding, Encoding> reader2; \
reader2.Parse(s, h2); \ reader2.Parse(s, h2); \
EXPECT_EQ(0, StrCmp<Encoding::Ch>(e, h2.str_)); \ EXPECT_EQ(0, StrCmp<Encoding::Ch>(e, h2.str_)); \
EXPECT_EQ(StrLen(e), h2.length_); \ EXPECT_EQ(StrLen(e), h2.length_); \
} }
...@@ -314,7 +314,7 @@ TEST(Reader, ParseString) { ...@@ -314,7 +314,7 @@ TEST(Reader, ParseString) {
const char e[] = "Hello\0World"; const char e[] = "Hello\0World";
ParseStringHandler<UTF8<> > h; ParseStringHandler<UTF8<> > h;
Reader reader; Reader reader;
reader.Parse(s, h); reader.Parse(s, h);
EXPECT_EQ(0, memcmp(e, h.str_, h.length_ + 1)); EXPECT_EQ(0, memcmp(e, h.str_, h.length_ + 1));
EXPECT_EQ(11u, h.length_); EXPECT_EQ(11u, h.length_);
} }
...@@ -326,7 +326,7 @@ TEST(Reader, ParseString_Transcoding) { ...@@ -326,7 +326,7 @@ TEST(Reader, ParseString_Transcoding) {
GenericStringStream<UTF8<> > is(x); GenericStringStream<UTF8<> > is(x);
GenericReader<UTF8<>, UTF16<> > reader; GenericReader<UTF8<>, UTF16<> > reader;
ParseStringHandler<UTF16<> > h; ParseStringHandler<UTF16<> > h;
reader.Parse(is, h); reader.Parse(is, h);
EXPECT_EQ(0, StrCmp<UTF16<>::Ch>(e, h.str_)); EXPECT_EQ(0, StrCmp<UTF16<>::Ch>(e, h.str_));
EXPECT_EQ(StrLen(e), h.length_); EXPECT_EQ(StrLen(e), h.length_);
} }
...@@ -335,7 +335,7 @@ TEST(Reader, ParseString_NonDestructive) { ...@@ -335,7 +335,7 @@ TEST(Reader, ParseString_NonDestructive) {
StringStream s("\"Hello\\nWorld\""); StringStream s("\"Hello\\nWorld\"");
ParseStringHandler<UTF8<> > h; ParseStringHandler<UTF8<> > h;
Reader reader; Reader reader;
reader.Parse(s, h); reader.Parse(s, h);
EXPECT_EQ(0, StrCmp("Hello\nWorld", h.str_)); EXPECT_EQ(0, StrCmp("Hello\nWorld", h.str_));
EXPECT_EQ(11u, h.length_); EXPECT_EQ(11u, h.length_);
} }
...@@ -447,7 +447,7 @@ TEST(Reader, ParseEmptyArray) { ...@@ -447,7 +447,7 @@ TEST(Reader, ParseEmptyArray) {
InsituStringStream s(json); InsituStringStream s(json);
ParseArrayHandler<0> h; ParseArrayHandler<0> h;
Reader reader; Reader reader;
reader.Parse(s, h); reader.Parse(s, h);
EXPECT_EQ(2u, h.step_); EXPECT_EQ(2u, h.step_);
free(json); free(json);
} }
...@@ -457,7 +457,7 @@ TEST(Reader, ParseArray) { ...@@ -457,7 +457,7 @@ TEST(Reader, ParseArray) {
InsituStringStream s(json); InsituStringStream s(json);
ParseArrayHandler<4> h; ParseArrayHandler<4> h;
Reader reader; Reader reader;
reader.Parse(s, h); reader.Parse(s, h);
EXPECT_EQ(6u, h.step_); EXPECT_EQ(6u, h.step_);
free(json); free(json);
} }
...@@ -470,7 +470,7 @@ TEST(Reader, ParseArray_Error) { ...@@ -470,7 +470,7 @@ TEST(Reader, ParseArray_Error) {
InsituStringStream s(buffer); \ InsituStringStream s(buffer); \
BaseReaderHandler<> h; \ BaseReaderHandler<> h; \
GenericReader<UTF8<>, UTF8<>, CrtAllocator> reader; \ GenericReader<UTF8<>, UTF8<>, CrtAllocator> reader; \
EXPECT_FALSE(reader.Parse(s, h)); \ EXPECT_FALSE(reader.Parse(s, h)); \
EXPECT_EQ(errorCode, reader.GetParseErrorCode());\ EXPECT_EQ(errorCode, reader.GetParseErrorCode());\
} }
...@@ -485,7 +485,7 @@ TEST(Reader, ParseArray_Error) { ...@@ -485,7 +485,7 @@ TEST(Reader, ParseArray_Error) {
struct ParseObjectHandler : BaseReaderHandler<UTF8<>, ParseObjectHandler> { struct ParseObjectHandler : BaseReaderHandler<UTF8<>, ParseObjectHandler> {
ParseObjectHandler() : step_(0) {} ParseObjectHandler() : step_(0) {}
bool Default() { ADD_FAILURE(); return false; } bool Default() { ADD_FAILURE(); return false; }
bool Null() { EXPECT_EQ(8u, step_); step_++; return true; } bool Null() { EXPECT_EQ(8u, step_); step_++; return true; }
bool Bool(bool b) { bool Bool(bool b) {
switch(step_) { switch(step_) {
...@@ -535,7 +535,7 @@ TEST(Reader, ParseObject) { ...@@ -535,7 +535,7 @@ TEST(Reader, ParseObject) {
InsituStringStream s(json2); InsituStringStream s(json2);
ParseObjectHandler h; ParseObjectHandler h;
Reader reader; Reader reader;
reader.Parse<kParseInsituFlag>(s, h); reader.Parse<kParseInsituFlag>(s, h);
EXPECT_EQ(20u, h.step_); EXPECT_EQ(20u, h.step_);
free(json2); free(json2);
} }
...@@ -545,7 +545,7 @@ TEST(Reader, ParseObject) { ...@@ -545,7 +545,7 @@ TEST(Reader, ParseObject) {
StringStream s(json); StringStream s(json);
ParseObjectHandler h; ParseObjectHandler h;
Reader reader; Reader reader;
reader.Parse(s, h); reader.Parse(s, h);
EXPECT_EQ(20u, h.step_); EXPECT_EQ(20u, h.step_);
} }
} }
...@@ -564,7 +564,7 @@ TEST(Reader, Parse_EmptyObject) { ...@@ -564,7 +564,7 @@ TEST(Reader, Parse_EmptyObject) {
StringStream s("{ } "); StringStream s("{ } ");
ParseEmptyObjectHandler h; ParseEmptyObjectHandler h;
Reader reader; Reader reader;
reader.Parse(s, h); reader.Parse(s, h);
EXPECT_EQ(2u, h.step_); EXPECT_EQ(2u, h.step_);
} }
...@@ -631,7 +631,7 @@ TEST(Reader, ParseInsituIterative_MultipleRoot) { ...@@ -631,7 +631,7 @@ TEST(Reader, ParseInsituIterative_MultipleRoot) {
InsituStringStream s(buffer); \ InsituStringStream s(buffer); \
BaseReaderHandler<> h; \ BaseReaderHandler<> h; \
Reader reader; \ Reader reader; \
EXPECT_FALSE(reader.Parse(s, h)); \ EXPECT_FALSE(reader.Parse(s, h)); \
EXPECT_EQ(errorCode, reader.GetParseErrorCode());\ EXPECT_EQ(errorCode, reader.GetParseErrorCode());\
} }
...@@ -644,17 +644,17 @@ TEST(Reader, ParseDocument_Error) { ...@@ -644,17 +644,17 @@ TEST(Reader, ParseDocument_Error) {
// The document root must not follow by other values. // The document root must not follow by other values.
TEST_ERROR(kParseErrorDocumentRootNotSingular, "[] 0"); TEST_ERROR(kParseErrorDocumentRootNotSingular, "[] 0");
TEST_ERROR(kParseErrorDocumentRootNotSingular, "{} 0"); TEST_ERROR(kParseErrorDocumentRootNotSingular, "{} 0");
TEST_ERROR(kParseErrorDocumentRootNotSingular, "null []"); TEST_ERROR(kParseErrorDocumentRootNotSingular, "null []");
TEST_ERROR(kParseErrorDocumentRootNotSingular, "0 {}"); TEST_ERROR(kParseErrorDocumentRootNotSingular, "0 {}");
} }
TEST(Reader, ParseValue_Error) { TEST(Reader, ParseValue_Error) {
// Invalid value. // Invalid value.
TEST_ERROR(kParseErrorValueInvalid, "nulL"); TEST_ERROR(kParseErrorValueInvalid, "nulL");
TEST_ERROR(kParseErrorValueInvalid, "truE"); TEST_ERROR(kParseErrorValueInvalid, "truE");
TEST_ERROR(kParseErrorValueInvalid, "falsE"); TEST_ERROR(kParseErrorValueInvalid, "falsE");
TEST_ERROR(kParseErrorValueInvalid, "a]"); TEST_ERROR(kParseErrorValueInvalid, "a]");
TEST_ERROR(kParseErrorValueInvalid, ".1"); TEST_ERROR(kParseErrorValueInvalid, ".1");
} }
TEST(Reader, ParseObject_Error) { TEST(Reader, ParseObject_Error) {
......
...@@ -51,13 +51,13 @@ TEST(Writer, Compact) { ...@@ -51,13 +51,13 @@ TEST(Writer, Compact) {
} }
TEST(Writer, Root) { TEST(Writer, Root) {
TEST_ROUNDTRIP("null"); TEST_ROUNDTRIP("null");
TEST_ROUNDTRIP("true"); TEST_ROUNDTRIP("true");
TEST_ROUNDTRIP("false"); TEST_ROUNDTRIP("false");
TEST_ROUNDTRIP("0"); TEST_ROUNDTRIP("0");
TEST_ROUNDTRIP("\"foo\""); TEST_ROUNDTRIP("\"foo\"");
TEST_ROUNDTRIP("[]"); TEST_ROUNDTRIP("[]");
TEST_ROUNDTRIP("{}"); TEST_ROUNDTRIP("{}");
} }
TEST(Writer, Int) { TEST(Writer, Int) {
...@@ -170,7 +170,7 @@ TEST(Writer, AssertRootMayBeAnyValue) { ...@@ -170,7 +170,7 @@ TEST(Writer, AssertRootMayBeAnyValue) {
{\ {\
StringBuffer buffer;\ StringBuffer buffer;\
Writer<StringBuffer> writer(buffer);\ Writer<StringBuffer> writer(buffer);\
EXPECT_TRUE(x);\ EXPECT_TRUE(x);\
} }
T(writer.Bool(false)); T(writer.Bool(false));
T(writer.Bool(true)); T(writer.Bool(true));
...@@ -243,18 +243,18 @@ TEST(Writer, AssertMultipleRoot) { ...@@ -243,18 +243,18 @@ TEST(Writer, AssertMultipleRoot) {
writer.EndObject(); writer.EndObject();
ASSERT_THROW(writer.StartObject(), AssertException); ASSERT_THROW(writer.StartObject(), AssertException);
writer.Reset(buffer); writer.Reset(buffer);
writer.Null(); writer.Null();
ASSERT_THROW(writer.Int(0), AssertException); ASSERT_THROW(writer.Int(0), AssertException);
writer.Reset(buffer); writer.Reset(buffer);
writer.String("foo"); writer.String("foo");
ASSERT_THROW(writer.StartArray(), AssertException); ASSERT_THROW(writer.StartArray(), AssertException);
writer.Reset(buffer); writer.Reset(buffer);
writer.StartArray(); writer.StartArray();
writer.EndArray(); writer.EndArray();
ASSERT_THROW(writer.Double(3.14), AssertException); ASSERT_THROW(writer.Double(3.14), AssertException);
} }
TEST(Writer, RootObjectIsComplete) { TEST(Writer, RootObjectIsComplete) {
...@@ -287,21 +287,21 @@ TEST(Writer, RootArrayIsComplete) { ...@@ -287,21 +287,21 @@ TEST(Writer, RootArrayIsComplete) {
TEST(Writer, RootValueIsComplete) { TEST(Writer, RootValueIsComplete) {
#define T(x)\ #define T(x)\
{\ {\
StringBuffer buffer;\ StringBuffer buffer;\
Writer<StringBuffer> writer(buffer);\ Writer<StringBuffer> writer(buffer);\
EXPECT_FALSE(writer.IsComplete()); \ EXPECT_FALSE(writer.IsComplete()); \
x; \ x; \
EXPECT_TRUE(writer.IsComplete()); \ EXPECT_TRUE(writer.IsComplete()); \
} }
T(writer.Null()); T(writer.Null());
T(writer.Bool(true)); T(writer.Bool(true));
T(writer.Bool(false)); T(writer.Bool(false));
T(writer.Int(0)); T(writer.Int(0));
T(writer.Uint(0)); T(writer.Uint(0));
T(writer.Int64(0)); T(writer.Int64(0));
T(writer.Uint64(0)); T(writer.Uint64(0));
T(writer.Double(0)); T(writer.Double(0));
T(writer.String("")); T(writer.String(""));
#undef T #undef T
} }
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