[OptTable] Fix typo VALUE => VALUES (NFCI) (#121523)
[llvm-project.git] / libc / test / src / stdio / printf_test.cpp
blob147d17bb4271f17eedf32b342a950e9e75e7b539
1 //===-- Unittests for printf ---------------------------------------------===//
2 //
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
6 //
7 //===----------------------------------------------------------------------===//
9 #include "src/stdio/printf.h"
11 #include "test/UnitTest/Test.h"
13 TEST(LlvmLibcPrintfTest, PrintOut) {
14 int written;
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);
27 EXPECT_EQ(written,
28 static_cast<int>(sizeof(format_more) + sizeof(short_numbers) - 4));