[vlc-commits] add bs_skip tests

Francois Cartegnie git at videolan.org
Thu Dec 17 15:39:28 CET 2015


vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Thu Dec 17 14:26:12 2015 +0100| [f91c968b4ef36cd6f9c7111285bfe8d00821f3cf] | committer: Francois Cartegnie

add bs_skip tests

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=f91c968b4ef36cd6f9c7111285bfe8d00821f3cf
---

 test/src/misc/bits.c |   23 ++++++++++++++++++++++-
 1 file changed, 22 insertions(+), 1 deletion(-)

diff --git a/test/src/misc/bits.c b/test/src/misc/bits.c
index de13b73..17b8335 100644
--- a/test/src/misc/bits.c
+++ b/test/src/misc/bits.c
@@ -19,7 +19,9 @@
  *****************************************************************************/
 
 #include "../../libvlc/test.h"
-
+#ifdef NDEBUG
+ #undef NDEBUG
+#endif
 #include <vlc_bits.h>
 #include <assert.h>
 
@@ -85,5 +87,24 @@ int main( void )
     assert( bs_read_se(&bs) == -1 );
     assert( bs_eof(&bs) );
 
+    const uint8_t abc[6] = { 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF };
+    bs_init( &bs, &abc, 6 );
+    bs_skip( &bs, 24 );
+    assert( bs_read( &bs, 8 ) == 0xDD );
+    assert( bs_read( &bs, 4 ) == 0x0E );
+    assert( bs_read( &bs, 8 ) == 0xEF );
+    assert( bs_remain( &bs ) == 4 );
+
+    bs_init( &bs, &abc, 6 );
+    bs_skip( &bs, 40 );
+    assert( bs_read( &bs, 8 ) == 0xFF );
+
+    bs_init( &bs, &abc, 6 );
+    bs_skip( &bs, 20 );
+    assert( bs_read( &bs, 8 ) == 0xCD );
+    assert( bs_read( &bs, 4 ) == 0x0D );
+    assert( bs_read( &bs, 8 ) == 0xEE );
+    assert( bs_remain( &bs ) == 8 );
+
     return 0;
 }



More information about the vlc-commits mailing list