]> granicus.if.org Git - gc/commitdiff
Fix test_cpp assertion violation in find-leak mode
authorIvan Maidanski <ivmai@mail.ru>
Wed, 21 Nov 2018 21:32:50 +0000 (00:32 +0300)
committerIvan Maidanski <ivmai@mail.ru>
Wed, 21 Nov 2018 21:53:33 +0000 (00:53 +0300)
* 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

index b7f76256e0eb76d3b9715ff57ef657c4d0aeb314..db3de0225798dd601c5845af48f8816cf1288bcb 100644 (file)
@@ -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);
     }