"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "test/unittest/itoatest.cpp" between
rapidjson-1.0.2.tar.gz and rapidjson-1.1.0.tar.gz

About: RapidJSON is a fast JSON parser/generator for C++ with both SAX/DOM style API.

itoatest.cpp  (rapidjson-1.0.2):itoatest.cpp  (rapidjson-1.1.0)
skipping to change at line 33 skipping to change at line 33
using namespace rapidjson::internal; using namespace rapidjson::internal;
template <typename T> template <typename T>
struct Traits { struct Traits {
}; };
template <> template <>
struct Traits<uint32_t> { struct Traits<uint32_t> {
enum { kBufferSize = 11 }; enum { kBufferSize = 11 };
enum { kMaxDigit = 10 }; enum { kMaxDigit = 10 };
static uint32_t Negate(uint32_t x) { return x; }; static uint32_t Negate(uint32_t x) { return x; }
}; };
template <> template <>
struct Traits<int32_t> { struct Traits<int32_t> {
enum { kBufferSize = 12 }; enum { kBufferSize = 12 };
enum { kMaxDigit = 10 }; enum { kMaxDigit = 10 };
static int32_t Negate(int32_t x) { return -x; }; static int32_t Negate(int32_t x) { return -x; }
}; };
template <> template <>
struct Traits<uint64_t> { struct Traits<uint64_t> {
enum { kBufferSize = 21 }; enum { kBufferSize = 21 };
enum { kMaxDigit = 20 }; enum { kMaxDigit = 20 };
static uint64_t Negate(uint64_t x) { return x; }; static uint64_t Negate(uint64_t x) { return x; }
}; };
template <> template <>
struct Traits<int64_t> { struct Traits<int64_t> {
enum { kBufferSize = 22 }; enum { kBufferSize = 22 };
enum { kMaxDigit = 20 }; enum { kMaxDigit = 20 };
static int64_t Negate(int64_t x) { return -x; }; static int64_t Negate(int64_t x) { return -x; }
}; };
template <typename T> template <typename T>
static void VerifyValue(T value, void(*f)(T, char*), char* (*g)(T, char*)) { static void VerifyValue(T value, void(*f)(T, char*), char* (*g)(T, char*)) {
char buffer1[Traits<T>::kBufferSize]; char buffer1[Traits<T>::kBufferSize];
char buffer2[Traits<T>::kBufferSize]; char buffer2[Traits<T>::kBufferSize];
f(value, buffer1); f(value, buffer1);
*g(value, buffer2) = '\0'; *g(value, buffer2) = '\0';
skipping to change at line 86 skipping to change at line 86
for (uint32_t power = 2; power <= 10; power += 8) { for (uint32_t power = 2; power <= 10; power += 8) {
T i = 1, last; T i = 1, last;
do { do {
VerifyValue<T>(i - 1, f, g); VerifyValue<T>(i - 1, f, g);
VerifyValue<T>(i, f, g); VerifyValue<T>(i, f, g);
if (std::numeric_limits<T>::min() < 0) { if (std::numeric_limits<T>::min() < 0) {
VerifyValue<T>(Traits<T>::Negate(i), f, g); VerifyValue<T>(Traits<T>::Negate(i), f, g);
VerifyValue<T>(Traits<T>::Negate(i + 1), f, g); VerifyValue<T>(Traits<T>::Negate(i + 1), f, g);
} }
last = i; last = i;
if (i > static_cast<T>(std::numeric_limits<T>::max() / static_cast<T
>(power)))
break;
i *= power; i *= power;
} while (last < i); } while (last < i);
} }
} }
static void u32toa_naive(uint32_t value, char* buffer) { static void u32toa_naive(uint32_t value, char* buffer) {
char temp[10]; char temp[10];
char *p = temp; char *p = temp;
do { do {
*p++ = char(value % 10) + '0'; *p++ = static_cast<char>(char(value % 10) + '0');
value /= 10; value /= 10;
} while (value > 0); } while (value > 0);
do { do {
*buffer++ = *--p; *buffer++ = *--p;
} while (p != temp); } while (p != temp);
*buffer = '\0'; *buffer = '\0';
} }
skipping to change at line 119 skipping to change at line 121
*buffer++ = '-'; *buffer++ = '-';
u = ~u + 1; u = ~u + 1;
} }
u32toa_naive(u, buffer); u32toa_naive(u, buffer);
} }
static void u64toa_naive(uint64_t value, char* buffer) { static void u64toa_naive(uint64_t value, char* buffer) {
char temp[20]; char temp[20];
char *p = temp; char *p = temp;
do { do {
*p++ = char(value % 10) + '0'; *p++ = static_cast<char>(char(value % 10) + '0');
value /= 10; value /= 10;
} while (value > 0); } while (value > 0);
do { do {
*buffer++ = *--p; *buffer++ = *--p;
} while (p != temp); } while (p != temp);
*buffer = '\0'; *buffer = '\0';
} }
 End of changes. 7 change blocks. 
6 lines changed or deleted 9 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)