mirror of
https://github.com/pocoproject/poco.git
synced 2025-02-20 22:31:23 +01:00
parent
e21d1f5fcc
commit
1b14088283
@ -15,6 +15,7 @@ Release 1.5.0 (2012-12-17)
|
||||
- Android compile/build support (by Rangel Reale)
|
||||
- TypeHandler::prepare() now takes const-reference
|
||||
- fixed GH #27: Poco::URI::decode() doesn't properly handle '+'
|
||||
- fixed GH #31: JSON implementation bug
|
||||
|
||||
Release 1.5.0 (2012-10-14)
|
||||
==========================
|
||||
|
@ -51,9 +51,8 @@ namespace Poco {
|
||||
|
||||
template <class T>
|
||||
class Buffer
|
||||
/// A very simple buffer class that allocates a buffer of
|
||||
/// a given type and size in the constructor and
|
||||
/// deallocates the buffer in the destructor.
|
||||
/// A buffer class that allocates a buffer of a given type and size
|
||||
/// in the constructor and deallocates the buffer in the destructor.
|
||||
///
|
||||
/// This class is useful everywhere where a temporary buffer
|
||||
/// is needed.
|
||||
|
@ -161,7 +161,7 @@ inline bool Object::has(const std::string& key) const
|
||||
inline bool Object::isArray(const std::string& key) const
|
||||
{
|
||||
ValueMap::const_iterator it = _values.find(key);
|
||||
return it != _values.end() || it->second.type() == typeid(Array::Ptr);
|
||||
return it != _values.end() && it->second.type() == typeid(Array::Ptr);
|
||||
}
|
||||
|
||||
|
||||
@ -175,7 +175,7 @@ inline bool Object::isNull(const std::string& key) const
|
||||
inline bool Object::isObject(const std::string& key) const
|
||||
{
|
||||
ValueMap::const_iterator it = _values.find(key);
|
||||
return it != _values.end() || it->second.type() == typeid(Object::Ptr);
|
||||
return it != _values.end() && it->second.type() == typeid(Object::Ptr);
|
||||
}
|
||||
|
||||
|
||||
|
@ -366,8 +366,11 @@ void JSONTest::testObjectProperty()
|
||||
}
|
||||
|
||||
assert(result.type() == typeid(Object::Ptr));
|
||||
|
||||
|
||||
Object::Ptr object = result.extract<Object::Ptr>();
|
||||
assert (object->isObject("test"));
|
||||
assert (!object->isArray("test"));
|
||||
|
||||
Var test = object->get("test");
|
||||
assert(test.type() == typeid(Object::Ptr));
|
||||
object = test.extract<Object::Ptr>();
|
||||
@ -379,6 +382,36 @@ void JSONTest::testObjectProperty()
|
||||
}
|
||||
|
||||
|
||||
void JSONTest::testObjectArray()
|
||||
{
|
||||
std::string json = "{ \"test\" : { \"test1\" : [1, 2, 3], \"test2\" : 4 } }";
|
||||
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>();
|
||||
assert(object->isObject("test"));
|
||||
object = object->getObject("test");
|
||||
assert(!object->isObject("test1"));
|
||||
assert(object->isArray("test1"));
|
||||
assert(!object->isObject("test2"));
|
||||
assert(!object->isArray("test2"));
|
||||
}
|
||||
|
||||
|
||||
void JSONTest::testEmptyArray()
|
||||
{
|
||||
std::string json = "[]";
|
||||
@ -833,6 +866,7 @@ CppUnit::Test* JSONTest::suite()
|
||||
CppUnit_addTest(pSuite, JSONTest, testDouble2Property);
|
||||
CppUnit_addTest(pSuite, JSONTest, testDouble3Property);
|
||||
CppUnit_addTest(pSuite, JSONTest, testObjectProperty);
|
||||
CppUnit_addTest(pSuite, JSONTest, testObjectArray);
|
||||
CppUnit_addTest(pSuite, JSONTest, testEmptyArray);
|
||||
CppUnit_addTest(pSuite, JSONTest, testNestedArray);
|
||||
CppUnit_addTest(pSuite, JSONTest, testNullElement);
|
||||
|
@ -57,6 +57,7 @@ public:
|
||||
void testDouble2Property();
|
||||
void testDouble3Property();
|
||||
void testObjectProperty();
|
||||
void testObjectArray();
|
||||
void testEmptyArray();
|
||||
void testNestedArray();
|
||||
void testNullElement();
|
||||
|
Loading…
x
Reference in New Issue
Block a user