47 StrPrintf( &output,
"Hello %s! ",
"World" );
49 StrPrintf( &output,
"Float: %.2f, ", 3.14 );
51 BOOST_CHECK_EQUAL( output, std::string(
"Hello World! Number: 42, Float: 3.14, Char: A. " ) );
55 std::string longString( 500,
'A' );
56 StrPrintf( &output,
"%s", longString.c_str() );
57 BOOST_CHECK_EQUAL( output, longString );
62 #pragma GCC diagnostic ignored "-Wformat-zero-length"
66 #pragma GCC diagnostic warning "-Wformat-zero-length"
68 BOOST_ASSERT( output.empty() );
72 StrPrintf( &output,
"%s, ", longString.c_str() );
74 BOOST_CHECK_EQUAL( output, std::string(
"Small, " + longString +
", End." ) );
78 StrPrintf( &output,
"%d %s %c %.2f", 123,
"Hello",
'X', 9.876 );
79 BOOST_CHECK_EQUAL( output, std::string(
"123 Hello X 9.88" ) );
int StrPrintf(std::string *result, const char *format,...)
This is like sprintf() but the output is appended to a std::string instead of to a character array.
BOOST_AUTO_TEST_SUITE(CadstarPartParser)
BOOST_AUTO_TEST_SUITE_END()
BOOST_AUTO_TEST_CASE(VPrint)
Declare the test suite.