From: Ivan Maidanski Date: Wed, 21 Nov 2018 21:32:50 +0000 (+0300) Subject: Fix test_cpp assertion violation in find-leak mode X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=eb50313129c8a053ba5ebc491be828a2b10100d9;p=gc 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. --- diff --git a/tests/test_cpp.cc b/tests/test_cpp.cc index b7f76256..db3de022 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); }