1 //===-- Unittests for printf ---------------------------------------------===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 #include "src/stdio/printf.h"
11 #include "test/UnitTest/Test.h"
13 TEST(LlvmLibcPrintfTest
, PrintOut
) {
16 constexpr char simple
[] = "A simple string with no conversions.\n";
17 written
= LIBC_NAMESPACE::printf(simple
);
18 EXPECT_EQ(written
, static_cast<int>(sizeof(simple
) - 1));
20 constexpr char numbers
[] = "1234567890\n";
21 written
= LIBC_NAMESPACE::printf("%s", numbers
);
22 EXPECT_EQ(written
, static_cast<int>(sizeof(numbers
) - 1));
24 constexpr char format_more
[] = "%s and more\n";
25 constexpr char short_numbers
[] = "1234";
26 written
= LIBC_NAMESPACE::printf(format_more
, short_numbers
);
28 static_cast<int>(sizeof(format_more
) + sizeof(short_numbers
) - 4));