mirror of
https://github.com/ZDoom/fluidsynth.git
synced 2025-01-31 21:50:37 +00:00
Add test for sfont preset iteration
This commit is contained in:
parent
5a8880560d
commit
c6bdc4bc12
2 changed files with 42 additions and 0 deletions
|
@ -7,6 +7,7 @@ include ( FluidUnitTest )
|
|||
## add unit tests here ##
|
||||
ADD_FLUID_TEST(test_sample_cache)
|
||||
ADD_FLUID_TEST(test_sfont_loading)
|
||||
ADD_FLUID_TEST(test_defsfont_preset_iteration)
|
||||
|
||||
|
||||
add_custom_target(check
|
||||
|
@ -14,4 +15,5 @@ COMMAND ${CMAKE_CTEST_COMMAND} -C $<CONFIG> --output-on-failure
|
|||
DEPENDS
|
||||
test_sample_cache
|
||||
test_sfont_loading
|
||||
test_defsfont_preset_iteration
|
||||
)
|
||||
|
|
40
test/test_defsfont_preset_iteration.c
Normal file
40
test/test_defsfont_preset_iteration.c
Normal file
|
@ -0,0 +1,40 @@
|
|||
#include "test.h"
|
||||
#include "fluidsynth.h"
|
||||
#include "sfloader/fluid_sfont.h"
|
||||
#include "utils/fluidsynth_priv.h"
|
||||
|
||||
int main(void)
|
||||
{
|
||||
char *s;
|
||||
int id;
|
||||
fluid_sfont_t *sfont;
|
||||
fluid_preset_t *preset;
|
||||
fluid_preset_t *prev_preset;
|
||||
int count = 0;
|
||||
|
||||
/* setup */
|
||||
fluid_settings_t *settings = new_fluid_settings();
|
||||
fluid_synth_t *synth = new_fluid_synth(settings);
|
||||
fluid_settings_dupstr(settings, "synth.default-soundfont", &s);
|
||||
id = fluid_synth_sfload(synth, s, 1);
|
||||
sfont = fluid_synth_get_sfont_by_id(synth, id);
|
||||
|
||||
/* code under test */
|
||||
fluid_sfont_iteration_start(sfont);
|
||||
|
||||
while ((preset = fluid_sfont_iteration_next(sfont)) != NULL) {
|
||||
count++;
|
||||
|
||||
/* make sure we actually got a different preset */
|
||||
TEST_ASSERT(preset != prev_preset);
|
||||
prev_preset = preset;
|
||||
}
|
||||
|
||||
TEST_ASSERT(count > 0);
|
||||
|
||||
/* teardown */
|
||||
delete_fluid_synth(synth);
|
||||
delete_fluid_settings(settings);
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
Loading…
Reference in a new issue