mirror of
https://github.com/pocoproject/poco.git
synced 2025-10-17 11:05:03 +02:00
Add 64-bit integer JSON unit test
This commit is contained in:
@@ -203,6 +203,40 @@ void JSONTest::testNumberProperty()
|
|||||||
assert(value == 1969);
|
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()
|
void JSONTest::testStringProperty()
|
||||||
{
|
{
|
||||||
@@ -860,6 +894,9 @@ CppUnit::Test* JSONTest::suite()
|
|||||||
CppUnit_addTest(pSuite, JSONTest, testTrueProperty);
|
CppUnit_addTest(pSuite, JSONTest, testTrueProperty);
|
||||||
CppUnit_addTest(pSuite, JSONTest, testFalseProperty);
|
CppUnit_addTest(pSuite, JSONTest, testFalseProperty);
|
||||||
CppUnit_addTest(pSuite, JSONTest, testNumberProperty);
|
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, testStringProperty);
|
||||||
CppUnit_addTest(pSuite, JSONTest, testEmptyObject);
|
CppUnit_addTest(pSuite, JSONTest, testEmptyObject);
|
||||||
CppUnit_addTest(pSuite, JSONTest, testDoubleProperty);
|
CppUnit_addTest(pSuite, JSONTest, testDoubleProperty);
|
||||||
|
@@ -51,6 +51,9 @@ public:
|
|||||||
void testTrueProperty();
|
void testTrueProperty();
|
||||||
void testFalseProperty();
|
void testFalseProperty();
|
||||||
void testNumberProperty();
|
void testNumberProperty();
|
||||||
|
#if defined(POCO_HAVE_INT64)
|
||||||
|
void testNumber64Property();
|
||||||
|
#endif
|
||||||
void testStringProperty();
|
void testStringProperty();
|
||||||
void testEmptyObject();
|
void testEmptyObject();
|
||||||
void testDoubleProperty();
|
void testDoubleProperty();
|
||||||
|
Reference in New Issue
Block a user