From eb50313129c8a053ba5ebc491be828a2b10100d9 Mon Sep 17 00:00:00 2001 From: Ivan Maidanski Date: Thu, 22 Nov 2018 00:32:50 +0300 Subject: [PATCH] Fix test_cpp assertion violation in find-leak mode * tests/test_cpp.cc (C.Test, D.Test, F.Test): Do not fail on nFreed>=0.8*nAllocated[F] assertion violation if GC_get_find_leak() returns non-zero; replace .8*nAllocated[F] to (nAllocated[F]/5)*4 to avoid floating-point operations. --- tests/test_cpp.cc | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tests/test_cpp.cc b/tests/test_cpp.cc index b7f7625..db3de02 100644 --- a/tests/test_cpp.cc +++ b/tests/test_cpp.cc @@ -158,7 +158,9 @@ class C: public GC_NS_QUALIFY(gc_cleanup), public A { public: left = right = 0; level = -123456;} static void Test() { - my_assert( nFreed <= nAllocated && nFreed >= .8 * nAllocated );} + my_assert(nFreed <= nAllocated); + my_assert(nFreed >= (nAllocated / 5) * 4 || GC_get_find_leak()); + } static int nFreed; static int nAllocated; @@ -181,7 +183,8 @@ class D: public GC_NS_QUALIFY(gc) { public: nFreed++; my_assert( (GC_word)self->i == (GC_word)data );} static void Test() { - my_assert( nFreed >= .8 * nAllocated );} + my_assert(nFreed >= (nAllocated / 5) * 4 || GC_get_find_leak()); + } int i; static int nFreed; @@ -219,7 +222,7 @@ class F: public E {public: } static void Test() { - my_assert(nFreedF >= .8 * nAllocatedF); + my_assert(nFreedF >= (nAllocatedF / 5) * 4 || GC_get_find_leak()); my_assert(2 * nFreedF == nFreed); } -- 2.7.4