From 8c69f8495de1791decff3ae37f1da2383415c144 Mon Sep 17 00:00:00 2001 From: Jay Berkenbilt Date: Fri, 30 Aug 2019 11:58:33 -0400 Subject: [PATCH] Add getRefcount to PointerHolder test --- libtests/pointer_holder.cc | 4 ++++ libtests/qtest/ph/ph.out | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/libtests/pointer_holder.cc b/libtests/pointer_holder.cc index c255df5a..05ab4cfa 100644 --- a/libtests/pointer_holder.cc +++ b/libtests/pointer_holder.cc @@ -63,10 +63,14 @@ int main(int argc, char* argv[]) std::cout << "hello" << std::endl; Object* o1 = new Object; ObjectHolder oh1(o1); + std::cout << "oh1 refcount = " << oh1.getRefcount() << std::endl; ObjectHolder oh2(oh1); + std::cout << "oh1 refcount = " << oh1.getRefcount() << std::endl; + std::cout << "oh2 refcount = " << oh2.getRefcount() << std::endl; ObjectHolder oh3(new Object); ObjectHolder oh4; ObjectHolder oh5; + std::cout << "oh5 refcount = " << oh5.getRefcount() << std::endl; if (oh4 == oh5) { std::cout << "nulls equal" << std::endl; diff --git a/libtests/qtest/ph/ph.out b/libtests/qtest/ph/ph.out index 1326e489..2f82bd8b 100644 --- a/libtests/qtest/ph/ph.out +++ b/libtests/qtest/ph/ph.out @@ -1,6 +1,10 @@ hello created Object, id 1 +oh1 refcount = 1 +oh1 refcount = 2 +oh2 refcount = 2 created Object, id 2 +oh5 refcount = 1 nulls equal destroyed Object, id 2 equal okay