Commit 73023bcb5d0705a8e914ae7586aa2f417a82d9a7
1 parent
182c2480
Change sparse_array test to test sparse QPDF_Arrays
Showing
1 changed file
with
13 additions
and
10 deletions
libtests/sparse_array.cc
| 1 | 1 | #include <qpdf/assert_test.h> |
| 2 | 2 | |
| 3 | -#include <qpdf/SparseOHArray.hh> | |
| 3 | +#include <qpdf/QPDFObjectHandle.hh> | |
| 4 | +#include <qpdf/QPDF_Array.hh> | |
| 4 | 5 | #include <iostream> |
| 5 | 6 | |
| 6 | 7 | int |
| 7 | 8 | main() |
| 8 | 9 | { |
| 9 | - SparseOHArray a; | |
| 10 | + auto obj = QPDF_Array::create({}, true); | |
| 11 | + QPDF_Array& a = *obj->as<QPDF_Array>(); | |
| 12 | + | |
| 10 | 13 | assert(a.size() == 0); |
| 11 | 14 | |
| 12 | - a.append(QPDFObjectHandle::parse("1")); | |
| 13 | - a.append(QPDFObjectHandle::parse("(potato)")); | |
| 14 | - a.append(QPDFObjectHandle::parse("null")); | |
| 15 | - a.append(QPDFObjectHandle::parse("null")); | |
| 16 | - a.append(QPDFObjectHandle::parse("/Quack")); | |
| 15 | + a.push_back(QPDFObjectHandle::parse("1")); | |
| 16 | + a.push_back(QPDFObjectHandle::parse("(potato)")); | |
| 17 | + a.push_back(QPDFObjectHandle::parse("null")); | |
| 18 | + a.push_back(QPDFObjectHandle::parse("null")); | |
| 19 | + a.push_back(QPDFObjectHandle::parse("/Quack")); | |
| 17 | 20 | assert(a.size() == 5); |
| 18 | 21 | assert(a.at(0).isInteger() && (a.at(0).getIntValue() == 1)); |
| 19 | 22 | assert(a.at(1).isString() && (a.at(1).getStringValue() == "potato")); |
| ... | ... | @@ -60,20 +63,20 @@ main() |
| 60 | 63 | a.setAt(4, QPDFObjectHandle::newNull()); |
| 61 | 64 | assert(a.at(4).isNull()); |
| 62 | 65 | |
| 63 | - a.remove_last(); | |
| 66 | + a.erase(a.size() - 1); | |
| 64 | 67 | assert(a.size() == 5); |
| 65 | 68 | assert(a.at(0).isName() && (a.at(0).getName() == "/First")); |
| 66 | 69 | assert(a.at(1).isInteger() && (a.at(1).getIntValue() == 1)); |
| 67 | 70 | assert(a.at(3).isName() && (a.at(3).getName() == "/Third")); |
| 68 | 71 | assert(a.at(4).isNull()); |
| 69 | 72 | |
| 70 | - a.remove_last(); | |
| 73 | + a.erase(a.size() - 1); | |
| 71 | 74 | assert(a.size() == 4); |
| 72 | 75 | assert(a.at(0).isName() && (a.at(0).getName() == "/First")); |
| 73 | 76 | assert(a.at(1).isInteger() && (a.at(1).getIntValue() == 1)); |
| 74 | 77 | assert(a.at(3).isName() && (a.at(3).getName() == "/Third")); |
| 75 | 78 | |
| 76 | - a.remove_last(); | |
| 79 | + a.erase(a.size() - 1); | |
| 77 | 80 | assert(a.size() == 3); |
| 78 | 81 | assert(a.at(0).isName() && (a.at(0).getName() == "/First")); |
| 79 | 82 | assert(a.at(1).isInteger() && (a.at(1).getIntValue() == 1)); | ... | ... |