Skip to content

Commit

Permalink
Simplify expectations on PSG calls
Browse files Browse the repository at this point in the history
  • Loading branch information
rhargreaves committed Feb 19, 2025
1 parent cc4dc42 commit 26ae06f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 23 deletions.
1 change: 0 additions & 1 deletion tests/cmocka_inc.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
#include <cmocka.h>

#define INT_PTR(val) (&((int) { val }))

#define UNUSED __attribute__((unused))

#define expect_value_with_pos(function, parameter, value, file, line) \
Expand Down
34 changes: 12 additions & 22 deletions tests/system/test_e2e.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "mocks/mock_synth.h"
#include "mocks/mock_comm.h"
#include "mocks/mock_sgdk.h"
#include "mocks/mock_psg.h"

static const u8 TEST_CC_PAN = 10;
static const u8 TEST_CC_PORTAMENTO_TIME = 5;
Expand Down Expand Up @@ -84,10 +85,8 @@ void test_psg_audible_if_note_on_event_triggered(void** state)
{
stub_everdrive_as_present();
stub_usb_receive_note_on(TEST_MIDI_CHANNEL_PSG_1, 60, TEST_VELOCITY_MAX);
expect_any(__wrap_PSG_setTone, channel);
expect_any(__wrap_PSG_setTone, value);
expect_any(__wrap_PSG_setEnvelope, channel);
expect_any(__wrap_PSG_setEnvelope, value);
expect_any_psg_tone();
expect_any_psg_attenuation();
midi_receiver_read();
}

Expand All @@ -113,10 +112,8 @@ void test_general_midi_reset_sysex_stops_all_notes(void** state)

// PSG note
stub_usb_receive_note_on(TEST_MIDI_CHANNEL_PSG_1, noteOnKey, TEST_VELOCITY_MAX);
expect_value(__wrap_PSG_setTone, channel, 0);
expect_any(__wrap_PSG_setTone, value);
expect_value(__wrap_PSG_setEnvelope, channel, 0);
expect_value(__wrap_PSG_setEnvelope, value, 0);
expect_psg_tone(0, 0x357);
expect_psg_attenuation(0, 0);
midi_receiver_read();

// Send General MIDI reset
Expand All @@ -130,8 +127,7 @@ void test_general_midi_reset_sysex_stops_all_notes(void** state)
expect_ym2612_write_reg(0, 0x28, 0x04);
expect_ym2612_write_reg(0, 0x28, 0x05);
expect_ym2612_write_reg(0, 0x28, 0x06);
expect_value(__wrap_PSG_setEnvelope, channel, 0);
expect_value(__wrap_PSG_setEnvelope, value, 0xF);
expect_psg_attenuation(0, 0xF);
midi_receiver_read();
}

Expand Down Expand Up @@ -159,10 +155,8 @@ void test_remap_midi_channel_1_to_psg_channel_1()
midi_receiver_read();

stub_usb_receive_note_on(TEST_MIDI_CHANNEL_1, 48, TEST_VELOCITY_MAX);
expect_value(__wrap_PSG_setTone, channel, 0);
expect_any(__wrap_PSG_setTone, value);
expect_value(__wrap_PSG_setEnvelope, channel, 0);
expect_value(__wrap_PSG_setEnvelope, value, 0);
expect_psg_tone(0, 0x357);
expect_psg_attenuation(0, 0);
midi_receiver_read();
}

Expand All @@ -176,10 +170,8 @@ void test_set_device_for_midi_channel_1_to_psg()
midi_receiver_read();

stub_usb_receive_note_on(TEST_MIDI_CHANNEL_1, 48, TEST_VELOCITY_MAX);
expect_value(__wrap_PSG_setTone, channel, 0);
expect_any(__wrap_PSG_setTone, value);
expect_value(__wrap_PSG_setEnvelope, channel, 0);
expect_value(__wrap_PSG_setEnvelope, value, 0);
expect_psg_tone(0, 0x357);
expect_psg_attenuation(0, 0);
midi_receiver_read();
}

Expand Down Expand Up @@ -216,10 +208,8 @@ void test_loads_psg_envelope()
midi_receiver_read();

stub_usb_receive_note_on(TEST_MIDI_CHANNEL_PSG_1, 60, TEST_VELOCITY_MAX);
expect_value(__wrap_PSG_setTone, channel, 0);
expect_value(__wrap_PSG_setTone, value, 0x17c);
expect_value(__wrap_PSG_setEnvelope, channel, 0);
expect_value(__wrap_PSG_setEnvelope, value, 6);
expect_psg_tone(0, 0x17c);
expect_psg_attenuation(0, 6);
midi_receiver_read();
}

Expand Down

0 comments on commit 26ae06f

Please sign in to comment.