Commit 78492f99 authored by miloyip@gmail.com's avatar miloyip@gmail.com

Fixed compilation errors in Ubuntu 64-bit

git-svn-id: https://rapidjson.googlecode.com/svn/trunk@29 c5894555-1306-4e8d-425f-1f6f381ee07c
parent 9ae680d3
...@@ -67,6 +67,9 @@ solution "test" ...@@ -67,6 +67,9 @@ solution "test"
project "gtest" project "gtest"
kind "StaticLib" kind "StaticLib"
defines { "GTEST_HAS_PTHREAD=0" }
files { files {
"../thirdparty/gtest/src/gtest-all.cc", "../thirdparty/gtest/src/gtest-all.cc",
"../thirdparty/gtest/src/**.h", "../thirdparty/gtest/src/**.h",
......
...@@ -44,7 +44,7 @@ public: ...@@ -44,7 +44,7 @@ public:
length_ = (size_t)ftell(fp); length_ = (size_t)ftell(fp);
fseek(fp, 0, SEEK_SET); fseek(fp, 0, SEEK_SET);
json_ = (char*)malloc(length_ + 1); json_ = (char*)malloc(length_ + 1);
fread(json_, 1, length_, fp); ASSERT_EQ(length_, fread(json_, 1, length_, fp));
json_[length_] = '\0'; json_[length_] = '\0';
fclose(fp); fclose(fp);
......
...@@ -109,7 +109,7 @@ TEST_F(Platform, read) { ...@@ -109,7 +109,7 @@ TEST_F(Platform, read) {
#else #else
TEST_F(Platform, read) { TEST_F(Platform, read) {
for (int i = 0; i < kTrialCount; i++) { for (int i = 0; i < kTrialCount; i++) {
int fd = open(filename_, O_BINARY | O_RDONLY); int fd = open(filename_, O_RDONLY);
ASSERT_NE(-1, fd); ASSERT_NE(-1, fd);
ASSERT_EQ(length_, read(fd, temp_, length_)); ASSERT_EQ(length_, read(fd, temp_, length_));
EXPECT_EQ(checkSum_, CheckSum()); EXPECT_EQ(checkSum_, CheckSum());
...@@ -138,7 +138,7 @@ TEST_F(Platform, MapViewOfFile) { ...@@ -138,7 +138,7 @@ TEST_F(Platform, MapViewOfFile) {
#ifdef _POSIX_MAPPED_FILES #ifdef _POSIX_MAPPED_FILES
TEST_F(Platform, mmap) { TEST_F(Platform, mmap) {
for (int i = 0; i < kTrialCount; i++) { for (int i = 0; i < kTrialCount; i++) {
int fd = open(filename_, _O_BINARY | _O_RDONLY); int fd = open(filename_, O_RDONLY);
ASSERT_NE(-1, fd); ASSERT_NE(-1, fd);
void *p = mmap(NULL, length_, PROT_READ, MAP_PRIVATE, fd, 0); void *p = mmap(NULL, length_, PROT_READ, MAP_PRIVATE, fd, 0);
ASSERT_TRUE(p != NULL); ASSERT_TRUE(p != NULL);
......
...@@ -85,7 +85,11 @@ yajl_gen_status GenVal(yajl_gen g, yajl_val v) { ...@@ -85,7 +85,11 @@ yajl_gen_status GenVal(yajl_gen g, yajl_val v) {
size_t len; size_t len;
//if (YAJL_IS_INTEGER(v)) // buggy //if (YAJL_IS_INTEGER(v)) // buggy
if (v->u.number.flags & YAJL_NUMBER_INT_VALID) if (v->u.number.flags & YAJL_NUMBER_INT_VALID)
len = sprintf(num, "%d", YAJL_GET_INTEGER(v)); #if _MSC_VER
len = sprintf(num, "%I64d", YAJL_GET_INTEGER(v));
#else
len = sprintf(num, "%lld", YAJL_GET_INTEGER(v));
#endif
//else if (YAJL_IS_DOUBLE(v)) // buggy //else if (YAJL_IS_DOUBLE(v)) // buggy
else if (v->u.number.flags & YAJL_NUMBER_DOUBLE_VALID) else if (v->u.number.flags & YAJL_NUMBER_DOUBLE_VALID)
len = sprintf(num, "%g", YAJL_GET_DOUBLE(v)); len = sprintf(num, "%g", YAJL_GET_DOUBLE(v));
......
...@@ -193,7 +193,7 @@ TEST(Value, Uint) { ...@@ -193,7 +193,7 @@ TEST(Value, Uint) {
TEST(Value, Int64) { TEST(Value, Int64) {
// Constructor with int // Constructor with int
Value x(1234LL); Value x(int64_t(1234LL));
EXPECT_EQ(kNumberType, x.GetType()); EXPECT_EQ(kNumberType, x.GetType());
EXPECT_EQ(1234, x.GetInt()); EXPECT_EQ(1234, x.GetInt());
EXPECT_EQ(1234, x.GetUint()); EXPECT_EQ(1234, x.GetUint());
...@@ -214,7 +214,7 @@ TEST(Value, Int64) { ...@@ -214,7 +214,7 @@ TEST(Value, Int64) {
EXPECT_FALSE(x.IsObject()); EXPECT_FALSE(x.IsObject());
EXPECT_FALSE(x.IsArray()); EXPECT_FALSE(x.IsArray());
Value nx(-1234LL); Value nx(int64_t(-1234LL));
EXPECT_EQ(-1234, nx.GetInt()); EXPECT_EQ(-1234, nx.GetInt());
EXPECT_EQ(-1234, nx.GetInt64()); EXPECT_EQ(-1234, nx.GetInt64());
EXPECT_TRUE(nx.IsInt()); EXPECT_TRUE(nx.IsInt());
...@@ -238,7 +238,7 @@ TEST(Value, Int64) { ...@@ -238,7 +238,7 @@ TEST(Value, Int64) {
TEST(Value, Uint64) { TEST(Value, Uint64) {
// Constructor with int // Constructor with int
Value x(1234LL); Value x(uint64_t(1234LL));
EXPECT_EQ(kNumberType, x.GetType()); EXPECT_EQ(kNumberType, x.GetType());
EXPECT_EQ(1234, x.GetInt()); EXPECT_EQ(1234, x.GetInt());
EXPECT_EQ(1234, x.GetUint()); EXPECT_EQ(1234, x.GetUint());
......
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