remove redundant TEST_ASSERT_[N]EQ macros

This commit is contained in:
derselbst 2018-04-11 10:23:17 +02:00
parent f4f439180d
commit 713a4b680d
3 changed files with 23 additions and 24 deletions

View file

@ -6,6 +6,5 @@
#define TEST_ASSERT(COND) if (!(COND)) { fprintf(stderr, __FILE__ ":%d assertion ("#COND") failed\n", __LINE__); exit(-1); }
#define TEST_ASSERT_EQ(LHS, RHS) TEST_ASSERT((LHS) == (RHS))
#define TEST_ASSERT_NEQ(LHS, RHS) TEST_ASSERT((LHS) != (RHS))
#define TEST_SUCCESS(FLUID_FUNCT) TEST_ASSERT_NEQ((FLUID_FUNCT), FLUID_FAILED)
/* macro to test whether a fluidsynth function succeeded or not */
#define TEST_SUCCESS(FLUID_FUNCT) TEST_ASSERT((FLUID_FUNCT) != FLUID_FAILED)

View file

@ -15,13 +15,13 @@ int main(void)
fluid_synth_t *synth1 = new_fluid_synth(settings),
*synth2 = new_fluid_synth(settings);
TEST_ASSERT_NEQ(settings, NULL);
TEST_ASSERT_NEQ(synth1, NULL);
TEST_ASSERT_NEQ(synth2, NULL);
TEST_ASSERT(settings != NULL);
TEST_ASSERT(synth1 != NULL);
TEST_ASSERT(synth2 != NULL);
TEST_SUCCESS(fluid_settings_dupstr(settings, "synth.default-soundfont", &s))
TEST_ASSERT_NEQ(s[0], '\0');
TEST_ASSERT(s[0] != '\0');
printf("Attempt to open %s\n", s);

View file

@ -16,53 +16,53 @@ int main(void)
fluid_settings_t *settings = new_fluid_settings();
fluid_synth_t *synth = new_fluid_synth(settings);
TEST_ASSERT_NEQ(settings, NULL);
TEST_ASSERT_NEQ(synth, NULL);
TEST_ASSERT(settings != NULL);
TEST_ASSERT(synth != NULL);
// no sfont loaded
TEST_ASSERT_EQ(fluid_synth_sfcount(synth), 0);
TEST_ASSERT(fluid_synth_sfcount(synth) == 0);
TEST_SUCCESS(fluid_settings_dupstr(settings, "synth.default-soundfont", &s))
TEST_ASSERT_NEQ(s[0], '\0');
TEST_ASSERT(s[0] != '\0');
FLUID_LOG(FLUID_INFO, "Attempt to open %s", s);
// load a sfont to synth
TEST_SUCCESS(id = fluid_synth_sfload(synth, s, 1));
// one sfont loaded
TEST_ASSERT_EQ(fluid_synth_sfcount(synth), 1);
TEST_ASSERT_NEQ(sfont = fluid_synth_get_sfont_by_id(synth, id), NULL);
TEST_ASSERT(fluid_synth_sfcount(synth) == 1);
TEST_ASSERT((sfont = fluid_synth_get_sfont_by_id(synth, id)) != NULL);
// this is still the same filename as we've put in
TEST_ASSERT_EQ(FLUID_STRCMP(s, fluid_sfont_get_name(sfont)), 0);
TEST_ASSERT_EQ(fluid_sfont_get_id(sfont), id);
TEST_ASSERT(FLUID_STRCMP(s, fluid_sfont_get_name(sfont)) == 0);
TEST_ASSERT(fluid_sfont_get_id(sfont) == id);
// still the same id?
TEST_ASSERT_EQ(fluid_synth_sfreload(synth, id), id);
TEST_ASSERT(fluid_synth_sfreload(synth, id) == id);
// one sfont loaded
TEST_ASSERT_EQ(fluid_synth_sfcount(synth), 1);
TEST_ASSERT_NEQ(sfont = fluid_synth_get_sfont_by_id(synth, id), NULL);
TEST_ASSERT(fluid_synth_sfcount(synth) == 1);
TEST_ASSERT((sfont = fluid_synth_get_sfont_by_id(synth, id)) != NULL);
// still the same filename?
TEST_ASSERT_EQ(FLUID_STRCMP(s, fluid_sfont_get_name(sfont)), 0);
TEST_ASSERT(FLUID_STRCMP(s, fluid_sfont_get_name(sfont)) == 0);
// correct id stored?
TEST_ASSERT_EQ(fluid_sfont_get_id(sfont), id);
TEST_ASSERT(fluid_sfont_get_id(sfont) == id);
// remove the sfont without deleting
TEST_SUCCESS(fluid_synth_remove_sfont(synth, sfont));
// no sfont loaded
TEST_ASSERT_EQ(fluid_synth_sfcount(synth), 0);
TEST_ASSERT(fluid_synth_sfcount(synth) == 0);
// re-add the sfont without deleting
TEST_SUCCESS(id = fluid_synth_add_sfont(synth, sfont));
// one sfont loaded
TEST_ASSERT_EQ(fluid_synth_sfcount(synth), 1);
TEST_ASSERT(fluid_synth_sfcount(synth) == 1);
// destroy the sfont
TEST_SUCCESS(fluid_synth_sfunload(synth, id, 0));
// no sfont loaded
TEST_ASSERT_EQ(fluid_synth_sfcount(synth), 0);
TEST_ASSERT(fluid_synth_sfcount(synth) == 0);
delete_fluid_synth(synth);
delete_fluid_settings(settings);