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