Add 64-bit integer JSON unit test

This commit is contained in:
Mike Naquin 2012-12-13 08:27:42 -06:00
parent ef9cda6666
commit 25811d4c64
2 changed files with 40 additions and 0 deletions

View File

@ -203,6 +203,40 @@ void JSONTest::testNumberProperty()
assert(value == 1969);
}
#if defined(POCO_HAVE_INT64)
void JSONTest::testNumber64Property()
{
std::string json = "{ \"test\" : 5000000000000000 }";
Parser parser;
Var result;
try
{
DefaultHandler handler;
parser.setHandler(&handler);
parser.parse(json);
result = handler.result();
}
catch(JSONException& jsone)
{
std::cout << jsone.message() << std::endl;
assert(false);
}
assert(result.type() == typeid(Object::Ptr));
Object::Ptr object = result.extract<Object::Ptr>();
Var test = object->get("test");
assert(test.isInteger());
Int64 value = test;
assert(value == 5000000000000000);
}
#endif
void JSONTest::testStringProperty()
{
@ -860,6 +894,9 @@ CppUnit::Test* JSONTest::suite()
CppUnit_addTest(pSuite, JSONTest, testTrueProperty);
CppUnit_addTest(pSuite, JSONTest, testFalseProperty);
CppUnit_addTest(pSuite, JSONTest, testNumberProperty);
#if defined(POCO_HAVE_INT64)
CppUnit_addTest(pSuite, JSONTest, testNumber64Property);
#endif
CppUnit_addTest(pSuite, JSONTest, testStringProperty);
CppUnit_addTest(pSuite, JSONTest, testEmptyObject);
CppUnit_addTest(pSuite, JSONTest, testDoubleProperty);

View File

@ -51,6 +51,9 @@ public:
void testTrueProperty();
void testFalseProperty();
void testNumberProperty();
#if defined(POCO_HAVE_INT64)
void testNumber64Property();
#endif
void testStringProperty();
void testEmptyObject();
void testDoubleProperty();