summaryrefslogtreecommitdiffstats
path: root/util/stream/printf_ut.cpp
diff options
context:
space:
mode:
authorDevtools Arcadia <[email protected]>2022-02-07 18:08:42 +0300
committerDevtools Arcadia <[email protected]>2022-02-07 18:08:42 +0300
commit1110808a9d39d4b808aef724c861a2e1a38d2a69 (patch)
treee26c9fed0de5d9873cce7e00bc214573dc2195b7 /util/stream/printf_ut.cpp
intermediate changes
ref:cde9a383711a11544ce7e107a78147fb96cc4029
Diffstat (limited to 'util/stream/printf_ut.cpp')
-rw-r--r--util/stream/printf_ut.cpp33
1 files changed, 33 insertions, 0 deletions
diff --git a/util/stream/printf_ut.cpp b/util/stream/printf_ut.cpp
new file mode 100644
index 00000000000..0eab1670625
--- /dev/null
+++ b/util/stream/printf_ut.cpp
@@ -0,0 +1,33 @@
+#include "null.h"
+#include "printf.h"
+#include "str.h"
+
+#include <util/generic/string.h>
+
+#include <library/cpp/testing/unittest/registar.h>
+
+Y_UNIT_TEST_SUITE(TStreamPrintfTest) {
+ Y_UNIT_TEST(TestPrintf) {
+ TStringStream ss;
+
+ UNIT_ASSERT_EQUAL(Printf(ss, "qw %s %d", "er", 1), 7);
+ UNIT_ASSERT_EQUAL(ss.Str(), "qw er 1");
+ }
+
+#ifdef __GNUC__
+ #pragma GCC diagnostic ignored "-Wformat-zero-length"
+#endif // __GNUC__
+
+ Y_UNIT_TEST(TestZeroString) {
+ UNIT_ASSERT_EQUAL(Printf(Cnull, ""), 0);
+ }
+
+ Y_UNIT_TEST(TestLargePrintf) {
+ TString s = NUnitTest::RandomString(1000000);
+ TStringStream ss;
+
+ Printf(ss, "%s", s.data());
+
+ UNIT_ASSERT_EQUAL(ss.Str(), s);
+ }
+}