29#include <gtest/gtest.h>
39#define CPRINTF_TEST(...) \
41 std::stringstream ss; \
42 ccprintf(ss, __VA_ARGS__); \
43 int maxlen = ss.str().length() + 3; \
44 char *buf = new char[maxlen]; \
45 buf[maxlen - 1] = '\0'; \
46 snprintf(buf, maxlen - 2, __VA_ARGS__); \
47 EXPECT_EQ(ss.str(), std::string(buf)); \
57 CPRINTF_TEST(
"%shits%%s + %smisses%%s\n",
"test",
"test");
58 CPRINTF_TEST(
"%%s%-10s %c he went home \'\"%d %#o %#llx %1.5f %1.2E\n",
59 "hello",
'A', 1, 0xff, 0xfffffffffffffULL, 3.141592653589,
64 CPRINTF_TEST(
"%-10s %c he home \'\"%d %#o %#llx %1.5f %1.2E\n",
65 "hello",
'A', 1, 0xff, 0xfffffffffffffULL,
69TEST(CPrintf, FloatingPoint)
71 double f = 314159.26535897932384;
101 f = 0.00000026535897932384;
129 f = 0.00000026535897932384;
160 std::stringstream
ss;
162 std::string foo1 =
"string test";
164 EXPECT_EQ(
ss.str(),
"string test\n");
167 std::stringstream foo2;
168 foo2 <<
"stringstream test";
170 EXPECT_EQ(
ss.str(),
"stringstream test\n");
176TEST(CPrintf, SpecialFormatting)
#define CPRINTF_TEST(...)
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
void ccprintf(cp::Print &print)