Add function to get uninterrupted bit run

Function bitvec_rl_curbit added to get number of  uninterrupted
bits run in vector starting from the current bit till max number
of bits.
Test case is added to check bitvec_rl_curbit.

Change-Id: Iae153d3639ea6b891c1fc10d7801a435c9492e26
diff --git a/tests/bitvec/bitvec_test.c b/tests/bitvec/bitvec_test.c
index a98a91c..d0bc30c 100644
--- a/tests/bitvec/bitvec_test.c
+++ b/tests/bitvec/bitvec_test.c
@@ -150,6 +150,18 @@
 	}
 }
 
+static inline void test_bitvec_rl_curbit(struct bitvec *bv, bool b, int max_bits,
+						int result )
+{
+	int num = 0;
+	int readIndex = bv->cur_bit;
+	OSMO_ASSERT(bv->cur_bit < max_bits);
+	num = bitvec_rl_curbit(bv, b, max_bits);
+	readIndex += num;
+	OSMO_ASSERT(bv->cur_bit == readIndex);
+	OSMO_ASSERT(num == result);
+}
+
 static void test_array()
 {
 	struct bitvec b;
@@ -245,7 +257,35 @@
 
 	test_array();
 
-	printf("\nbitvec ok.\n");
+	printf("\nbitvec_runlength....\n");
 
+	bitvec_zero(&bv);
+	bitvec_set_uint(&bv, 0xff, 8);
+	bv.cur_bit -= 8;
+	test_bitvec_rl_curbit(&bv, 1, 64, 8);
+
+	bitvec_zero(&bv);
+	bitvec_set_uint(&bv, 0xfc, 8);
+	bv.cur_bit -= 8;
+	test_bitvec_rl_curbit(&bv, 1, 64, 6);
+
+	bitvec_zero(&bv);
+	test_bitvec_rl_curbit(&bv, 0, 52, 52);
+
+	bitvec_zero(&bv);
+	bitvec_set_uint(&bv, 0xfc, 8);
+	bv.cur_bit -= 2;
+	test_bitvec_rl_curbit(&bv, 0, 64, 58);
+
+	bitvec_zero(&bv);
+	bitvec_set_uint(&bv, 0x07, 8);
+	bitvec_set_uint(&bv, 0xf8, 8);
+	bv.cur_bit -= 11;
+	test_bitvec_rl_curbit(&bv, 1, 64, 8);
+
+	bitvec_zero(&bv);
+	test_bitvec_rl_curbit(&bv, 1, 64, 0);
+
+	printf("\nbitvec ok.\n");
 	return 0;
 }