From a1af7db3ecf1863c77e69aa432e6fb2694ec3f95 Mon Sep 17 00:00:00 2001 From: steven-na Date: Thu, 30 Jul 2026 13:58:06 -0700 Subject: Wav file loading --- tests/fixtures/sine.wav | Bin 0 -> 96044 bytes tests/smrt_arena.c | 2 +- tests/string.c | 3 +-- tests/wav.c | 27 +++++++++++++++++++++++++++ 4 files changed, 29 insertions(+), 3 deletions(-) create mode 100644 tests/fixtures/sine.wav create mode 100644 tests/wav.c (limited to 'tests') diff --git a/tests/fixtures/sine.wav b/tests/fixtures/sine.wav new file mode 100644 index 0000000..8e01d11 Binary files /dev/null and b/tests/fixtures/sine.wav differ diff --git a/tests/smrt_arena.c b/tests/smrt_arena.c index 5e3ef5c..505a5e0 100644 --- a/tests/smrt_arena.c +++ b/tests/smrt_arena.c @@ -9,7 +9,7 @@ #include Test(smrt_arena, create_arena) { - smrt_arena_t *arena = smrt_arena_create(KiB(1), KiB(4), false); + smrt_arena_t *arena = smrt_arena_create(KiB(1), plat_get_pagesize(), false); cr_expect(arena->reserve_size == MAX(KiB(1), plat_get_pagesize())); cr_expect(arena->pos == SMRT_ARENA_BASE_POS); diff --git a/tests/string.c b/tests/string.c index 38109a7..794bcfb 100644 --- a/tests/string.c +++ b/tests/string.c @@ -2,11 +2,11 @@ #include #include +#include #include #include #include -#include Test(string, create_string) { smrt_arena_t *arena = smrt_arena_create(KiB(4), KiB(4), false); @@ -64,7 +64,6 @@ Test(string, string_duplicate) { strng_t *dup = strng_dup(arena, orig); - printf("%.*s\n", STRNG_FMT(dup)); cr_expect(dup->alloc_size == 26); cr_expect(dup->len == 26); diff --git a/tests/wav.c b/tests/wav.c new file mode 100644 index 0000000..aac7f9d --- /dev/null +++ b/tests/wav.c @@ -0,0 +1,27 @@ +#include "../src/wav.h" + +#include +#include + +#include +#include +#include +#include + +Test(wav, read_file) { + smrt_arena_t *arena = smrt_arena_create(MiB(4), KiB(4), false); + + wav_master_chunk_t mchunk; + wav_fmt_chunk_t fmtchunk; + + wav_data_t *data = load_wav_file(arena, "./tests/fixtures/sine.wav", &mchunk, &fmtchunk); + + u8 idcheck[4] = { 'f', 'm', 't', ' ' }; + cr_expect(memcmp(fmtchunk.chunk_id, idcheck, 4) == 0); + cr_expect(fmtchunk.audio_format == 1); + cr_expect(fmtchunk.num_channels == 1); + cr_expect(fmtchunk.bits_per_sample == 16); + cr_expect(data->sample_count == 48000); + + smrt_arena_destroy(arena); +} -- cgit v1.2.3