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