2
1
mirror of https://github.com/qpdf/qpdf.git synced 2024-12-22 19:08:59 +00:00
qpdf/libtests/obj_table.cc

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

59 lines
1.1 KiB
C++
Raw Normal View History

#include <qpdf/ObjTable.hh>
struct Test
{
2024-08-31 19:15:19 +00:00
Test() = default;
Test(int value) :
value(value)
{
}
int value{0};
};
class Table: public ObjTable<Test>
{
public:
Table()
{
2024-08-31 13:29:15 +00:00
resize(5);
}
void
test()
{
for (int i = 0; i < 10; ++i) {
(*this)[i].value = 2 * i;
(*this)[1000 + i].value = 2 * (1000 + i);
}
2024-08-31 13:29:15 +00:00
for (int i: {50, 60, 70, 98, 99, 100, 101, 150, 198, 199, 200, 201}) {
(*this)[i].value = 2 * i;
}
resize(100);
2024-08-31 19:15:19 +00:00
for (int i: {1, 99, 100, 105, 110, 120, 205, 206, 207, 210}) {
2024-08-31 13:29:15 +00:00
(*this)[i].value = 3 * i;
}
resize(200);
2024-08-31 19:15:19 +00:00
for (int i = 1; i < 10; ++i) {
emplace_back(i);
}
forEach([](auto i, auto const& item) -> void {
2024-08-31 13:29:15 +00:00
if (item.value) {
std::cout << std::to_string(i) << " : " << std::to_string(item.value) << "\n";
}
});
std::cout << "2000 : " << std::to_string((*this)[2000].value) << "\n";
}
};
int
main()
{
Table().test();
std::cout << "object table tests done\n";
return 0;
}