mirror of
https://github.com/pocoproject/poco.git
synced 2024-12-13 10:32:57 +01:00
#3114: Added JSON Array::empty() method
This commit is contained in:
parent
eb992c9042
commit
95214e428a
@ -124,6 +124,9 @@ public:
|
||||
std::size_t size() const;
|
||||
/// Returns the size of the array.
|
||||
|
||||
bool empty() const;
|
||||
/// Returns true if the array is empty, false otherwise.
|
||||
|
||||
bool isArray(unsigned int index) const;
|
||||
/// Returns true when the element is an array.
|
||||
|
||||
@ -241,6 +244,12 @@ inline std::size_t Array::size() const
|
||||
}
|
||||
|
||||
|
||||
inline bool Array::empty() const
|
||||
{
|
||||
return _values.empty();
|
||||
}
|
||||
|
||||
|
||||
inline bool Array::isArray(unsigned int index) const
|
||||
{
|
||||
Dynamic::Var value = get(index);
|
||||
|
@ -791,9 +791,11 @@ void JSONTest::testEmptyArray()
|
||||
|
||||
Poco::JSON::Array::Ptr array = result.extract<Poco::JSON::Array::Ptr>();
|
||||
assertTrue (array->size() == 0);
|
||||
assertTrue (array->empty());
|
||||
|
||||
Poco::Dynamic::Array da = *array;
|
||||
assertTrue (da.size() == 0);
|
||||
assertTrue (da.empty());
|
||||
}
|
||||
|
||||
|
||||
@ -817,10 +819,12 @@ void JSONTest::testNestedArray()
|
||||
|
||||
Poco::JSON::Array::Ptr array = result.extract<Poco::JSON::Array::Ptr>();
|
||||
assertTrue (array->size() == 1);
|
||||
assertTrue (!array->empty());
|
||||
|
||||
Poco::Dynamic::Array da = *array;
|
||||
assertTrue (da.size() == 1);
|
||||
assertTrue (da[0].size() == 1);
|
||||
assertTrue (!da.empty());
|
||||
assertTrue (da[0][0].size() == 1);
|
||||
assertTrue (da[0][0][0].size() == 0);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user