Skip to content

Commit 7acbb87

Browse files
committed
Some more tests
1 parent 4e9b4f6 commit 7acbb87

File tree

1 file changed

+37
-1
lines changed

1 file changed

+37
-1
lines changed

test/unittest/readertest.cpp

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,8 @@ TEST(Reader, ParseNumber_NormalPrecisionError) {
449449
TEST(Reader, ParseNumber_Error) {
450450
#define TEST_NUMBER_ERROR(errorCode, str, errorOffset, streamPos) \
451451
{ \
452-
char buffer[1001]; \
452+
char buffer[2048]; \
453+
ASSERT_LT(std::strlen(str), 2048u); \
453454
sprintf(buffer, "%s", str); \
454455
InsituStringStream s(buffer); \
455456
BaseReaderHandler<> h; \
@@ -498,6 +499,41 @@ TEST(Reader, ParseNumber_Error) {
498499
"03685473724737236837236775297525854775297525472975254737236873720170151235473783"
499500
"7236737247372368772473723683723456789012E66", 0, 283);
500501

502+
// Half way between max-normal and infinity
503+
// Should round to infinity in nearest-even mode.
504+
TEST_NUMBER_ERROR(kParseErrorNumberTooBig,
505+
"1.797693134862315807937289714053034150799341327100378269361737789804449682927647"
506+
"50946649017977587207096330286416692887910946555547851940402630657488671505820681"
507+
"90890200070838367627385484581771153176447573027006985557136695962284291481986083"
508+
"49364752927190741684443655107043427115596995080930428801779041744977920000000000"
509+
"00000000000000000000000000000000000000000000000000000000000000000000000000000000"
510+
"00000000000000000000000000000000000000000000000000000000000000000000000000000000"
511+
"00000000000000000000000000000000000000000000000000000000000000000000000000000000"
512+
"00000000000000000000000000000000000000000000000000000000000000000000000000000000"
513+
"00000000000000000000000000000000000000000000000000000000000000000000000000000000"
514+
"00000000000000000000000000000000000000000000000000000000000000000000000000000000"
515+
"00000000000000000000000000000000000000000000000000000000000000000000000000000000"
516+
"00000000000000000000000000000000000000000000000000000000000000000000000000000000"
517+
"00000000000000000000000000000000000000000000000000000000000000000000000000000000"
518+
"00000000000000000000000000000000000000000000000000000000000000000000000000000000e+308", 0, 1125);
519+
// ...round up
520+
TEST_NUMBER_ERROR(kParseErrorNumberTooBig,
521+
"1.797693134862315807937289714053034150799341327100378269361737789804449682927647"
522+
"50946649017977587207096330286416692887910946555547851940402630657488671505820681"
523+
"90890200070838367627385484581771153176447573027006985557136695962284291481986083"
524+
"49364752927190741684443655107043427115596995080930428801779041744977920000000000"
525+
"00000000000000000000000000000000000000000000000000000000000000000000000000000000"
526+
"00000000000000000000000000000000000000000000000000000000000000000000000000000000"
527+
"00000000000000000000000000000000000000000000000000000000000000000000000000000000"
528+
"00000000000000000000000000000000000000000000000000000000000000000000000000000000"
529+
"00000000000000000000000000000000000000000000000000000000000000000000000000000000"
530+
"00000000000000000000000000000000000000000000000000000000000000000000000000000000"
531+
"00000000000000000000000000000000000000000000000000000000000000000000000000000000"
532+
"00000000000000000000000000000000000000000000000000000000000000000000000000000000"
533+
"00000000000000000000000000000000000000000000000000000000000000000000000000000000"
534+
"00000000000000000000000000000000000000000000000000000000000000000000000000000000"
535+
"00000000000000000000000000000000000000000000000000000000000000000000000000000001e+308", 0, 1125);
536+
501537
#undef TEST_NUMBER_ERROR
502538
}
503539

0 commit comments

Comments
 (0)