Files
bx/tests/vsnprintf_test.cpp
Branimir Karadžić e531142c79 Added vsnprintf test.
2017-01-17 12:11:22 -08:00

23 lines
543 B
C++

/*
* Copyright 2010-2017 Branimir Karadzic. All rights reserved.
* License: https://github.com/bkaradzic/bx#license-bsd-2-clause
*/
#include "test.h"
#include <bx/string.h>
TEST_CASE("vsnprintf NULL buffer", "No output buffer provided.")
{
REQUIRE(4 == bx::snprintf(NULL, 0, "test") );
REQUIRE(1 == bx::snprintf(NULL, 0, "%d", 1) );
}
TEST_CASE("vsnprintf truncated", "Truncated output buffer.")
{
char buffer[7];
REQUIRE(10 == bx::snprintf(buffer, BX_COUNTOF(buffer), "Ten chars!") );
REQUIRE(0 == strcmp(buffer, "Ten ch") );
}