History

test: zero buffer and no file cases

lieff committed 6 years ago

Commit d6071151 parent ca285b22 files · +20 −1Browse files

Unified · Split

2 files
  1. minimp3_ex.h +1 −1
  2. minimp3_test.c +19 −0
minimp3_ex.h+1−1
@@ -220,7 +220,7 @@ int mp3dec_load_buf(mp3dec_t *dec, const uint8_t *buf, size_t buf_size, mp3dec_f · 219 unmodified lines
220 220
221int mp3dec_load_cb(mp3dec_t *dec, mp3dec_io_t *io, uint8_t *buf, size_t buf_size, mp3dec_file_info_t *info, MP3D_PROGRESS_CB progress_cb, void *user_data)221int mp3dec_load_cb(mp3dec_t *dec, mp3dec_io_t *io, uint8_t *buf, size_t buf_size, mp3dec_file_info_t *info, MP3D_PROGRESS_CB progress_cb, void *user_data)
222{222{
223 if (!dec || !buf || !info || (size_t)-1 == buf_size)223 if (!dec || !buf || !info || (size_t)-1 == buf_size || (io && buf_size < MINIMP3_BUF_SIZE))
224 return MP3D_E_PARAM;224 return MP3D_E_PARAM;
225 uint64_t detected_samples = 0;225 uint64_t detected_samples = 0;
226 size_t orig_buf_size = buf_size;226 size_t orig_buf_size = buf_size;
minimp3_test.c+19−0
@@ -372,6 +372,9 @@ static int self_test(const char *input_file_name) · 371 unmodified lines
372 ASSERT(MP3D_E_PARAM == ret);372 ASSERT(MP3D_E_PARAM == ret);
373 ret = mp3dec_load_buf(&mp3d, buf, size, 0, 0, 0);373 ret = mp3dec_load_buf(&mp3d, buf, size, 0, 0, 0);
374 ASSERT(MP3D_E_PARAM == ret);374 ASSERT(MP3D_E_PARAM == ret);
375 memset(&finfo, 0xff, sizeof(finfo));
376 ret = mp3dec_load_buf(&mp3d, buf, 0, &finfo, 0, 0);
377 ASSERT(0 == ret && 0 == finfo.samples);
375 378
376 ret = mp3dec_load_cb(0, &io, buf, size, &finfo, 0, 0);379 ret = mp3dec_load_cb(0, &io, buf, size, &finfo, 0, 0);
377 ASSERT(MP3D_E_PARAM == ret);380 ASSERT(MP3D_E_PARAM == ret);
@@ -381,6 +384,8 @@ static int self_test(const char *input_file_name) · 3 unmodified lines
381 ASSERT(MP3D_E_PARAM == ret);384 ASSERT(MP3D_E_PARAM == ret);
382 ret = mp3dec_load_cb(&mp3d, &io, buf, size, 0, 0, 0);385 ret = mp3dec_load_cb(&mp3d, &io, buf, size, 0, 0, 0);
383 ASSERT(MP3D_E_PARAM == ret);386 ASSERT(MP3D_E_PARAM == ret);
387 ret = mp3dec_load_cb(&mp3d, &io, buf, 0, &finfo, 0, 0);
388 ASSERT(MP3D_E_PARAM == ret);
384 389
385 ret = mp3dec_iterate_buf(0, size, frames_iterate_cb, 0);390 ret = mp3dec_iterate_buf(0, size, frames_iterate_cb, 0);
386 ASSERT(MP3D_E_PARAM == ret);391 ASSERT(MP3D_E_PARAM == ret);
@@ -388,6 +393,8 @@ static int self_test(const char *input_file_name) · 1 unmodified line
388 ASSERT(MP3D_E_PARAM == ret);393 ASSERT(MP3D_E_PARAM == ret);
389 ret = mp3dec_iterate_buf(buf, size, 0, 0);394 ret = mp3dec_iterate_buf(buf, size, 0, 0);
390 ASSERT(MP3D_E_PARAM == ret);395 ASSERT(MP3D_E_PARAM == ret);
396 ret = mp3dec_iterate_buf(buf, 0, frames_iterate_cb, 0);
397 ASSERT(0 == ret);
391 398
392 ret = mp3dec_iterate_cb(0, buf, size, frames_iterate_cb, 0);399 ret = mp3dec_iterate_cb(0, buf, size, frames_iterate_cb, 0);
393 ASSERT(MP3D_E_PARAM == ret);400 ASSERT(MP3D_E_PARAM == ret);
@@ -397,6 +404,8 @@ static int self_test(const char *input_file_name) · 3 unmodified lines
397 ASSERT(MP3D_E_PARAM == ret);404 ASSERT(MP3D_E_PARAM == ret);
398 ret = mp3dec_iterate_cb(&io, buf, size, 0, 0);405 ret = mp3dec_iterate_cb(&io, buf, size, 0, 0);
399 ASSERT(MP3D_E_PARAM == ret);406 ASSERT(MP3D_E_PARAM == ret);
407 ret = mp3dec_iterate_cb(&io, buf, 0, frames_iterate_cb, 0);
408 ASSERT(MP3D_E_PARAM == ret);
400 409
401 ret = mp3dec_ex_open_buf(0, buf, size, MP3D_SEEK_TO_SAMPLE);410 ret = mp3dec_ex_open_buf(0, buf, size, MP3D_SEEK_TO_SAMPLE);
402 ASSERT(MP3D_E_PARAM == ret);411 ASSERT(MP3D_E_PARAM == ret);
@@ -406,6 +415,10 @@ static int self_test(const char *input_file_name) · 3 unmodified lines
406 ASSERT(MP3D_E_PARAM == ret);415 ASSERT(MP3D_E_PARAM == ret);
407 ret = mp3dec_ex_open_buf(&dec, buf, size, MP3D_SEEK_TO_SAMPLE + 1);416 ret = mp3dec_ex_open_buf(&dec, buf, size, MP3D_SEEK_TO_SAMPLE + 1);
408 ASSERT(MP3D_E_PARAM == ret);417 ASSERT(MP3D_E_PARAM == ret);
418 ret = mp3dec_ex_open_buf(&dec, buf, 0, MP3D_SEEK_TO_SAMPLE);
419 ASSERT(0 == ret);
420 ret = mp3dec_ex_read(&dec, (mp3d_sample_t*)buf, 10);
421 ASSERT(0 == ret);
409 422
410 ret = mp3dec_ex_open_cb(0, &io, MP3D_SEEK_TO_SAMPLE);423 ret = mp3dec_ex_open_cb(0, &io, MP3D_SEEK_TO_SAMPLE);
411 ASSERT(MP3D_E_PARAM == ret);424 ASSERT(MP3D_E_PARAM == ret);
@@ -428,11 +441,15 @@ static int self_test(const char *input_file_name) · 16 unmodified lines
428 ASSERT(MP3D_E_PARAM == ret);441 ASSERT(MP3D_E_PARAM == ret);
429 ret = mp3dec_load(&mp3d, input_file_name, 0, 0, 0);442 ret = mp3dec_load(&mp3d, input_file_name, 0, 0, 0);
430 ASSERT(MP3D_E_PARAM == ret);443 ASSERT(MP3D_E_PARAM == ret);
444 ret = mp3dec_load(&mp3d, "not_foud", &finfo, 0, 0);
445 ASSERT(MP3D_E_IOERROR == ret);
431 446
432 ret = mp3dec_iterate(0, frames_iterate_cb, 0);447 ret = mp3dec_iterate(0, frames_iterate_cb, 0);
433 ASSERT(MP3D_E_PARAM == ret);448 ASSERT(MP3D_E_PARAM == ret);
434 ret = mp3dec_iterate(input_file_name, 0, 0);449 ret = mp3dec_iterate(input_file_name, 0, 0);
435 ASSERT(MP3D_E_PARAM == ret);450 ASSERT(MP3D_E_PARAM == ret);
451 ret = mp3dec_iterate("not_foud", frames_iterate_cb, 0);
452 ASSERT(MP3D_E_IOERROR == ret);
436 453
437 ret = mp3dec_ex_open(0, input_file_name, MP3D_SEEK_TO_SAMPLE);454 ret = mp3dec_ex_open(0, input_file_name, MP3D_SEEK_TO_SAMPLE);
438 ASSERT(MP3D_E_PARAM == ret);455 ASSERT(MP3D_E_PARAM == ret);
@@ -440,6 +457,8 @@ static int self_test(const char *input_file_name) · 1 unmodified line
440 ASSERT(MP3D_E_PARAM == ret);457 ASSERT(MP3D_E_PARAM == ret);
441 ret = mp3dec_ex_open(&dec, input_file_name, MP3D_SEEK_TO_SAMPLE + 1);458 ret = mp3dec_ex_open(&dec, input_file_name, MP3D_SEEK_TO_SAMPLE + 1);
442 ASSERT(MP3D_E_PARAM == ret);459 ASSERT(MP3D_E_PARAM == ret);
460 ret = mp3dec_ex_open(&dec, "not_foud", MP3D_SEEK_TO_SAMPLE);
461 ASSERT(MP3D_E_IOERROR == ret);
443 462
444 printf("passed\n");463 printf("passed\n");
445 return 0;464 return 0;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t