diff options
author | Gregory Maxwell <greg@xiph.org> | 2013-11-19 11:25:20 +0400 |
---|---|---|
committer | Gregory Maxwell <greg@xiph.org> | 2013-11-19 11:25:20 +0400 |
commit | 733b47f31cfa72eb31323dc8b3dd1ba16074a106 (patch) | |
tree | c572e9c9b97ae15abd444874eb8dce59e88664c0 /tests/test_opus_api.c | |
parent | 135d1c9848cb5114f485c02d969fd1717045dcef (diff) |
Add opus_packet_(un)pad tests.
Diffstat (limited to 'tests/test_opus_api.c')
-rw-r--r-- | tests/test_opus_api.c | 34 |
1 files changed, 32 insertions, 2 deletions
diff --git a/tests/test_opus_api.c b/tests/test_opus_api.c index 204cb2d2..17b96293 100644 --- a/tests/test_opus_api.c +++ b/tests/test_opus_api.c @@ -1446,9 +1446,9 @@ int test_repacketizer_api(void) packet=malloc(max_out); if(packet==NULL)test_failed(); - po=malloc(max_out); - if(po==NULL)test_failed(); memset(packet,0,max_out); + po=malloc(max_out+256); + if(po==NULL)test_failed(); i=opus_repacketizer_get_size(); if(i<=0)test_failed(); @@ -1550,6 +1550,14 @@ int test_repacketizer_api(void) cfgs++; if(opus_repacketizer_out(rp,po,len)!=len)test_failed(); cfgs++; + if(opus_packet_unpad(po,len)!=len)test_failed(); + cfgs++; + if(opus_packet_pad(po,len,len+1)!=OPUS_OK)test_failed(); + cfgs++; + if(opus_packet_pad(po,len+1,len+256)!=OPUS_OK)test_failed(); + cfgs++; + if(opus_packet_unpad(po,len+256)!=len)test_failed(); + cfgs++; if(opus_repacketizer_out(rp,po,len-1)!=OPUS_BUFFER_TOO_SMALL)test_failed(); cfgs++; if(len>1) @@ -1649,6 +1657,14 @@ int test_repacketizer_api(void) cfgs++; if(opus_repacketizer_out(rp,po,len)!=len)test_failed(); cfgs++; + if(opus_packet_unpad(po,len)!=len)test_failed(); + cfgs++; + if(opus_packet_pad(po,len,len+1)!=OPUS_OK)test_failed(); + cfgs++; + if(opus_packet_pad(po,len+1,len+256)!=OPUS_OK)test_failed(); + cfgs++; + if(opus_packet_unpad(po,len+256)!=len)test_failed(); + cfgs++; if(opus_repacketizer_out(rp,po,len-1)!=OPUS_BUFFER_TOO_SMALL)test_failed(); cfgs++; if(len>1) @@ -1661,9 +1677,23 @@ int test_repacketizer_api(void) } } + po[0]='O'; + po[1]='p'; + if(opus_packet_pad(po,4,5)!=OPUS_BAD_ARG)test_failed(); + cfgs++; + if(opus_packet_unpad(po,4)!=OPUS_INVALID_PACKET)test_failed(); + cfgs++; + po[0]=0; + po[1]=0; + po[2]=0; + if(opus_packet_pad(po,5,4)!=OPUS_BAD_ARG)test_failed(); + cfgs++; + fprintf(stdout," opus_repacketizer_cat ........................ OK.\n"); fprintf(stdout," opus_repacketizer_out ........................ OK.\n"); fprintf(stdout," opus_repacketizer_out_range .................. OK.\n"); + fprintf(stdout," opus_packet_pad .............................. OK.\n"); + fprintf(stdout," opus_packet_unpad ............................ OK.\n"); opus_repacketizer_destroy(rp); cfgs++; |