mirror of
https://github.com/Tencent/rapidjson.git
synced 2025-10-27 02:53:13 +01:00
Fix clang -Weverything
This commit is contained in:
@@ -28,7 +28,7 @@ void ParseCheck(DocumentType& doc) {
|
||||
typedef typename DocumentType::ValueType ValueType;
|
||||
|
||||
EXPECT_FALSE(doc.HasParseError());
|
||||
EXPECT_TRUE((ParseResult)doc);
|
||||
EXPECT_TRUE(static_cast<ParseResult>(doc));
|
||||
|
||||
EXPECT_TRUE(doc.IsObject());
|
||||
|
||||
@@ -63,8 +63,8 @@ void ParseCheck(DocumentType& doc) {
|
||||
const ValueType& a = doc["a"];
|
||||
EXPECT_TRUE(a.IsArray());
|
||||
EXPECT_EQ(4u, a.Size());
|
||||
for (SizeType i = 0; i < 4; i++)
|
||||
EXPECT_EQ(i + 1, a[i].GetUint());
|
||||
for (SizeType j = 0; j < 4; j++)
|
||||
EXPECT_EQ(j + 1, a[j].GetUint());
|
||||
}
|
||||
|
||||
template <typename Allocator, typename StackAllocator>
|
||||
@@ -118,15 +118,15 @@ TEST(Document, UnchangedOnParseError) {
|
||||
|
||||
static FILE* OpenEncodedFile(const char* filename) {
|
||||
const char *paths[] = {
|
||||
"encodings/%s",
|
||||
"bin/encodings/%s",
|
||||
"../bin/encodings/%s",
|
||||
"../../bin/encodings/%s",
|
||||
"../../../bin/encodings/%s"
|
||||
"encodings",
|
||||
"bin/encodings",
|
||||
"../bin/encodings",
|
||||
"../../bin/encodings",
|
||||
"../../../bin/encodings"
|
||||
};
|
||||
char buffer[1024];
|
||||
for (size_t i = 0; i < sizeof(paths) / sizeof(paths[0]); i++) {
|
||||
sprintf(buffer, paths[i], filename);
|
||||
sprintf(buffer, "%s/%s", paths[i], filename);
|
||||
FILE *fp = fopen(buffer, "rb");
|
||||
if (fp)
|
||||
return fp;
|
||||
@@ -157,22 +157,22 @@ TEST(Document, ParseStream_EncodedInputStream) {
|
||||
StringBuffer bos;
|
||||
typedef EncodedOutputStream<UTF8<>, StringBuffer> OutputStream;
|
||||
OutputStream eos(bos, false); // Not writing BOM
|
||||
Writer<OutputStream, UTF16<>, UTF8<> > writer(eos);
|
||||
d.Accept(writer);
|
||||
|
||||
{
|
||||
// Condense the original file and compare.
|
||||
FILE *fp = OpenEncodedFile("utf8.json");
|
||||
FileReadStream is(fp, buffer, sizeof(buffer));
|
||||
Reader reader;
|
||||
StringBuffer bos2;
|
||||
Writer<StringBuffer> writer(bos2);
|
||||
reader.Parse(is, writer);
|
||||
fclose(fp);
|
||||
|
||||
EXPECT_EQ(bos.GetSize(), bos2.GetSize());
|
||||
EXPECT_EQ(0, memcmp(bos.GetString(), bos2.GetString(), bos2.GetSize()));
|
||||
Writer<OutputStream, UTF16<>, UTF8<> > writer(eos);
|
||||
d.Accept(writer);
|
||||
}
|
||||
|
||||
// Condense the original file and compare.
|
||||
fp = OpenEncodedFile("utf8.json");
|
||||
FileReadStream is(fp, buffer, sizeof(buffer));
|
||||
Reader reader;
|
||||
StringBuffer bos2;
|
||||
Writer<StringBuffer> writer2(bos2);
|
||||
reader.Parse(is, writer2);
|
||||
fclose(fp);
|
||||
|
||||
EXPECT_EQ(bos.GetSize(), bos2.GetSize());
|
||||
EXPECT_EQ(0, memcmp(bos.GetString(), bos2.GetString(), bos2.GetSize()));
|
||||
}
|
||||
|
||||
TEST(Document, ParseStream_AutoUTFInputStream) {
|
||||
@@ -199,19 +199,17 @@ TEST(Document, ParseStream_AutoUTFInputStream) {
|
||||
Writer<StringBuffer> writer(bos);
|
||||
d.Accept(writer);
|
||||
|
||||
{
|
||||
// Condense the original file and compare.
|
||||
FILE *fp = OpenEncodedFile("utf8.json");
|
||||
FileReadStream is(fp, buffer, sizeof(buffer));
|
||||
Reader reader;
|
||||
StringBuffer bos2;
|
||||
Writer<StringBuffer> writer(bos2);
|
||||
reader.Parse(is, writer);
|
||||
fclose(fp);
|
||||
// Condense the original file and compare.
|
||||
fp = OpenEncodedFile("utf8.json");
|
||||
FileReadStream is(fp, buffer, sizeof(buffer));
|
||||
Reader reader;
|
||||
StringBuffer bos2;
|
||||
Writer<StringBuffer> writer2(bos2);
|
||||
reader.Parse(is, writer2);
|
||||
fclose(fp);
|
||||
|
||||
EXPECT_EQ(bos.GetSize(), bos2.GetSize());
|
||||
EXPECT_EQ(0, memcmp(bos.GetString(), bos2.GetString(), bos2.GetSize()));
|
||||
}
|
||||
EXPECT_EQ(bos.GetSize(), bos2.GetSize());
|
||||
EXPECT_EQ(0, memcmp(bos.GetString(), bos2.GetString(), bos2.GetSize()));
|
||||
}
|
||||
|
||||
TEST(Document, Swap) {
|
||||
@@ -263,12 +261,16 @@ TEST(Document, Swap) {
|
||||
struct OutputStringStream : public std::ostringstream {
|
||||
typedef char Ch;
|
||||
|
||||
virtual ~OutputStringStream();
|
||||
|
||||
void Put(char c) {
|
||||
put(c);
|
||||
}
|
||||
void Flush() {}
|
||||
};
|
||||
|
||||
OutputStringStream::~OutputStringStream() {}
|
||||
|
||||
TEST(Document, AcceptWriter) {
|
||||
Document doc;
|
||||
doc.Parse(" { \"hello\" : \"world\", \"t\" : true , \"f\" : false, \"n\": null, \"i\":123, \"pi\": 3.1416, \"a\":[1, 2, 3, 4] } ");
|
||||
|
||||
Reference in New Issue
Block a user