mirror of
https://github.com/ZDoom/fluidsynth.git
synced 2025-01-31 13:40:35 +00:00
add a unit test for C99 compliant FLUID_SNPRINTF
This commit is contained in:
parent
75e168cb58
commit
04a5224eb9
2 changed files with 24 additions and 0 deletions
|
@ -14,6 +14,7 @@ ADD_FLUID_TEST(test_sfont_loading)
|
|||
ADD_FLUID_TEST(test_sample_rate_change)
|
||||
ADD_FLUID_TEST(test_preset_sample_loading)
|
||||
ADD_FLUID_TEST(test_seqbind_unregister)
|
||||
ADD_FLUID_TEST(test_snprintf)
|
||||
|
||||
if ( LIBSNDFILE_HASVORBIS )
|
||||
ADD_FLUID_TEST(test_sf3_sfont_loading)
|
||||
|
|
23
test/test_snprintf.c
Normal file
23
test/test_snprintf.c
Normal file
|
@ -0,0 +1,23 @@
|
|||
|
||||
#include "test.h"
|
||||
#include "utils/fluidsynth_priv.h"
|
||||
|
||||
// this test makes sure FLUID_SNPRINTF uses a proper C99 compliant implementation
|
||||
|
||||
int main(void)
|
||||
{
|
||||
char buf[2+1];
|
||||
|
||||
int ret = FLUID_SNPRINTF(buf, sizeof(buf), "99");
|
||||
TEST_ASSERT(ret == 2);
|
||||
|
||||
TEST_ASSERT(buf[2] == '\0');
|
||||
|
||||
ret = FLUID_SNPRINTF(buf, sizeof(buf), "999");
|
||||
TEST_ASSERT(ret == 3);
|
||||
|
||||
// output truncated, buffer must be NULL terminated!
|
||||
TEST_ASSERT(buf[2] == '\0');
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
Loading…
Reference in a new issue