From 601b2f1a6b18d7273316403904929fa783199d23 Mon Sep 17 00:00:00 2001
From: Roman Tsisyk <roman@tsisyk.com>
Date: Fri, 8 Feb 2013 13:09:59 +0400
Subject: [PATCH] BitsetIndex: lua tests

---
 test/big/bitset.lua      |   39 +
 test/big/bitset.result   | 1526 ++++++++++++++++++++++++++++++++++++++
 test/big/bitset.test     |  108 +++
 test/big/iterator.lua    |   27 -
 test/big/iterator.result |    4 +-
 test/big/iterator.test   |    6 +-
 test/big/tarantool.cfg   |   12 +
 test/big/utils.lua       |   82 ++
 8 files changed, 1772 insertions(+), 32 deletions(-)
 create mode 100644 test/big/bitset.lua
 create mode 100644 test/big/bitset.result
 create mode 100644 test/big/bitset.test
 delete mode 100644 test/big/iterator.lua
 create mode 100644 test/big/utils.lua

diff --git a/test/big/bitset.lua b/test/big/bitset.lua
new file mode 100644
index 0000000000..469c8c72ea
--- /dev/null
+++ b/test/big/bitset.lua
@@ -0,0 +1,39 @@
+local SPACE_NO = 23
+local INDEX_NO = 1
+
+function fill(...)
+	local nums = table.generate(arithmetic(...));
+	table.shuffle(nums);
+	for _k, v in ipairs(nums) do
+		box.insert(SPACE_NO, v, v);
+	end
+end
+
+function delete(...)
+	local nums = table.generate(arithmetic(...));
+	table.shuffle(nums);
+	for _k, v in ipairs(nums) do
+		box.delete(SPACE_NO, v);
+	end
+end
+
+function clear()
+	box.space[SPACE_NO]:truncate()
+end
+
+function dump(...)
+	iterate(SPACE_NO, INDEX_NO, 1, 2, ...);
+end
+
+function test_insert_delete(n)
+	local t = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53,
+		59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127}
+
+	table.shuffle(t);
+
+	clear();
+	fill(1, n);
+
+	for _, v in ipairs(t) do delete(v, n / v) end
+	dump(box.index.BITS_ALL)
+end
diff --git a/test/big/bitset.result b/test/big/bitset.result
new file mode 100644
index 0000000000..e0bf2c192b
--- /dev/null
+++ b/test/big/bitset.result
@@ -0,0 +1,1526 @@
+lua dofile('utils.lua')
+---
+...
+lua dofile('bitset.lua')
+---
+...
+
+#-----------------------------------------------------------------------------#
+# BitsetIndex: insert/delete
+#-----------------------------------------------------------------------------#
+
+lua test_insert_delete(128)
+---
+sorted output
+$       1$
+...
+
+#-----------------------------------------------------------------------------#
+# BitsetIndex: ALL
+#-----------------------------------------------------------------------------#
+
+lua clear()
+---
+...
+lua fill(1, 128)
+---
+...
+lua dump(box.index.BITS_ALL)
+---
+sorted output
+$       1$
+$       2$
+$       3$
+$       4$
+$       5$
+$       6$
+$       7$
+$       8$
+$       9$
+$      10$
+$      11$
+$      12$
+$      13$
+$      14$
+$      15$
+$      16$
+$      17$
+$      18$
+$      19$
+$      20$
+$      21$
+$      22$
+$      23$
+$      24$
+$      25$
+$      26$
+$      27$
+$      28$
+$      29$
+$      30$
+$      31$
+$      32$
+$      33$
+$      34$
+$      35$
+$      36$
+$      37$
+$      38$
+$      39$
+$      40$
+$      41$
+$      42$
+$      43$
+$      44$
+$      45$
+$      46$
+$      47$
+$      48$
+$      49$
+$      50$
+$      51$
+$      52$
+$      53$
+$      54$
+$      55$
+$      56$
+$      57$
+$      58$
+$      59$
+$      60$
+$      61$
+$      62$
+$      63$
+$      64$
+$      65$
+$      66$
+$      67$
+$      68$
+$      69$
+$      70$
+$      71$
+$      72$
+$      73$
+$      74$
+$      75$
+$      76$
+$      77$
+$      78$
+$      79$
+$      80$
+$      81$
+$      82$
+$      83$
+$      84$
+$      85$
+$      86$
+$      87$
+$      88$
+$      89$
+$      90$
+$      91$
+$      92$
+$      93$
+$      94$
+$      95$
+$      96$
+$      97$
+$      98$
+$      99$
+$     100$
+$     101$
+$     102$
+$     103$
+$     104$
+$     105$
+$     106$
+$     107$
+$     108$
+$     109$
+$     110$
+$     111$
+$     112$
+$     113$
+$     114$
+$     115$
+$     116$
+$     117$
+$     118$
+$     119$
+$     120$
+$     121$
+$     122$
+$     123$
+$     124$
+$     125$
+$     126$
+$     127$
+$     128$
+...
+
+#-----------------------------------------------------------------------------#
+# BitsetIndex: BITS_ALL_SET (single bit)
+#-----------------------------------------------------------------------------#
+
+lua dump(box.index.BITS_ALL_SET, 0)
+---
+sorted output
+...
+lua dump(box.index.BITS_ALL_SET, 1)
+---
+sorted output
+$       1$
+$       3$
+$       5$
+$       7$
+$       9$
+$      11$
+$      13$
+$      15$
+$      17$
+$      19$
+$      21$
+$      23$
+$      25$
+$      27$
+$      29$
+$      31$
+$      33$
+$      35$
+$      37$
+$      39$
+$      41$
+$      43$
+$      45$
+$      47$
+$      49$
+$      51$
+$      53$
+$      55$
+$      57$
+$      59$
+$      61$
+$      63$
+$      65$
+$      67$
+$      69$
+$      71$
+$      73$
+$      75$
+$      77$
+$      79$
+$      81$
+$      83$
+$      85$
+$      87$
+$      89$
+$      91$
+$      93$
+$      95$
+$      97$
+$      99$
+$     101$
+$     103$
+$     105$
+$     107$
+$     109$
+$     111$
+$     113$
+$     115$
+$     117$
+$     119$
+$     121$
+$     123$
+$     125$
+$     127$
+...
+lua dump(box.index.BITS_ALL_SET, 2)
+---
+sorted output
+$       2$
+$       3$
+$       6$
+$       7$
+$      10$
+$      11$
+$      14$
+$      15$
+$      18$
+$      19$
+$      22$
+$      23$
+$      26$
+$      27$
+$      30$
+$      31$
+$      34$
+$      35$
+$      38$
+$      39$
+$      42$
+$      43$
+$      46$
+$      47$
+$      50$
+$      51$
+$      54$
+$      55$
+$      58$
+$      59$
+$      62$
+$      63$
+$      66$
+$      67$
+$      70$
+$      71$
+$      74$
+$      75$
+$      78$
+$      79$
+$      82$
+$      83$
+$      86$
+$      87$
+$      90$
+$      91$
+$      94$
+$      95$
+$      98$
+$      99$
+$     102$
+$     103$
+$     106$
+$     107$
+$     110$
+$     111$
+$     114$
+$     115$
+$     118$
+$     119$
+$     122$
+$     123$
+$     126$
+$     127$
+...
+lua dump(box.index.BITS_ALL_SET, 8)
+---
+sorted output
+$       8$
+$       9$
+$      10$
+$      11$
+$      12$
+$      13$
+$      14$
+$      15$
+$      24$
+$      25$
+$      26$
+$      27$
+$      28$
+$      29$
+$      30$
+$      31$
+$      40$
+$      41$
+$      42$
+$      43$
+$      44$
+$      45$
+$      46$
+$      47$
+$      56$
+$      57$
+$      58$
+$      59$
+$      60$
+$      61$
+$      62$
+$      63$
+$      72$
+$      73$
+$      74$
+$      75$
+$      76$
+$      77$
+$      78$
+$      79$
+$      88$
+$      89$
+$      90$
+$      91$
+$      92$
+$      93$
+$      94$
+$      95$
+$     104$
+$     105$
+$     106$
+$     107$
+$     108$
+$     109$
+$     110$
+$     111$
+$     120$
+$     121$
+$     122$
+$     123$
+$     124$
+$     125$
+$     126$
+$     127$
+...
+lua dump(box.index.BITS_ALL_SET, 1073741824)
+---
+sorted output
+...
+lua dump(box.index.BITS_ALL_SET, 2147483648)
+---
+sorted output
+...
+lua dump(box.index.BITS_ALL_SET, 4294967296)
+---
+sorted output
+...
+
+#-----------------------------------------------------------------------------#
+# BitsetIndex: BITS_ALL_SET (multiple bit)
+#-----------------------------------------------------------------------------#
+
+lua dump(box.index.BITS_ALL_SET, 3)
+---
+sorted output
+$       3$
+$       7$
+$      11$
+$      15$
+$      19$
+$      23$
+$      27$
+$      31$
+$      35$
+$      39$
+$      43$
+$      47$
+$      51$
+$      55$
+$      59$
+$      63$
+$      67$
+$      71$
+$      75$
+$      79$
+$      83$
+$      87$
+$      91$
+$      95$
+$      99$
+$     103$
+$     107$
+$     111$
+$     115$
+$     119$
+$     123$
+$     127$
+...
+lua dump(box.index.BITS_ALL_SET, 7)
+---
+sorted output
+$       7$
+$      15$
+$      23$
+$      31$
+$      39$
+$      47$
+$      55$
+$      63$
+$      71$
+$      79$
+$      87$
+$      95$
+$     103$
+$     111$
+$     119$
+$     127$
+...
+lua dump(box.index.BITS_ALL_SET, 31)
+---
+sorted output
+$      31$
+$      63$
+$      95$
+$     127$
+...
+lua dump(box.index.BITS_ALL_SET, 5)
+---
+sorted output
+$       5$
+$       7$
+$      13$
+$      15$
+$      21$
+$      23$
+$      29$
+$      31$
+$      37$
+$      39$
+$      45$
+$      47$
+$      53$
+$      55$
+$      61$
+$      63$
+$      69$
+$      71$
+$      77$
+$      79$
+$      85$
+$      87$
+$      93$
+$      95$
+$     101$
+$     103$
+$     109$
+$     111$
+$     117$
+$     119$
+$     125$
+$     127$
+...
+lua dump(box.index.BITS_ALL_SET, 10)
+---
+sorted output
+$      10$
+$      11$
+$      14$
+$      15$
+$      26$
+$      27$
+$      30$
+$      31$
+$      42$
+$      43$
+$      46$
+$      47$
+$      58$
+$      59$
+$      62$
+$      63$
+$      74$
+$      75$
+$      78$
+$      79$
+$      90$
+$      91$
+$      94$
+$      95$
+$     106$
+$     107$
+$     110$
+$     111$
+$     122$
+$     123$
+$     126$
+$     127$
+...
+lua dump(box.index.BITS_ALL_SET, 27)
+---
+sorted output
+$      27$
+$      31$
+$      59$
+$      63$
+$      91$
+$      95$
+$     123$
+$     127$
+...
+lua dump(box.index.BITS_ALL_SET, 341)
+---
+sorted output
+...
+lua dump(box.index.BITS_ALL_SET, 2147483649)
+---
+sorted output
+...
+lua dump(box.index.BITS_ALL_SET, 4294967295)
+---
+sorted output
+...
+
+#-----------------------------------------------------------------------------#
+# BitsetIndex: BITS_ALL_NOT_SET (single bit)
+#-----------------------------------------------------------------------------#
+
+lua dump(box.index.BITS_ALL_NOT_SET, 0)
+---
+sorted output
+$       1$
+$       2$
+$       3$
+$       4$
+$       5$
+$       6$
+$       7$
+$       8$
+$       9$
+$      10$
+$      11$
+$      12$
+$      13$
+$      14$
+$      15$
+$      16$
+$      17$
+$      18$
+$      19$
+$      20$
+$      21$
+$      22$
+$      23$
+$      24$
+$      25$
+$      26$
+$      27$
+$      28$
+$      29$
+$      30$
+$      31$
+$      32$
+$      33$
+$      34$
+$      35$
+$      36$
+$      37$
+$      38$
+$      39$
+$      40$
+$      41$
+$      42$
+$      43$
+$      44$
+$      45$
+$      46$
+$      47$
+$      48$
+$      49$
+$      50$
+$      51$
+$      52$
+$      53$
+$      54$
+$      55$
+$      56$
+$      57$
+$      58$
+$      59$
+$      60$
+$      61$
+$      62$
+$      63$
+$      64$
+$      65$
+$      66$
+$      67$
+$      68$
+$      69$
+$      70$
+$      71$
+$      72$
+$      73$
+$      74$
+$      75$
+$      76$
+$      77$
+$      78$
+$      79$
+$      80$
+$      81$
+$      82$
+$      83$
+$      84$
+$      85$
+$      86$
+$      87$
+$      88$
+$      89$
+$      90$
+$      91$
+$      92$
+$      93$
+$      94$
+$      95$
+$      96$
+$      97$
+$      98$
+$      99$
+$     100$
+$     101$
+$     102$
+$     103$
+$     104$
+$     105$
+$     106$
+$     107$
+$     108$
+$     109$
+$     110$
+$     111$
+$     112$
+$     113$
+$     114$
+$     115$
+$     116$
+$     117$
+$     118$
+$     119$
+$     120$
+$     121$
+$     122$
+$     123$
+$     124$
+$     125$
+$     126$
+$     127$
+$     128$
+...
+lua dump(box.index.BITS_ALL_NOT_SET, 2)
+---
+sorted output
+$       1$
+$       4$
+$       5$
+$       8$
+$       9$
+$      12$
+$      13$
+$      16$
+$      17$
+$      20$
+$      21$
+$      24$
+$      25$
+$      28$
+$      29$
+$      32$
+$      33$
+$      36$
+$      37$
+$      40$
+$      41$
+$      44$
+$      45$
+$      48$
+$      49$
+$      52$
+$      53$
+$      56$
+$      57$
+$      60$
+$      61$
+$      64$
+$      65$
+$      68$
+$      69$
+$      72$
+$      73$
+$      76$
+$      77$
+$      80$
+$      81$
+$      84$
+$      85$
+$      88$
+$      89$
+$      92$
+$      93$
+$      96$
+$      97$
+$     100$
+$     101$
+$     104$
+$     105$
+$     108$
+$     109$
+$     112$
+$     113$
+$     116$
+$     117$
+$     120$
+$     121$
+$     124$
+$     125$
+$     128$
+...
+lua dump(box.index.BITS_ALL_NOT_SET, 8)
+---
+sorted output
+$       1$
+$       2$
+$       3$
+$       4$
+$       5$
+$       6$
+$       7$
+$      16$
+$      17$
+$      18$
+$      19$
+$      20$
+$      21$
+$      22$
+$      23$
+$      32$
+$      33$
+$      34$
+$      35$
+$      36$
+$      37$
+$      38$
+$      39$
+$      48$
+$      49$
+$      50$
+$      51$
+$      52$
+$      53$
+$      54$
+$      55$
+$      64$
+$      65$
+$      66$
+$      67$
+$      68$
+$      69$
+$      70$
+$      71$
+$      80$
+$      81$
+$      82$
+$      83$
+$      84$
+$      85$
+$      86$
+$      87$
+$      96$
+$      97$
+$      98$
+$      99$
+$     100$
+$     101$
+$     102$
+$     103$
+$     112$
+$     113$
+$     114$
+$     115$
+$     116$
+$     117$
+$     118$
+$     119$
+$     128$
+...
+lua dump(box.index.BITS_ALL_NOT_SET, 4294967296)
+---
+sorted output
+$       1$
+$       2$
+$       3$
+$       4$
+$       5$
+$       6$
+$       7$
+$       8$
+$       9$
+$      10$
+$      11$
+$      12$
+$      13$
+$      14$
+$      15$
+$      16$
+$      17$
+$      18$
+$      19$
+$      20$
+$      21$
+$      22$
+$      23$
+$      24$
+$      25$
+$      26$
+$      27$
+$      28$
+$      29$
+$      30$
+$      31$
+$      32$
+$      33$
+$      34$
+$      35$
+$      36$
+$      37$
+$      38$
+$      39$
+$      40$
+$      41$
+$      42$
+$      43$
+$      44$
+$      45$
+$      46$
+$      47$
+$      48$
+$      49$
+$      50$
+$      51$
+$      52$
+$      53$
+$      54$
+$      55$
+$      56$
+$      57$
+$      58$
+$      59$
+$      60$
+$      61$
+$      62$
+$      63$
+$      64$
+$      65$
+$      66$
+$      67$
+$      68$
+$      69$
+$      70$
+$      71$
+$      72$
+$      73$
+$      74$
+$      75$
+$      76$
+$      77$
+$      78$
+$      79$
+$      80$
+$      81$
+$      82$
+$      83$
+$      84$
+$      85$
+$      86$
+$      87$
+$      88$
+$      89$
+$      90$
+$      91$
+$      92$
+$      93$
+$      94$
+$      95$
+$      96$
+$      97$
+$      98$
+$      99$
+$     100$
+$     101$
+$     102$
+$     103$
+$     104$
+$     105$
+$     106$
+$     107$
+$     108$
+$     109$
+$     110$
+$     111$
+$     112$
+$     113$
+$     114$
+$     115$
+$     116$
+$     117$
+$     118$
+$     119$
+$     120$
+$     121$
+$     122$
+$     123$
+$     124$
+$     125$
+$     126$
+$     127$
+$     128$
+...
+
+#-----------------------------------------------------------------------------#
+# BitsetIndex: BITS_ALL_NOT_SET (multiple bit)
+#-----------------------------------------------------------------------------#
+
+lua dump(box.index.BITS_ALL_NOT_SET, 3)
+---
+sorted output
+$       4$
+$       8$
+$      12$
+$      16$
+$      20$
+$      24$
+$      28$
+$      32$
+$      36$
+$      40$
+$      44$
+$      48$
+$      52$
+$      56$
+$      60$
+$      64$
+$      68$
+$      72$
+$      76$
+$      80$
+$      84$
+$      88$
+$      92$
+$      96$
+$     100$
+$     104$
+$     108$
+$     112$
+$     116$
+$     120$
+$     124$
+$     128$
+...
+lua dump(box.index.BITS_ALL_NOT_SET, 7)
+---
+sorted output
+$       8$
+$      16$
+$      24$
+$      32$
+$      40$
+$      48$
+$      56$
+$      64$
+$      72$
+$      80$
+$      88$
+$      96$
+$     104$
+$     112$
+$     120$
+$     128$
+...
+lua dump(box.index.BITS_ALL_NOT_SET, 10)
+---
+sorted output
+$       1$
+$       4$
+$       5$
+$      16$
+$      17$
+$      20$
+$      21$
+$      32$
+$      33$
+$      36$
+$      37$
+$      48$
+$      49$
+$      52$
+$      53$
+$      64$
+$      65$
+$      68$
+$      69$
+$      80$
+$      81$
+$      84$
+$      85$
+$      96$
+$      97$
+$     100$
+$     101$
+$     112$
+$     113$
+$     116$
+$     117$
+$     128$
+...
+lua dump(box.index.BITS_ALL_NOT_SET, 27)
+---
+sorted output
+$       4$
+$      32$
+$      36$
+$      64$
+$      68$
+$      96$
+$     100$
+$     128$
+...
+lua dump(box.index.BITS_ALL_NOT_SET, 85)
+---
+sorted output
+$       2$
+$       8$
+$      10$
+$      32$
+$      34$
+$      40$
+$      42$
+$     128$
+...
+lua dump(box.index.BITS_ALL_NOT_SET, 4294967295)
+---
+sorted output
+...
+
+#-----------------------------------------------------------------------------#
+# BitsetIndex: BITS_ANY_SET (single bit)
+#-----------------------------------------------------------------------------#
+
+lua dump(box.index.BITS_ANY_SET, 0)
+---
+sorted output
+...
+lua dump(box.index.BITS_ANY_SET, 16)
+---
+sorted output
+$      16$
+$      17$
+$      18$
+$      19$
+$      20$
+$      21$
+$      22$
+$      23$
+$      24$
+$      25$
+$      26$
+$      27$
+$      28$
+$      29$
+$      30$
+$      31$
+$      48$
+$      49$
+$      50$
+$      51$
+$      52$
+$      53$
+$      54$
+$      55$
+$      56$
+$      57$
+$      58$
+$      59$
+$      60$
+$      61$
+$      62$
+$      63$
+$      80$
+$      81$
+$      82$
+$      83$
+$      84$
+$      85$
+$      86$
+$      87$
+$      88$
+$      89$
+$      90$
+$      91$
+$      92$
+$      93$
+$      94$
+$      95$
+$     112$
+$     113$
+$     114$
+$     115$
+$     116$
+$     117$
+$     118$
+$     119$
+$     120$
+$     121$
+$     122$
+$     123$
+$     124$
+$     125$
+$     126$
+$     127$
+...
+lua dump(box.index.BITS_ANY_SET, 128)
+---
+sorted output
+$     128$
+...
+lua dump(box.index.BITS_ANY_SET, 4294967296)
+---
+sorted output
+...
+
+#-----------------------------------------------------------------------------#
+# BitsetIndex: BITS_ANY_SET (multiple bit)
+#-----------------------------------------------------------------------------#
+
+lua dump(box.index.BITS_ANY_SET, 7)
+---
+sorted output
+$       1$
+$       2$
+$       3$
+$       4$
+$       5$
+$       6$
+$       7$
+$       9$
+$      10$
+$      11$
+$      12$
+$      13$
+$      14$
+$      15$
+$      17$
+$      18$
+$      19$
+$      20$
+$      21$
+$      22$
+$      23$
+$      25$
+$      26$
+$      27$
+$      28$
+$      29$
+$      30$
+$      31$
+$      33$
+$      34$
+$      35$
+$      36$
+$      37$
+$      38$
+$      39$
+$      41$
+$      42$
+$      43$
+$      44$
+$      45$
+$      46$
+$      47$
+$      49$
+$      50$
+$      51$
+$      52$
+$      53$
+$      54$
+$      55$
+$      57$
+$      58$
+$      59$
+$      60$
+$      61$
+$      62$
+$      63$
+$      65$
+$      66$
+$      67$
+$      68$
+$      69$
+$      70$
+$      71$
+$      73$
+$      74$
+$      75$
+$      76$
+$      77$
+$      78$
+$      79$
+$      81$
+$      82$
+$      83$
+$      84$
+$      85$
+$      86$
+$      87$
+$      89$
+$      90$
+$      91$
+$      92$
+$      93$
+$      94$
+$      95$
+$      97$
+$      98$
+$      99$
+$     100$
+$     101$
+$     102$
+$     103$
+$     105$
+$     106$
+$     107$
+$     108$
+$     109$
+$     110$
+$     111$
+$     113$
+$     114$
+$     115$
+$     116$
+$     117$
+$     118$
+$     119$
+$     121$
+$     122$
+$     123$
+$     124$
+$     125$
+$     126$
+$     127$
+...
+lua dump(box.index.BITS_ANY_SET, 84)
+---
+sorted output
+$       4$
+$       5$
+$       6$
+$       7$
+$      12$
+$      13$
+$      14$
+$      15$
+$      16$
+$      17$
+$      18$
+$      19$
+$      20$
+$      21$
+$      22$
+$      23$
+$      24$
+$      25$
+$      26$
+$      27$
+$      28$
+$      29$
+$      30$
+$      31$
+$      36$
+$      37$
+$      38$
+$      39$
+$      44$
+$      45$
+$      46$
+$      47$
+$      48$
+$      49$
+$      50$
+$      51$
+$      52$
+$      53$
+$      54$
+$      55$
+$      56$
+$      57$
+$      58$
+$      59$
+$      60$
+$      61$
+$      62$
+$      63$
+$      64$
+$      65$
+$      66$
+$      67$
+$      68$
+$      69$
+$      70$
+$      71$
+$      72$
+$      73$
+$      74$
+$      75$
+$      76$
+$      77$
+$      78$
+$      79$
+$      80$
+$      81$
+$      82$
+$      83$
+$      84$
+$      85$
+$      86$
+$      87$
+$      88$
+$      89$
+$      90$
+$      91$
+$      92$
+$      93$
+$      94$
+$      95$
+$      96$
+$      97$
+$      98$
+$      99$
+$     100$
+$     101$
+$     102$
+$     103$
+$     104$
+$     105$
+$     106$
+$     107$
+$     108$
+$     109$
+$     110$
+$     111$
+$     112$
+$     113$
+$     114$
+$     115$
+$     116$
+$     117$
+$     118$
+$     119$
+$     120$
+$     121$
+$     122$
+$     123$
+$     124$
+$     125$
+$     126$
+$     127$
+...
+lua dump(box.index.BITS_ANY_SET, 113)
+---
+sorted output
+$       1$
+$       3$
+$       5$
+$       7$
+$       9$
+$      11$
+$      13$
+$      15$
+$      16$
+$      17$
+$      18$
+$      19$
+$      20$
+$      21$
+$      22$
+$      23$
+$      24$
+$      25$
+$      26$
+$      27$
+$      28$
+$      29$
+$      30$
+$      31$
+$      32$
+$      33$
+$      34$
+$      35$
+$      36$
+$      37$
+$      38$
+$      39$
+$      40$
+$      41$
+$      42$
+$      43$
+$      44$
+$      45$
+$      46$
+$      47$
+$      48$
+$      49$
+$      50$
+$      51$
+$      52$
+$      53$
+$      54$
+$      55$
+$      56$
+$      57$
+$      58$
+$      59$
+$      60$
+$      61$
+$      62$
+$      63$
+$      64$
+$      65$
+$      66$
+$      67$
+$      68$
+$      69$
+$      70$
+$      71$
+$      72$
+$      73$
+$      74$
+$      75$
+$      76$
+$      77$
+$      78$
+$      79$
+$      80$
+$      81$
+$      82$
+$      83$
+$      84$
+$      85$
+$      86$
+$      87$
+$      88$
+$      89$
+$      90$
+$      91$
+$      92$
+$      93$
+$      94$
+$      95$
+$      96$
+$      97$
+$      98$
+$      99$
+$     100$
+$     101$
+$     102$
+$     103$
+$     104$
+$     105$
+$     106$
+$     107$
+$     108$
+$     109$
+$     110$
+$     111$
+$     112$
+$     113$
+$     114$
+$     115$
+$     116$
+$     117$
+$     118$
+$     119$
+$     120$
+$     121$
+$     122$
+$     123$
+$     124$
+$     125$
+$     126$
+$     127$
+...
diff --git a/test/big/bitset.test b/test/big/bitset.test
new file mode 100644
index 0000000000..fca6bc10c3
--- /dev/null
+++ b/test/big/bitset.test
@@ -0,0 +1,108 @@
+# encoding: tarantool
+#
+
+import os
+import shutil
+
+for file in ("utils.lua", "bitset.lua"):
+    src_path = os.path.join("big/", file)
+    dst_path = os.path.join(vardir, file)
+    shutil.copy(src_path, dst_path)
+    exec admin "lua dofile('%s')" % (file)
+    os.unlink(dst_path);
+
+print """
+#-----------------------------------------------------------------------------#
+# BitsetIndex: insert/delete
+#-----------------------------------------------------------------------------#
+""";
+
+exec admin "lua test_insert_delete(128)"
+
+print """
+#-----------------------------------------------------------------------------#
+# BitsetIndex: ALL
+#-----------------------------------------------------------------------------#
+""";
+
+exec admin "lua clear()"
+exec admin "lua fill(1, 128)"
+exec admin "lua dump(box.index.BITS_ALL)"
+
+print """
+#-----------------------------------------------------------------------------#
+# BitsetIndex: BITS_ALL_SET (single bit)
+#-----------------------------------------------------------------------------#
+""";
+
+exec admin "lua dump(box.index.BITS_ALL_SET, 0)"
+
+exec admin "lua dump(box.index.BITS_ALL_SET, 1)"
+exec admin "lua dump(box.index.BITS_ALL_SET, 2)"
+exec admin "lua dump(box.index.BITS_ALL_SET, 8)"
+exec admin "lua dump(box.index.BITS_ALL_SET, 1073741824)"
+exec admin "lua dump(box.index.BITS_ALL_SET, 2147483648)"
+exec admin "lua dump(box.index.BITS_ALL_SET, 4294967296)"
+
+print """
+#-----------------------------------------------------------------------------#
+# BitsetIndex: BITS_ALL_SET (multiple bit)
+#-----------------------------------------------------------------------------#
+""";
+
+exec admin "lua dump(box.index.BITS_ALL_SET, 3)"
+exec admin "lua dump(box.index.BITS_ALL_SET, 7)"
+exec admin "lua dump(box.index.BITS_ALL_SET, 31)"
+exec admin "lua dump(box.index.BITS_ALL_SET, 5)"
+exec admin "lua dump(box.index.BITS_ALL_SET, 10)"
+exec admin "lua dump(box.index.BITS_ALL_SET, 27)"
+exec admin "lua dump(box.index.BITS_ALL_SET, 341)"
+exec admin "lua dump(box.index.BITS_ALL_SET, 2147483649)"
+exec admin "lua dump(box.index.BITS_ALL_SET, 4294967295)"
+
+print """
+#-----------------------------------------------------------------------------#
+# BitsetIndex: BITS_ALL_NOT_SET (single bit)
+#-----------------------------------------------------------------------------#
+""";
+
+exec admin "lua dump(box.index.BITS_ALL_NOT_SET, 0)"
+
+exec admin "lua dump(box.index.BITS_ALL_NOT_SET, 2)"
+exec admin "lua dump(box.index.BITS_ALL_NOT_SET, 8)"
+exec admin "lua dump(box.index.BITS_ALL_NOT_SET, 4294967296)"
+
+print """
+#-----------------------------------------------------------------------------#
+# BitsetIndex: BITS_ALL_NOT_SET (multiple bit)
+#-----------------------------------------------------------------------------#
+""";
+
+exec admin "lua dump(box.index.BITS_ALL_NOT_SET, 3)"
+exec admin "lua dump(box.index.BITS_ALL_NOT_SET, 7)"
+exec admin "lua dump(box.index.BITS_ALL_NOT_SET, 10)"
+exec admin "lua dump(box.index.BITS_ALL_NOT_SET, 27)"
+exec admin "lua dump(box.index.BITS_ALL_NOT_SET, 85)"
+exec admin "lua dump(box.index.BITS_ALL_NOT_SET, 4294967295)"
+
+print """
+#-----------------------------------------------------------------------------#
+# BitsetIndex: BITS_ANY_SET (single bit)
+#-----------------------------------------------------------------------------#
+""";
+
+exec admin "lua dump(box.index.BITS_ANY_SET, 0)"
+
+exec admin "lua dump(box.index.BITS_ANY_SET, 16)"
+exec admin "lua dump(box.index.BITS_ANY_SET, 128)"
+exec admin "lua dump(box.index.BITS_ANY_SET, 4294967296)"
+
+print """
+#-----------------------------------------------------------------------------#
+# BitsetIndex: BITS_ANY_SET (multiple bit)
+#-----------------------------------------------------------------------------#
+""";
+
+exec admin "lua dump(box.index.BITS_ANY_SET, 7)"
+exec admin "lua dump(box.index.BITS_ANY_SET, 84)"
+exec admin "lua dump(box.index.BITS_ANY_SET, 113)"
diff --git a/test/big/iterator.lua b/test/big/iterator.lua
deleted file mode 100644
index f9557af5e3..0000000000
--- a/test/big/iterator.lua
+++ /dev/null
@@ -1,27 +0,0 @@
-function iterate(space_no, index_no, f1, f2, ...)
-	local sorted = (box.space[space_no].index[index_no].type == "TREE");
-	local pkeys = {};
-	local tkeys = {};
-	local values = {};
-	for v in box.space[space_no].index[index_no]:iterator(...) do
-		local pk = v:slice(0, 1);
-		local tk = '$';
-		for f = f1, f2-1, 1 do tk = (tk..(v[f])..'$'); end;
-		table.insert(values, tk);
-		if pkeys[pk] ~= nil then
-			print('Duplicate tuple (primary key): ', pk);
-		end
-		if box.space[space_no].index[index_no].unique and tkeys[tk] ~= nil then
-			print('Duplicate tuple (test key): ', tk);
-		end;
-		tkeys[pk] = true;
-		tkeys[tk] = true;
-	end;
-
-	if not sorted then
-		table.sort(values);
-		print('sorted output');
-	end;
-
-	for i,v in ipairs(values) do print(v) end;
-end;
diff --git a/test/big/iterator.result b/test/big/iterator.result
index 117481a34b..dd55c7efff 100644
--- a/test/big/iterator.result
+++ b/test/big/iterator.result
@@ -1,4 +1,4 @@
-lua dofile('iterator.lua')
+lua dofile('utils.lua')
 ---
 ...
 lua box.insert(20, 'pid_001', 'sid_001', 'tid_998', 'a')
@@ -764,7 +764,7 @@ lua iterate(20, 3, 2, 4, box.index.LT, 'tid_000')
 ...
 lua iterate(20, 3, 2, 4, box.index.LT, 'tid_996', 'to', 'many', 'keys')
 ---
-error: 'iterator.lua:6: Key part count 4 is greater than index part count 2'
+error: 'utils.lua:27: Key part count 4 is greater than index part count 2'
 ...
 
 #-----------------------------------------------------------------------------#
diff --git a/test/big/iterator.test b/test/big/iterator.test
index 2182f7c2b2..53fd5531bc 100644
--- a/test/big/iterator.test
+++ b/test/big/iterator.test
@@ -3,10 +3,10 @@
 import os
 import shutil
 
-iterator_lua_path = os.path.join(vardir, "iterator.lua")
-shutil.copy("big/iterator.lua", iterator_lua_path)
+iterator_lua_path = os.path.join(vardir, "utils.lua")
+shutil.copy("big/utils.lua", iterator_lua_path)
 
-exec admin "lua dofile('iterator.lua')"
+exec admin "lua dofile('utils.lua')"
 shutil.rmtree(iterator_lua_path, True)
 
 exec admin "lua box.insert(20, 'pid_001', 'sid_001', 'tid_998', 'a')"
diff --git a/test/big/tarantool.cfg b/test/big/tarantool.cfg
index b3334affc2..a41c143265 100644
--- a/test/big/tarantool.cfg
+++ b/test/big/tarantool.cfg
@@ -328,3 +328,15 @@ space[22].index[3].type = "TREE"
 space[22].index[3].unique = true
 space[22].index[3].key_field[0].fieldno = 3
 space[22].index[3].key_field[0].type = "NUM"
+
+# bitset::replace test
+space[23].enabled = true
+space[23].index[0].type = "HASH"
+space[23].index[0].unique = true
+space[23].index[0].key_field[0].fieldno = 0
+space[23].index[0].key_field[0].type = "NUM"
+
+space[23].index[1].type = "BITSET"
+space[23].index[1].unique = false
+space[23].index[1].key_field[0].fieldno = 1
+space[23].index[1].key_field[0].type = "NUM"
diff --git a/test/big/utils.lua b/test/big/utils.lua
new file mode 100644
index 0000000000..2e32faa1dc
--- /dev/null
+++ b/test/big/utils.lua
@@ -0,0 +1,82 @@
+function space_field_types(space_no)
+	local types = {};
+	for _, index in pairs(box.space[space_no].index) do
+		for _,key_def in pairs(index.key_field) do
+			types[key_def.fieldno] = key_def.type;
+		end
+	end
+	return types;
+end
+
+function iterate(space_no, index_no, f1, f2, ...)
+	local sorted = (box.space[space_no].index[index_no].type == "TREE");
+	local pkeys = {};
+	local tkeys = {};
+	local values = {};
+	local types = space_field_types(space_no);
+	function get_field(tuple, field_no)
+		local f = tuple[field_no]
+		if (types[field_no] == 'NUM') then
+			return string.format('%8d', box.unpack('i', f));
+		elseif (types[field_no] == 'NUM64') then
+			return string.format('%8ld', box.unpack('l', f));
+		else
+			return f
+		end
+	end
+	for v in box.space[space_no].index[index_no]:iterator(...) do
+		local pk = get_field(v, 0);
+		local tk = '$';
+		for f = f1, f2-1, 1 do tk = (tk..(get_field(v, f))..'$'); end;
+		table.insert(values, tk);
+		if pkeys[pk] ~= nil then
+			print('Duplicate tuple (primary key): ', pk);
+		end
+		if box.space[space_no].index[index_no].unique and tkeys[tk] ~= nil then
+			print('Duplicate tuple (test key): ', tk);
+		end;
+		tkeys[pk] = true;
+		tkeys[tk] = true;
+	end;
+
+	if not sorted then
+		table.sort(values);
+		print('sorted output');
+	end;
+
+	for i,v in ipairs(values) do print(v) end;
+end
+
+function arithmetic(d, count)
+	if not d then d = 1 end
+	local a = 0;
+	local i = 0;
+
+	return function()
+		if count and (i >= count) then
+			return nil;
+		end
+
+		i = i + 1;
+		a = a + d;
+		return a;
+	end
+end
+
+function table.shuffle(t)
+	local n = #t
+	while n >= 2 do
+		local k = math.random(n)
+		t[k], t[n] = t[n], t[k]
+		n = n - 1
+	end
+end
+
+function table.generate(iter)
+	local t = {};
+	for k in iter do
+		table.insert(t, k);
+	end
+
+	return t;
+end
-- 
GitLab