mirror of
https://github.com/open-source-parsers/jsoncpp.git
synced 2025-10-15 15:16:47 +02:00
Fix Value::resize to fill all array elements (#1265)
* Fix Value::resize to fill all array elements Fixes #1264
This commit is contained in:
@@ -12,6 +12,7 @@
|
||||
|
||||
#include "fuzz.h"
|
||||
#include "jsontest.h"
|
||||
#include <algorithm>
|
||||
#include <cmath>
|
||||
#include <cstring>
|
||||
#include <functional>
|
||||
@@ -24,6 +25,7 @@
|
||||
#include <memory>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
using CharReaderPtr = std::unique_ptr<Json::CharReader>;
|
||||
|
||||
@@ -347,6 +349,17 @@ JSONTEST_FIXTURE_LOCAL(ValueTest, resizeArray) {
|
||||
JSONTEST_ASSERT_EQUAL(array.size(), 0);
|
||||
}
|
||||
}
|
||||
|
||||
JSONTEST_FIXTURE_LOCAL(ValueTest, resizePopulatesAllMissingElements) {
|
||||
int n = 10;
|
||||
Json::Value v;
|
||||
v.resize(n);
|
||||
JSONTEST_ASSERT_EQUAL(n, v.size());
|
||||
JSONTEST_ASSERT_EQUAL(n, std::distance(v.begin(), v.end()));
|
||||
for (const Json::Value& e : v)
|
||||
JSONTEST_ASSERT_EQUAL(e, Json::Value{});
|
||||
}
|
||||
|
||||
JSONTEST_FIXTURE_LOCAL(ValueTest, getArrayValue) {
|
||||
Json::Value array;
|
||||
for (Json::ArrayIndex i = 0; i < 5; i++)
|
||||
|
Reference in New Issue
Block a user