aboutsummaryrefslogtreecommitdiff
path: root/compiler-rt/lib/gwp_asan/tests/utilities.cpp
blob: 09a54e526f5dbc4d218d9213544d0f7702bc0a5e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
//===-- utilities.cpp -------------------------------------------*- 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
//
//===----------------------------------------------------------------------===//

#include "gwp_asan/utilities.h"
#include "gwp_asan/tests/harness.h"

using gwp_asan::check;
using gwp_asan::checkWithErrorCode;

TEST(UtilitiesDeathTest, CheckPrintsAsExpected) {
  EXPECT_DEATH({ check(false, "Hello world"); }, "Hello world");
  check(true, "Should not crash");
  EXPECT_DEATH(
      { checkWithErrorCode(false, "Hello world", 1337); },
      "Hello world \\(Error Code: 1337\\)");
  EXPECT_DEATH(
      { checkWithErrorCode(false, "Hello world", -1337); },
      "Hello world \\(Error Code: -1337\\)");
}