2018-05-17 12:56:55 +00:00
|
|
|
|
|
|
|
#include "test.h"
|
2019-02-15 11:28:22 +00:00
|
|
|
#include "utils/fluid_sys.h"
|
2018-05-17 12:56:55 +00:00
|
|
|
|
|
|
|
// this test makes sure FLUID_SNPRINTF uses a proper C99 compliant implementation
|
|
|
|
|
|
|
|
int main(void)
|
|
|
|
{
|
2018-06-24 11:01:31 +00:00
|
|
|
char buf[2 + 1];
|
2018-05-17 12:56:55 +00:00
|
|
|
|
|
|
|
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;
|
|
|
|
}
|