llvm/libc/test/UnitTest/LibcTest.cpp

//===-- Implementation of the base class for libc unittests----------------===//
//
// 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 "LibcTest.h"

#include "include/llvm-libc-macros/stdfix-macros.h"
#include "src/__support/CPP/string.h"
#include "src/__support/CPP/string_view.h"
#include "src/__support/fixed_point/fx_rep.h"
#include "src/__support/macros/config.h"
#include "src/__support/macros/properties/types.h" // LIBC_TYPES_HAS_INT128
#include "src/__support/uint128.h"
#include "test/UnitTest/TestLogger.h"

#if __STDC_HOSTED__
#include <time.h>
#define LIBC_TEST_USE_CLOCK
#elif defined(TARGET_SUPPORTS_CLOCK)
#include <time.h>

#include "src/time/clock.h"
extern "C" clock_t clock() noexcept { return LIBC_NAMESPACE::clock(); }
#define LIBC_TEST_USE_CLOCK
#endif

namespace LIBC_NAMESPACE_DECL {
namespace testing {

namespace internal {

TestLogger &operator<<(TestLogger &logger, Location Loc) {}

// When the value is UInt128, __uint128_t or wider, show its hexadecimal
// digits.
template <typename T>
cpp::enable_if_t<(cpp::is_integral_v<T> && (sizeof(T) > sizeof(uint64_t))) ||
                     is_big_int_v<T>,
                 cpp::string>
describeValue(T Value) {}

// When the value is of a standard integral type, just display it as normal.
template <typename T>
cpp::enable_if_t<cpp::is_integral_v<T> && (sizeof(T) <= sizeof(uint64_t)),
                 cpp::string>
describeValue(T Value) {}

#ifdef LIBC_COMPILER_HAS_FIXED_POINT
template <typename T>
cpp::enable_if_t<cpp::is_fixed_point_v<T>, cpp::string> describeValue(T Value) {
  using FXRep = fixed_point::FXRep<T>;
  using comp_t = typename FXRep::CompType;

  return cpp::to_string(cpp::bit_cast<comp_t>(Value)) + " * 2^-" +
         cpp::to_string(FXRep::FRACTION_LEN);
}
#endif // LIBC_COMPILER_HAS_FIXED_POINT

cpp::string_view describeValue(const cpp::string &Value) {}
cpp::string_view describeValue(cpp::string_view Value) {}

template <typename ValType>
bool test(RunContext *Ctx, TestCond Cond, ValType LHS, ValType RHS,
          const char *LHSStr, const char *RHSStr, Location Loc) {}

} // namespace internal

Test *Test::Start =;
Test *Test::End =;

int argc =;
char **argv =;
char **envp =;

RunContext;

void Test::addTest(Test *T) {}

int Test::getNumTests() {}

int Test::runTests(const TestOptions &Options) {}

internal // namespace internal

bool Test::testStrEq(const char *LHS, const char *RHS, const char *LHSStr,
                     const char *RHSStr, internal::Location Loc) {}

bool Test::testStrNe(const char *LHS, const char *RHS, const char *LHSStr,
                     const char *RHSStr, internal::Location Loc) {}

bool Test::testMatch(bool MatchResult, MatcherBase &Matcher, const char *LHSStr,
                     const char *RHSStr, internal::Location Loc) {}

} // namespace testing
} // namespace LIBC_NAMESPACE_DECL