Skip to content

Commit

Permalink
Test DAC note is played
Browse files Browse the repository at this point in the history
  • Loading branch information
rhargreaves committed Aug 30, 2024
1 parent 65a742d commit 3e7cfab
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
3 changes: 3 additions & 0 deletions tests/unit/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#define midi_pcm_test(test) cmocka_unit_test_setup(test, test_midi_setup)
#define midi_portamento_test(test) cmocka_unit_test_setup(test, test_midi_portamento_setup)
#define midi_finetune_test(test) cmocka_unit_test_setup(test, test_midi_setup)
#define midi_dac_test(test) cmocka_unit_test_setup(test, test_midi_dac_setup)
#define dynamic_midi_test(test) cmocka_unit_test_setup(test, test_dynamic_midi_setup)
#define synth_test(test) cmocka_unit_test_setup(test, test_synth_setup)
#define comm_test(test) cmocka_unit_test_setup(test, test_comm_setup)
Expand Down Expand Up @@ -189,6 +190,8 @@ int main(void)
midi_test(test_midi_resets_fm_values_to_defaults),
midi_test(test_midi_resets_psg_values_to_defaults),

midi_dac_test(test_midi_dac_plays_note),

pitchcents_test(test_pitchcents_shift_extreme_up),
pitchcents_test(test_pitchcents_bend_nil),
pitchcents_test(test_pitchcents_bend_down_fully),
Expand Down
23 changes: 23 additions & 0 deletions tests/unit/test_midi_pcm.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,16 @@
#include "test_midi.h"
#include "snd/sound.h"
#include "snd/pcm/snd_pcm.h"

static int test_midi_dac_setup(UNUSED void** state)
{
test_midi_setup(state);

expect_value(__wrap_synth_enableDac, enable, true);
__real_midi_cc(0, 78, 0x7F);

return 0;
}

static void test_midi_enables_dac(UNUSED void** state)
{
Expand All @@ -13,3 +25,14 @@ static void test_midi_disables_dac(UNUSED void** state)

__real_midi_cc(0, 78, 0);
}

static void test_midi_dac_plays_note(UNUSED void** state)
{
expect_any(__wrap_SND_PCM_startPlay, sample);
expect_any(__wrap_SND_PCM_startPlay, len);
expect_any(__wrap_SND_PCM_startPlay, rate);
expect_value(__wrap_SND_PCM_startPlay, pan, SOUND_PAN_CENTER);
expect_value(__wrap_SND_PCM_startPlay, loop, 0);

__real_midi_note_on(5, 100, 100);
}

0 comments on commit 3e7cfab

Please sign in to comment.