aboutsummaryrefslogtreecommitdiff
path: root/libc/test/src/stdio/fputc_test.cpp
blob: 0a776f70e353ddd1327c2604a5ccb1b7d75c6300 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
//===-- Unittests for fputc / putchar -------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

#include "src/__support/File/file.h"
#include "src/stdio/fputc.h"
#include "src/stdio/putchar.h"

#include "test/UnitTest/Test.h"

TEST(LlvmLibcPutcTest, PrintOut) {
  int result;

  constexpr char simple[] = "A simple string written to stdout\n";
  for (const char &c : simple) {
    result = LIBC_NAMESPACE::putchar(c);
    EXPECT_GE(result, 0);
  }

  constexpr char more[] = "A simple string written to stderr\n";
  for (const char &c : more) {
    result = LIBC_NAMESPACE::fputc(
        c, reinterpret_cast<FILE *>(LIBC_NAMESPACE::stderr));
  }
  EXPECT_GE(result, 0);
}