瀏覽代碼

HPCC-12662 Further fix to IBitSet::incl()

And add a unittest.

Signed-off-by: Jake Smith <jake.smith@lexisnexis.com>
Jake Smith 10 年之前
父節點
當前提交
049142c0bf
共有 2 個文件被更改,包括 28 次插入0 次删除
  1. 16 0
      system/jlib/jset.cpp
  2. 12 0
      testing/unittests/jlibtests.cpp

+ 16 - 0
system/jlib/jset.cpp

@@ -196,6 +196,22 @@ protected:
                 addBitSet(0);
                 ++n;
             }
+            if (j>0)
+            {
+                bits_t m = 0;
+                bits_t t = ((bits_t)1)<<j;
+                for (;j<BitsPerItem;j++)
+                {
+                    m |= t;
+                    if (--nb==0)
+                        break;
+                    t <<= 1;
+                }
+                addBitSet(m);
+            }
+            if (nb==0)
+                return;
+            j = 0;
         }
         else
         {

+ 12 - 0
testing/unittests/jlibtests.cpp

@@ -130,6 +130,18 @@ protected:
             ASSERT(match == i);
             ASSERT(bs->test(i) == clearValue);
         }
+        bs->reset();
+        if (initial)
+        {
+            bs->incl(start, end);
+            bs->excl(start+5, end-5);
+        }
+        else
+            bs->incl(start+5, end-5);
+        unsigned inclStart = bs->scan(start, setValue);
+        ASSERT((start+5) == inclStart);
+        unsigned inclEnd = bs->scan(start+5, clearValue);
+        ASSERT((end-5) == (inclEnd-1));
     }
 
     void testSet(bool initial)