1 | //===-- Unittests for fputc / putchar -------------------------------------===// |
---|---|
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 | //===----------------------------------------------------------------------===// |
8 | |
9 | #include "src/__support/File/file.h" |
10 | #include "src/stdio/fputc.h" |
11 | #include "src/stdio/putchar.h" |
12 | |
13 | #include "test/UnitTest/Test.h" |
14 | |
15 | TEST(LlvmLibcPutcTest, PrintOut) { |
16 | int result; |
17 | |
18 | constexpr char simple[] = "A simple string written to stdout\n"; |
19 | for (const char &c : simple) { |
20 | result = LIBC_NAMESPACE::putchar(c); |
21 | EXPECT_GE(result, 0); |
22 | } |
23 | |
24 | constexpr char more[] = "A simple string written to stderr\n"; |
25 | for (const char &c : more) { |
26 | result = LIBC_NAMESPACE::fputc( |
27 | c, stream: reinterpret_cast<FILE *>(LIBC_NAMESPACE::stderr)); |
28 | } |
29 | EXPECT_GE(result, 0); |
30 | } |
31 |