mirror of
https://github.com/ZDoom/fluidsynth.git
synced 2025-02-22 11:51:56 +00:00
Update unregistering unit test
This commit is contained in:
parent
e19652d45a
commit
ba71d6ad9e
1 changed files with 38 additions and 4 deletions
|
@ -2,11 +2,8 @@
|
||||||
#include "test.h"
|
#include "test.h"
|
||||||
#include "fluidsynth.h" // use local fluidsynth header
|
#include "fluidsynth.h" // use local fluidsynth header
|
||||||
|
|
||||||
// simple test to ensure that manually unregistering and deleting the internal fluid_seqbind_t works without crashing
|
static void test_unregister_with_event(fluid_synth_t *synth)
|
||||||
int main(void)
|
|
||||||
{
|
{
|
||||||
fluid_settings_t *settings = new_fluid_settings();
|
|
||||||
fluid_synth_t *synth = new_fluid_synth(settings);
|
|
||||||
fluid_sequencer_t *seq = new_fluid_sequencer2(0 /*i.e. use sample timer*/);
|
fluid_sequencer_t *seq = new_fluid_sequencer2(0 /*i.e. use sample timer*/);
|
||||||
|
|
||||||
// silently creates a fluid_seqbind_t
|
// silently creates a fluid_seqbind_t
|
||||||
|
@ -23,6 +20,43 @@ int main(void)
|
||||||
// client should be removed, deleting the seq should not free the struct again
|
// client should be removed, deleting the seq should not free the struct again
|
||||||
delete_fluid_event(evt);
|
delete_fluid_event(evt);
|
||||||
delete_fluid_sequencer(seq);
|
delete_fluid_sequencer(seq);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void test_unregister_with_client_unregister(fluid_synth_t *synth)
|
||||||
|
{
|
||||||
|
fluid_sequencer_t *seq = new_fluid_sequencer2(0 /*i.e. use sample timer*/);
|
||||||
|
|
||||||
|
// silently creates a fluid_seqbind_t
|
||||||
|
int seqid = fluid_sequencer_register_fluidsynth(seq, synth);
|
||||||
|
fluid_sequencer_unregister_client(seq, seqid);
|
||||||
|
|
||||||
|
// client should be removed, deleting the seq should not free the struct again
|
||||||
|
delete_fluid_sequencer(seq);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void test_unregister_without_unregister(fluid_synth_t *synth)
|
||||||
|
{
|
||||||
|
fluid_sequencer_t *seq = new_fluid_sequencer2(0 /*i.e. use sample timer*/);
|
||||||
|
|
||||||
|
// silently creates a fluid_seqbind_t
|
||||||
|
fluid_sequencer_register_fluidsynth(seq, synth);
|
||||||
|
|
||||||
|
// client should be removed
|
||||||
|
delete_fluid_sequencer(seq);
|
||||||
|
}
|
||||||
|
|
||||||
|
// test to ensure that unregistering and deleting the internal fluid_seqbind_t works without double-free
|
||||||
|
//
|
||||||
|
// valgrind should be used to ensure that there are no memory leaks
|
||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
fluid_settings_t *settings = new_fluid_settings();
|
||||||
|
fluid_synth_t *synth = new_fluid_synth(settings);
|
||||||
|
|
||||||
|
test_unregister_with_event(synth);
|
||||||
|
test_unregister_with_client_unregister(synth);
|
||||||
|
test_unregister_without_unregister(synth);
|
||||||
|
|
||||||
delete_fluid_synth(synth);
|
delete_fluid_synth(synth);
|
||||||
delete_fluid_settings(settings);
|
delete_fluid_settings(settings);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue