1//===-- utilities.cpp -------------------------------------------*- 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#include "gwp_asan/utilities.h"
10#include "gwp_asan/tests/harness.h"
11
12using gwp_asan::check;
13using gwp_asan::checkWithErrorCode;
14
15TEST(UtilitiesDeathTest, CheckPrintsAsExpected) {
16 EXPECT_DEATH({ check(Condition: false, Message: "Hello world"); }, "Hello world");
17 check(Condition: true, Message: "Should not crash");
18 EXPECT_DEATH(
19 { checkWithErrorCode(Condition: false, Message: "Hello world", ErrorCode: 1337); },
20 "Hello world \\(Error Code: 1337\\)");
21 EXPECT_DEATH(
22 { checkWithErrorCode(Condition: false, Message: "Hello world", ErrorCode: -1337); },
23 "Hello world \\(Error Code: -1337\\)");
24}
25

source code of compiler-rt/lib/gwp_asan/tests/utilities.cpp