blob: 26cabbb7930bd14d22d99840a99ebba2fa333ce9 [file] [edit]
//===-- Header for using the gtest framework --------------------*- C++ -*-===//
//
// 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
//
//===----------------------------------------------------------------------===//
#ifndef LLVM_LIBC_TEST_UNITTEST_GTEST_H
#define LLVM_LIBC_TEST_UNITTEST_GTEST_H
#include "src/__support/CPP/string.h"
#include "src/__support/CPP/string_view.h"
#include "src/__support/big_int.h"
#include "src/__support/integer_to_string.h"
#include "src/__support/macros/attributes.h"
#include "src/__support/macros/config.h"
#include "test/UnitTest/TestFilePath.h"
#include "test/UnitTest/TestLogger.h"
#include <gtest/gtest.h>
#include <ostream>
// System <ctype.h> (transitively included via <gtest/gtest.h> and <ostream>)
// may define XSI function-like macros that libc++ <cctype> does not undefine,
// which would otherwise expand inside qualified LIBC_NAMESPACE::isascii /
// toascii calls.
#undef isascii
#undef toascii
namespace LIBC_NAMESPACE_DECL {
namespace cpp {
LIBC_INLINE ::std::ostream &operator<<(::std::ostream &os, string_view sv) {
if (!sv.empty())
os.write(sv.data(), static_cast<::std::streamsize>(sv.size()));
return os;
}
LIBC_INLINE ::std::ostream &operator<<(::std::ostream &os, const string &s) {
if (!s.empty())
os.write(s.data(), static_cast<::std::streamsize>(s.size()));
return os;
}
// NOLINTNEXTLINE(readability-identifier-naming)
LIBC_INLINE void PrintTo(string_view sv, ::std::ostream *os) { *os << sv; }
// NOLINTNEXTLINE(readability-identifier-naming)
LIBC_INLINE void PrintTo(const string &s, ::std::ostream *os) { *os << s; }
} // namespace cpp
template <size_t Bits, bool Signed, typename WordType>
LIBC_INLINE ::std::ostream &
operator<<(::std::ostream &os, const BigInt<Bits, Signed, WordType> &val) {
const IntegerToString<BigInt<Bits, Signed, WordType>, radix::Hex::WithPrefix>
buffer(val);
return os << buffer.view();
}
namespace testing {
using ::testing::Matcher;
using ::testing::Test;
using ::testing::Types;
} // namespace testing
} // namespace LIBC_NAMESPACE_DECL
#define LIBC_TEST_HAS_MATCHERS() (1)
#endif // LLVM_LIBC_TEST_UNITTEST_GTEST_H