Skip to content

Commit

Permalink
Add another test for aufile_set_position.
Browse files Browse the repository at this point in the history
  • Loading branch information
larsimmisch committed Nov 21, 2023
1 parent 1fe9857 commit 4d31e9f
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions test/aupos.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ int test_auposition(void)
struct aufile *af = NULL;
struct aufile_prm prm;
char path[256];
uint8_t buffer[128];
uint8_t buffer[512];

re_snprintf(path, sizeof(path), "%s/beep.wav", test_datapath());

Expand All @@ -29,13 +29,30 @@ int test_auposition(void)
err = aufile_set_position(af, &prm, 67);
TEST_ERR(err);

/* That file is 67 ms long, so we shouldn't read anything */
/* That file is exactly 67 ms long, so we shouldn't read anything */
size_t size = sizeof(buffer);
err = aufile_read(af, buffer, &size);
TEST_ERR(err);

TEST_EQUALS(0, size);

af = mem_deref(af);

err = aufile_open(&af, &prm, path, AUFILE_READ);
TEST_ERR(err);

err = aufile_set_position(af, &prm, 37);
TEST_ERR(err);

size = sizeof(buffer);
err = aufile_read(af, buffer, &size);
TEST_ERR(err);

/* 30 ms should be left, at 8000Hz/s, one channels and 16 bit samples
that's 480 bytes */
TEST_EQUALS(480, size);


out:
mem_deref(af);

Expand Down

0 comments on commit 4d31e9f

Please sign in to comment.