diff --git a/libtests/sparse_array.cc b/libtests/sparse_array.cc index 62410399..a970b199 100644 --- a/libtests/sparse_array.cc +++ b/libtests/sparse_array.cc @@ -1,19 +1,22 @@ #include -#include +#include +#include #include int main() { - SparseOHArray a; + auto obj = QPDF_Array::create({}, true); + QPDF_Array& a = *obj->as(); + assert(a.size() == 0); - a.append(QPDFObjectHandle::parse("1")); - a.append(QPDFObjectHandle::parse("(potato)")); - a.append(QPDFObjectHandle::parse("null")); - a.append(QPDFObjectHandle::parse("null")); - a.append(QPDFObjectHandle::parse("/Quack")); + a.push_back(QPDFObjectHandle::parse("1")); + a.push_back(QPDFObjectHandle::parse("(potato)")); + a.push_back(QPDFObjectHandle::parse("null")); + a.push_back(QPDFObjectHandle::parse("null")); + a.push_back(QPDFObjectHandle::parse("/Quack")); assert(a.size() == 5); assert(a.at(0).isInteger() && (a.at(0).getIntValue() == 1)); assert(a.at(1).isString() && (a.at(1).getStringValue() == "potato")); @@ -60,20 +63,20 @@ main() a.setAt(4, QPDFObjectHandle::newNull()); assert(a.at(4).isNull()); - a.remove_last(); + a.erase(a.size() - 1); assert(a.size() == 5); assert(a.at(0).isName() && (a.at(0).getName() == "/First")); assert(a.at(1).isInteger() && (a.at(1).getIntValue() == 1)); assert(a.at(3).isName() && (a.at(3).getName() == "/Third")); assert(a.at(4).isNull()); - a.remove_last(); + a.erase(a.size() - 1); assert(a.size() == 4); assert(a.at(0).isName() && (a.at(0).getName() == "/First")); assert(a.at(1).isInteger() && (a.at(1).getIntValue() == 1)); assert(a.at(3).isName() && (a.at(3).getName() == "/Third")); - a.remove_last(); + a.erase(a.size() - 1); assert(a.size() == 3); assert(a.at(0).isName() && (a.at(0).getName() == "/First")); assert(a.at(1).isInteger() && (a.at(1).getIntValue() == 1));