vsnprintf_test.cpp 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422
  1. /*
  2. * Copyright 2010-2025 Branimir Karadzic. All rights reserved.
  3. * License: https://github.com/bkaradzic/bx/blob/master/LICENSE
  4. */
  5. #include "test.h"
  6. #include <bx/string.h>
  7. #include <bx/readerwriter.h>
  8. #include <limits>
  9. #include <inttypes.h>
  10. TEST_CASE("No output buffer provided.", "[string][printf]")
  11. {
  12. REQUIRE(4 == bx::snprintf(NULL, 0, "test") );
  13. REQUIRE(4 == bx::snprintf(NULL, 10, "test") );
  14. REQUIRE(1 == bx::snprintf(NULL, 0, "%d", 1) );
  15. REQUIRE(1 == bx::snprintf(NULL, 10, "%d", 1) );
  16. }
  17. TEST_CASE("Truncated output buffer.", "[string][printf]")
  18. {
  19. REQUIRE(4 == bx::snprintf(NULL, 0, "abvg") );
  20. char buffer15[15]; // fit
  21. REQUIRE(4 == bx::snprintf(buffer15, BX_COUNTOF(buffer15), "abvg") );
  22. REQUIRE('\0' == buffer15[4]);
  23. REQUIRE(0 == bx::strCmp(buffer15, "abvg") );
  24. char buffer1[1]; // truncate
  25. REQUIRE(4 == bx::snprintf(buffer1, BX_COUNTOF(buffer1), "abvg") );
  26. REQUIRE('\0' == buffer1[BX_COUNTOF(buffer1)-1]);
  27. buffer1[0] = '\xfb'; // null destination
  28. REQUIRE(4 == bx::snprintf(NULL, BX_COUNTOF(buffer1), "abvg") );
  29. REQUIRE('\xfb' == buffer1[0]);
  30. buffer1[0] = '\xbf'; // one byte destination
  31. REQUIRE(4 == bx::snprintf(buffer1, 1, "abvg") );
  32. REQUIRE('\0' == buffer1[0]);
  33. char buffer7[7]; // truncate
  34. REQUIRE(10 == bx::snprintf(NULL, 0, "Ten chars!") );
  35. REQUIRE(10 == bx::snprintf(buffer7, BX_COUNTOF(buffer7), "Ten chars!") );
  36. REQUIRE('\0' == buffer7[BX_COUNTOF(buffer7)-1]);
  37. REQUIRE(0 == bx::strCmp(buffer7, "Ten ch") );
  38. REQUIRE(7 == bx::snprintf(NULL, 0, "Seven67") );
  39. REQUIRE(7 == bx::snprintf(buffer7, BX_COUNTOF(buffer7), "Seven67") );
  40. REQUIRE('\0' == buffer7[BX_COUNTOF(buffer7)-1]);
  41. REQUIRE(0 == bx::strCmp(buffer7, "Seven6") );
  42. REQUIRE(11 == bx::snprintf(NULL, 0, "SevenEleven") );
  43. REQUIRE(11 == bx::snprintf(buffer7, BX_COUNTOF(buffer7), "SevenEleven") );
  44. REQUIRE('\0' == buffer7[BX_COUNTOF(buffer7)-1]);
  45. REQUIRE(0 == bx::strCmp(buffer7, "SevenE") );
  46. }
  47. template<bool StdCompliantT>
  48. static bool test(const char* _expected, const char* _format, va_list _argList)
  49. {
  50. const int32_t expectedLen = bx::strLen(_expected);
  51. int32_t max = expectedLen + 1024;
  52. char* bxTemp = (char*)BX_STACK_ALLOC(max);
  53. va_list argList;
  54. va_copy(argList, _argList);
  55. const int32_t bxLen = bx::vsnprintf(bxTemp, max, _format, argList);
  56. bool result = true
  57. && bxLen == expectedLen
  58. && 0 == bx::strCmp(_expected, bxTemp)
  59. ;
  60. char* crtTemp = NULL;
  61. int32_t crtLen = 0;
  62. if (!result
  63. || StdCompliantT)
  64. {
  65. BX_ASSERT(bx::strFind(_format, "%S").isEmpty()
  66. , "String format test is using '%%S' bx::StringView specific format specifier which is not standard compliant. "
  67. "Use `testNotStdCompliant` string testing method."
  68. );
  69. crtTemp = (char*)BX_STACK_ALLOC(max);
  70. va_copy(argList, _argList);
  71. crtLen = ::vsnprintf(crtTemp, max, _format, argList);
  72. result &= true
  73. && crtLen == bxLen
  74. && 0 == bx::strCmp(bx::StringView(bxTemp, bxLen), bx::StringView(crtTemp, crtLen) )
  75. ;
  76. }
  77. if (!result)
  78. {
  79. printf("---\n");
  80. printf("printf format '%s'\n", _format);
  81. printf(" bx result (%4d) '%s'\n", bxLen, bxTemp);
  82. printf(" expected (%4d) '%s'\n", expectedLen, _expected);
  83. printf("CRT vsnprintf (%4d) '%s'\n", crtLen, crtTemp);
  84. }
  85. return result;
  86. }
  87. // Test against CRT's vsnprintf implementation.
  88. static bool test(const char* _expected, const char* _format, ...)
  89. {
  90. va_list argList;
  91. va_start(argList, _format);
  92. const bool result = test<false>(_expected, _format, argList);
  93. va_end(argList);
  94. return result;
  95. }
  96. // Skip test against CRT's vsnprintf implementation.
  97. static bool testNotStdCompliant(const char* _expected, const char* _format, ...)
  98. {
  99. va_list argList;
  100. va_start(argList, _format);
  101. const bool result = test<false>(_expected, _format, argList);
  102. va_end(argList);
  103. return result;
  104. }
  105. TEST_CASE("Format %f", "[string][printf]")
  106. {
  107. constexpr double kDoubleNan = bx::bitsToDouble(bx::kDoubleExponentMask | bx::kDoubleMantissaMask);
  108. REQUIRE(test("1.337", "%0.3f", 1.337) );
  109. REQUIRE(test(" 13.370", "%8.3f", 13.37) );
  110. REQUIRE(test(" 13.370", "%*.*f", 8, 3, 13.37) );
  111. REQUIRE(test("13.370 ", "%-8.3f", 13.37) );
  112. REQUIRE(test("13.370 ", "%*.*f", -8, 3, 13.37) );
  113. REQUIRE(test(" -13.370", "% 8.3f", -13.37) );
  114. REQUIRE(test(" 13.370", "% 16.3f", 13.37) );
  115. REQUIRE(test(" -13.370", "% 16.3f", -13.37) );
  116. REQUIRE(test("nan ", "%-8f", kDoubleNan) );
  117. REQUIRE(test(" nan", "%8f", kDoubleNan) );
  118. REQUIRE(test("-NAN ", "%-8F", -kDoubleNan) );
  119. #if !defined(__FAST_MATH__) || !__FAST_MATH__
  120. REQUIRE(test(" inf", "%8f", bx::kDoubleInfinity) );
  121. REQUIRE(test("inf ", "%-8f", bx::kDoubleInfinity) );
  122. REQUIRE(test(" -INF", "%8F", -bx::kDoubleInfinity) );
  123. #endif // !defined(__FAST_MATH__) || !__FAST_MATH__
  124. REQUIRE(test(" 1.0", "%4.1f", 1.0) );
  125. REQUIRE(test(" 1.500", "%6.3f", 1.5) );
  126. REQUIRE(test("0001.500", "%08.3f", 1.5) );
  127. REQUIRE(test("+001.500", "%+08.3f", 1.5) );
  128. REQUIRE(test("-001.500", "%+08.3f", -1.5) );
  129. REQUIRE(test("0.0039", "%.4f", 0.00390625) );
  130. REQUIRE(test("0.003906", "%f", 0.00390625) );
  131. REQUIRE(testNotStdCompliant("-1.234567e-9", "%f", -1.234567e-9) );
  132. REQUIRE(testNotStdCompliant("-1e-9", "%.0f", -1.234567e-9) );
  133. REQUIRE(testNotStdCompliant("-1.2e-9", "%.1f", -1.234567e-9) );
  134. REQUIRE(testNotStdCompliant("-1.23e-9", "%.2f", -1.234567e-9) );
  135. REQUIRE(testNotStdCompliant("-1.234e-9", "%.3f", -1.234567e-9) );
  136. REQUIRE(testNotStdCompliant("-1.2345e-9", "%.4f", -1.234567e-9) );
  137. REQUIRE(testNotStdCompliant("-1.23456e-9", "%.5f", -1.234567e-9) );
  138. REQUIRE(testNotStdCompliant("-1.234567e-9", "%.6f", -1.234567e-9) );
  139. REQUIRE(testNotStdCompliant("-1.2345670e-9", "%.7f", -1.234567e-9) );
  140. REQUIRE(testNotStdCompliant("-1.23456700e-9", "%.8f", -1.234567e-9) );
  141. REQUIRE(testNotStdCompliant("-1.234567000e-9", "%.9f", -1.234567e-9) );
  142. REQUIRE(testNotStdCompliant("-1.2345670000e-9", "%.10f", -1.234567e-9) );
  143. REQUIRE(testNotStdCompliant("3.141592", "%f", 3.1415926535897932) );
  144. REQUIRE(testNotStdCompliant("3.141592", "%F", 3.1415926535897932) );
  145. REQUIRE(testNotStdCompliant("3", "%.0f", 3.1415926535897932) );
  146. REQUIRE(testNotStdCompliant("3.1", "%.1f", 3.1415926535897932) );
  147. REQUIRE(testNotStdCompliant("3.14", "%.2f", 3.1415926535897932) );
  148. REQUIRE(testNotStdCompliant("3.141", "%.3f", 3.1415926535897932) );
  149. REQUIRE(testNotStdCompliant("3.1415", "%.4f", 3.1415926535897932) );
  150. REQUIRE(testNotStdCompliant("3.14159", "%.5f", 3.1415926535897932) );
  151. REQUIRE(testNotStdCompliant("3.141592", "%.6f", 3.1415926535897932) );
  152. REQUIRE(testNotStdCompliant("3.1415926", "%.7f", 3.1415926535897932) );
  153. REQUIRE(testNotStdCompliant("3.14159265", "%.8f", 3.1415926535897932) );
  154. REQUIRE(testNotStdCompliant("3.141592653", "%.9f", 3.1415926535897932) );
  155. REQUIRE(testNotStdCompliant("3.1415926535", "%.10f", 3.1415926535897932) );
  156. REQUIRE(testNotStdCompliant("3.14159265358", "%.11f", 3.1415926535897932) );
  157. REQUIRE(testNotStdCompliant("3.141592653589", "%.12f", 3.1415926535897932) );
  158. REQUIRE(testNotStdCompliant("3.1415926535897", "%.13f", 3.1415926535897932) );
  159. REQUIRE(testNotStdCompliant("3.14159265358979", "%.14f", 3.1415926535897932) );
  160. REQUIRE(testNotStdCompliant("3.141592653589793", "%.15f", 3.1415926535897932) );
  161. REQUIRE(testNotStdCompliant("3.1415926535897930", "%.16f", 3.1415926535897932) );
  162. REQUIRE(testNotStdCompliant("3.1415926535897930", "%.16F", 3.1415926535897932) );
  163. REQUIRE(testNotStdCompliant("-3.141592e-9", "%f", -3.1415926535897932e-9) );
  164. REQUIRE(testNotStdCompliant("-3.141592E-9", "%F", -3.1415926535897932e-9) );
  165. REQUIRE(testNotStdCompliant("-3e-9", "%.0f", -3.1415926535897932e-9) );
  166. REQUIRE(testNotStdCompliant("-3.1e-9", "%.1f", -3.1415926535897932e-9) );
  167. REQUIRE(testNotStdCompliant("-3.14e-9", "%.2f", -3.1415926535897932e-9) );
  168. REQUIRE(testNotStdCompliant("-3.141e-9", "%.3f", -3.1415926535897932e-9) );
  169. REQUIRE(testNotStdCompliant("-3.1415e-9", "%.4f", -3.1415926535897932e-9) );
  170. REQUIRE(testNotStdCompliant("-3.14159e-9", "%.5f", -3.1415926535897932e-9) );
  171. REQUIRE(testNotStdCompliant("-3.141592e-9", "%.6f", -3.1415926535897932e-9) );
  172. REQUIRE(testNotStdCompliant("-3.1415926e-9", "%.7f", -3.1415926535897932e-9) );
  173. REQUIRE(testNotStdCompliant("-3.14159265e-9", "%.8f", -3.1415926535897932e-9) );
  174. REQUIRE(testNotStdCompliant("-3.141592653e-9", "%.9f", -3.1415926535897932e-9) );
  175. REQUIRE(testNotStdCompliant("-3.1415926535e-9", "%.10f", -3.1415926535897932e-9) );
  176. REQUIRE(testNotStdCompliant("-3.14159265358e-9", "%.11f", -3.1415926535897932e-9) );
  177. REQUIRE(testNotStdCompliant("-3.141592653589e-9", "%.12f", -3.1415926535897932e-9) );
  178. REQUIRE(testNotStdCompliant("-3.1415926535897e-9", "%.13f", -3.1415926535897932e-9) );
  179. REQUIRE(testNotStdCompliant("-3.14159265358979e-9", "%.14f", -3.1415926535897932e-9) );
  180. REQUIRE(testNotStdCompliant("-3.141592653589793e-9", "%.15f", -3.1415926535897932e-9) );
  181. REQUIRE(testNotStdCompliant("-3.1415926535897930e-9", "%.16f", -3.1415926535897932e-9) );
  182. REQUIRE(testNotStdCompliant("-3.1415926535897930E-9", "%.16F", -3.1415926535897932e-9) );
  183. REQUIRE(testNotStdCompliant("1e-12", "%f", 1e-12));
  184. REQUIRE(test("0.00390625", "%.8f", 0.00390625) );
  185. REQUIRE(test("-0.00390625", "%.8f", -0.00390625) );
  186. REQUIRE(test("1.50000000000000000", "%.17f", 1.5) );
  187. }
  188. TEST_CASE("Format %d, %i, %o, %u, %x", "[string][printf]")
  189. {
  190. REQUIRE(test("1337", "%d", 1337) );
  191. REQUIRE(test("-1337", "% d", -1337) );
  192. REQUIRE(test("1337 ", "%-20d", 1337) );
  193. REQUIRE(test("-1337 ", "%-20d", -1337) );
  194. REQUIRE(test(" -1337", "% 20d", -1337) );
  195. REQUIRE(test("1337", "%i", 1337) );
  196. REQUIRE(test("1337 ", "%-20i", 1337) );
  197. REQUIRE(test("-1337 ", "%-20i", -1337) );
  198. REQUIRE(test("1337", "%o", 01337) );
  199. REQUIRE(test("2471", "%o", 1337) );
  200. REQUIRE(test("1337 ", "%-20o", 01337) );
  201. REQUIRE(test("37777776441 ", "%-20o", -01337) );
  202. REQUIRE(test(" 2471", "%20o", 1337) );
  203. REQUIRE(test("00000000000000002471", "%020o", 1337) );
  204. REQUIRE(test("1337", "%u", 1337) );
  205. REQUIRE(test("1337 ", "%-20u", 1337) );
  206. REQUIRE(test("4294965959 ", "%-20u", -1337) );
  207. REQUIRE(test("1337", "%x", 0x1337) );
  208. REQUIRE(test("1234abcd ", "%-20x", 0x1234abcd) );
  209. REQUIRE(test("1234ABCD ", "%-20X", 0x1234abcd) );
  210. REQUIRE(test("edcb5433 ", "%-20x", -0x1234abcd) );
  211. REQUIRE(test("EDCB5433 ", "%-20X", -0x1234abcd) );
  212. REQUIRE(test(" 1234abcd", "% 20x", 0x1234abcd) );
  213. REQUIRE(test(" 1234ABCD", "% 20X", 0x1234abcd) );
  214. REQUIRE(test(" edcb5433", "% 20x", -0x1234abcd) );
  215. REQUIRE(test(" EDCB5433", "% 20X", -0x1234abcd) );
  216. REQUIRE(test("0000000000001234abcd", "%020x", 0x1234abcd) );
  217. REQUIRE(test("0000000000001234ABCD", "%020X", 0x1234abcd) );
  218. REQUIRE(test("000000000000edcb5433", "%020x", -0x1234abcd) );
  219. REQUIRE(test("000000000000EDCB5433", "%020X", -0x1234abcd) );
  220. REQUIRE(testNotStdCompliant("0xf", "0x%01x", -1) );
  221. REQUIRE(testNotStdCompliant("0xff", "0x%02x", -1) );
  222. REQUIRE(testNotStdCompliant("0xfff", "0x%03x", -1) );
  223. REQUIRE(testNotStdCompliant("0xffff", "0x%04x", -1) );
  224. REQUIRE(testNotStdCompliant("0xfffff", "0x%05x", -1) );
  225. REQUIRE(testNotStdCompliant("0xffffff", "0x%06x", -1) );
  226. REQUIRE(testNotStdCompliant("0xfffffff", "0x%07x", -1) );
  227. REQUIRE(testNotStdCompliant("0xffffffff", "0x%08x", -1) );
  228. REQUIRE(test(" -1", "% 4i", -1) );
  229. REQUIRE(test(" -1", "% 4i", -1) );
  230. REQUIRE(test(" 0", "% 4i", 0) );
  231. REQUIRE(test(" 1", "% 4i", 1) );
  232. REQUIRE(test(" 1", "% 4o", 1) );
  233. REQUIRE(test(" +1", "%+4i", 1) );
  234. REQUIRE(testNotStdCompliant(" +1", "%+4o", 1) );
  235. REQUIRE(test(" +0", "%+4i", 0) );
  236. REQUIRE(test(" -1", "%+4i", -1) );
  237. REQUIRE(test("0001", "%04i", 1) );
  238. REQUIRE(test("0001", "%04o", 1) );
  239. REQUIRE(test("0000", "%04i", 0) );
  240. REQUIRE(test("0000", "%04o", 0) );
  241. REQUIRE(test("-001", "%04i", -1) );
  242. REQUIRE(test("+001", "%+04i", 1) );
  243. if constexpr (sizeof(intmax_t) == 4)
  244. {
  245. REQUIRE(test("2147483647", "%jd", INTMAX_MAX) );
  246. }
  247. else
  248. {
  249. REQUIRE(test("9223372036854775807", "%jd", INTMAX_MAX) );
  250. }
  251. REQUIRE(test("18446744073709551615", "%" PRIu64, UINT64_MAX) );
  252. REQUIRE(test("ffffffffffffffff", "%016" PRIx64, UINT64_MAX) );
  253. }
  254. TEST_CASE("Format modifiers", "[string][printf]")
  255. {
  256. REQUIRE(test("| 1.000000|", "|%10f|", 1.0f) );
  257. REQUIRE(test("|1.000000 |", "|%-10f|", 1.0f) );
  258. REQUIRE(test("|001.000000|", "|%010f|", 1.0f) );
  259. REQUIRE(test("|0000000001|", "|%010.0f|", 1.0f) );
  260. REQUIRE(test("|000000001.|", "|%#010.0f|", 1.0f) );
  261. REQUIRE(test("| 1|", "|%10.0f|", 1.0f) );
  262. REQUIRE(test("| 1.|", "|%#10.0f|", 1.0f) );
  263. REQUIRE(test("| +1.|", "|%#+10.0f|", 1.0f) );
  264. REQUIRE(test("|1 |", "|%-10.0f|", 1.0f) );
  265. REQUIRE(test("|1. |", "|%#-10.0f|", 1.0f) );
  266. REQUIRE(test("|+1. |", "|%+#-10.0f|", 1.0f) );
  267. REQUIRE(test("| 00013: -00089|", "|%10.5d:%10.5d|", 13, -89) );
  268. REQUIRE(test("| -00013: +00089|", "|%10.5d:%+10.5d|", -13, 89) );
  269. REQUIRE(test("| -00013: -00089|", "|%10.5d:%10.5d|", -13, -89) );
  270. }
  271. TEST_CASE("Format %p", "[string][printf]")
  272. {
  273. REQUIRE(test("0xbadc0de", "%p", (void*)0xbadc0de) );
  274. REQUIRE(test("0xbadc0de ", "%-20p", (void*)0xbadc0de) );
  275. }
  276. TEST_CASE("Format %s", "[string][printf]")
  277. {
  278. REQUIRE(test("(null)", "%s", NULL) );
  279. }
  280. TEST_CASE("Format %td", "[string][printf]")
  281. {
  282. ptrdiff_t size = ptrdiff_t(-1);
  283. REQUIRE(test("-1", "%td", size) );
  284. if constexpr (4 == sizeof(ptrdiff_t) )
  285. {
  286. REQUIRE(test("-1073741824", "%td", ptrdiff_t(3221225472) ) );
  287. }
  288. else
  289. {
  290. REQUIRE(test("3221225472", "%td", ptrdiff_t(3221225472) ) );
  291. }
  292. }
  293. TEST_CASE("Format %n", "[string][printf]")
  294. {
  295. char temp[64];
  296. int32_t p0, p1, p2;
  297. bx::snprintf(temp, sizeof(temp), "%n", &p0);
  298. REQUIRE(0 == p0);
  299. bx::snprintf(temp, sizeof(temp), "01%n23%n45%n", &p0, &p1, &p2);
  300. REQUIRE(2 == p0);
  301. REQUIRE(4 == p1);
  302. REQUIRE(6 == p2);
  303. }
  304. TEST_CASE("Format %g", "[string][printf]")
  305. {
  306. REQUIRE(test(" 0.01", "%7.2g", .01) );
  307. REQUIRE(test(" 0.0123", "%7.4G", .0123) );
  308. // REQUIRE(test("1.23e+05", "%.3g", 123000.25) );
  309. // REQUIRE(test("1e+05", "%.0g", 123000.25) );
  310. }
  311. TEST_CASE("Format %c, %s, %S", "[string][printf]")
  312. {
  313. REQUIRE(test("x", "%c", 'x') );
  314. REQUIRE(test("x ", "%-20c", 'x') );
  315. REQUIRE(test("hello ", "%-20s", "hello") );
  316. REQUIRE(test(" hello", "%10s", "hello") );
  317. REQUIRE(test("hello, world!", "%s, %s!", "hello", "world") );
  318. REQUIRE(testNotStdCompliant("h", "%1s", "hello") );
  319. REQUIRE(testNotStdCompliant("he", "%2s", "hello") );
  320. REQUIRE(testNotStdCompliant("hel", "%3s", "hello") );
  321. REQUIRE(testNotStdCompliant("hell", "%4s", "hello") );
  322. REQUIRE(testNotStdCompliant("hello", "%5s", "hello") );
  323. bx::StringView str("0hello1world2");
  324. bx::StringView hello(str, 1, 5);
  325. bx::StringView world(str, 7, 5);
  326. REQUIRE(test("hello, world!", "%.*s, %.*s!"
  327. , hello.getLength(), hello.getPtr()
  328. , world.getLength(), world.getPtr()
  329. ) );
  330. REQUIRE(testNotStdCompliant("hello, world!", "%S, %S!"
  331. , &hello
  332. , &world
  333. ) );
  334. }
  335. TEST_CASE("WriterI", "[string][printf]")
  336. {
  337. char tmp[64];
  338. bx::StaticMemoryBlock mb(tmp, sizeof(tmp));
  339. bx::MemoryWriter writer(&mb);
  340. bx::Error err;
  341. int32_t len = bx::write(&writer, &err, "%d", 1389);
  342. REQUIRE(err.isOk());
  343. REQUIRE(len == 4);
  344. bx::StringView str(tmp, len);
  345. REQUIRE(0 == bx::strCmp(str, "1389") );
  346. }
  347. TEST_CASE("Invalid", "[string][printf]")
  348. {
  349. char temp[64];
  350. REQUIRE(0 == bx::snprintf(temp, sizeof(temp), "%", 1) );
  351. REQUIRE(0 == bx::snprintf(temp, sizeof(temp), "%-", 1) );
  352. REQUIRE(0 == bx::snprintf(temp, sizeof(temp), "%-0", 1) );
  353. REQUIRE(0 == bx::snprintf(temp, sizeof(temp), "%-03", 1) );
  354. REQUIRE(0 == bx::snprintf(temp, sizeof(temp), "%-03.", 1) );
  355. REQUIRE(0 == bx::snprintf(temp, sizeof(temp), "%-03.0", 1) );
  356. REQUIRE(0 == bx::snprintf(temp, sizeof(temp), "%-03.0t", 1) );
  357. }