Skip to content
This repository was archived by the owner on Apr 14, 2022. It is now read-only.

Commit a9daf9f

Browse files
committed
Add a couple minor additional decoder tests.
1 parent a0d096f commit a9daf9f

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

tests/test_opus_api.c

+20
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,8 @@ opus_int32 test_dec_api(void)
147147
fprintf(stdout," opus_decoder_create() ........................ OK.\n");
148148
fprintf(stdout," opus_decoder_init() .......................... OK.\n");
149149

150+
err=opus_decoder_ctl(dec, OPUS_GET_FINAL_RANGE((opus_uint32 *)NULL));
151+
if(err != OPUS_BAD_ARG)test_failed();
150152
VG_UNDEF(&dec_final_range,sizeof(dec_final_range));
151153
err=opus_decoder_ctl(dec, OPUS_GET_FINAL_RANGE(&dec_final_range));
152154
if(err!=OPUS_OK)test_failed();
@@ -159,12 +161,22 @@ opus_int32 test_dec_api(void)
159161
fprintf(stdout," OPUS_UNIMPLEMENTED ........................... OK.\n");
160162
cfgs++;
161163

164+
err=opus_decoder_ctl(dec, OPUS_GET_BANDWIDTH((opus_int32 *)NULL));
165+
if(err != OPUS_BAD_ARG)test_failed();
162166
VG_UNDEF(&i,sizeof(i));
163167
err=opus_decoder_ctl(dec, OPUS_GET_BANDWIDTH(&i));
164168
if(err != OPUS_OK || i!=0)test_failed();
165169
fprintf(stdout," OPUS_GET_BANDWIDTH ........................... OK.\n");
166170
cfgs++;
167171

172+
err=opus_decoder_ctl(dec, OPUS_GET_SAMPLE_RATE((opus_int32 *)NULL));
173+
if(err != OPUS_BAD_ARG)test_failed();
174+
VG_UNDEF(&i,sizeof(i));
175+
err=opus_decoder_ctl(dec, OPUS_GET_SAMPLE_RATE(&i));
176+
if(err != OPUS_OK || i!=48000)test_failed();
177+
fprintf(stdout," OPUS_GET_SAMPLE_RATE ......................... OK.\n");
178+
cfgs++;
179+
168180
/*GET_PITCH has different execution paths depending on the previously decoded frame.*/
169181
err=opus_decoder_ctl(dec, OPUS_GET_PITCH(nullvalue));
170182
if(err!=OPUS_BAD_ARG)test_failed();
@@ -190,6 +202,14 @@ opus_int32 test_dec_api(void)
190202
cfgs++;
191203
fprintf(stdout," OPUS_GET_PITCH ............................... OK.\n");
192204

205+
err=opus_decoder_ctl(dec, OPUS_GET_LAST_PACKET_DURATION((opus_int32 *)NULL));
206+
if(err != OPUS_BAD_ARG)test_failed();
207+
VG_UNDEF(&i,sizeof(i));
208+
err=opus_decoder_ctl(dec, OPUS_GET_LAST_PACKET_DURATION(&i));
209+
if(err != OPUS_OK || i!=960)test_failed();
210+
cfgs++;
211+
fprintf(stdout," OPUS_GET_LAST_PACKET_DURATION ................ OK.\n");
212+
193213
VG_UNDEF(&i,sizeof(i));
194214
err=opus_decoder_ctl(dec, OPUS_GET_GAIN(&i));
195215
VG_CHECK(&i,sizeof(i));

tests/test_opus_decode.c

+4
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,10 @@ int test_decoder_code0(int no_fuzz)
111111
if(opus_decoder_ctl(dec[t], OPUS_GET_LAST_PACKET_DURATION(&dur))!=OPUS_OK)test_failed();
112112
if(dur!=120/factor)test_failed();
113113

114+
/*Test on a size which isn't a multiple of 2.5ms*/
115+
out_samples = opus_decode(dec[t], 0, 0, outbuf, 120/factor+2, fec);
116+
if(out_samples!=OPUS_BAD_ARG)test_failed();
117+
114118
/*Test null pointer input*/
115119
out_samples = opus_decode(dec[t], 0, -1, outbuf, 120/factor, fec);
116120
if(out_samples!=120/factor)test_failed();

0 commit comments

Comments
 (0)