aboutsummaryrefslogtreecommitdiffstats
path: root/libtests/qutil.cc
diff options
context:
space:
mode:
authorJay Berkenbilt <ejb@ql.org>2022-08-31 18:49:29 +0200
committerJay Berkenbilt <ejb@ql.org>2022-08-31 20:47:27 +0200
commit0a54247652e49ce384dcf0d8df078201aa106089 (patch)
treed1609cab26a6b66c33dfb88dd43811894ec219dc /libtests/qutil.cc
parent0adfd74f8b5dc96091cd0b4251b08401f54df2ed (diff)
downloadqpdf-0a54247652e49ce384dcf0d8df078201aa106089.tar.zst
Add QUtil::get_max_memory_usage for testing
Diffstat (limited to 'libtests/qutil.cc')
-rw-r--r--libtests/qutil.cc14
1 files changed, 14 insertions, 0 deletions
diff --git a/libtests/qutil.cc b/libtests/qutil.cc
index 995a7599..82c2dd1a 100644
--- a/libtests/qutil.cc
+++ b/libtests/qutil.cc
@@ -703,6 +703,18 @@ is_long_long_test()
std::cout << "done" << std::endl;
}
+void
+memory_usage_test()
+{
+ auto u1 = QUtil::get_max_memory_usage();
+ if (u1 > 0) {
+ auto x = QUtil::make_shared_array<int>(10 << 20);
+ auto u2 = QUtil::get_max_memory_usage();
+ assert(u2 > u1);
+ }
+ std::cout << "memory usage okay" << std::endl;
+}
+
int
main(int argc, char* argv[])
{
@@ -739,6 +751,8 @@ main(int argc, char* argv[])
timestamp_test();
std::cout << "---- is_long_long" << std::endl;
is_long_long_test();
+ std::cout << "---- memory usage" << std::endl;
+ memory_usage_test();
} catch (std::exception& e) {
std::cout << "unexpected exception: " << e.what() << std::endl;
}