1 //===-- Header for using Fuchsia's zxtest framework ------------*- C++ -*-===// 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 #ifndef LLVM_LIBC_UTILS_UNITTEST_ZXTEST_H 10 #define LLVM_LIBC_UTILS_UNITTEST_ZXTEST_H 11 12 #include <zxtest/zxtest.h> 13 14 #define WITH_SIGNAL(X) #X 15 16 // These macros are used in string unittests. 17 #define ASSERT_ERRNO_EQ(VAL) \ 18 ASSERT_EQ(VAL, static_cast<int>(LIBC_NAMESPACE::libc_errno)) 19 #define ASSERT_ERRNO_SUCCESS() \ 20 ASSERT_EQ(0, static_cast<int>(LIBC_NAMESPACE::libc_errno)) 21 #define ASSERT_ERRNO_FAILURE() \ 22 ASSERT_NE(0, static_cast<int>(LIBC_NAMESPACE::libc_errno)) 23 24 #ifndef EXPECT_DEATH 25 // Since zxtest has ASSERT_DEATH but not EXPECT_DEATH, wrap calling it 26 // in a lambda returning void to swallow any early returns so that this 27 // can be used in a function that itself returns non-void. 28 #define EXPECT_DEATH(FUNC, SIG) ([&] { ASSERT_DEATH(FUNC, SIG); }()) 29 #endif 30 31 namespace LIBC_NAMESPACE::testing { 32 33 using Test = ::zxtest::Test; 34 35 } // namespace LIBC_NAMESPACE::testing 36 37 // zxtest does not have gmock-style matchers. 38 #define LIBC_TEST_HAS_MATCHERS() (0) 39 40 #endif // LLVM_LIBC_UTILS_UNITTEST_ZXTEST_H 41