aboutsummaryrefslogtreecommitdiffstats
path: root/unittests/IR/LeakDetectorTest.cpp
blob: 94eed4c1432b6e54c4365197f2385925c08281b1 (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
25
26
27
28
29
30
31
//===- LeakDetectorTest.cpp -----------------------------------------------===//
//
//                     The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//

#include "llvm/IR/LeakDetector.h"
#include "gtest/gtest.h"

using namespace llvm;

namespace {

#ifdef GTEST_HAS_DEATH_TEST
#ifndef NDEBUG
TEST(LeakDetector, Death1) {
  LeakDetector::addGarbageObject((void*) 1);
  LeakDetector::addGarbageObject((void*) 2);

  EXPECT_DEATH(LeakDetector::addGarbageObject((void*) 1),
               ".*Ts.count\\(o\\) == 0 && \"Object already in set!\"");
  EXPECT_DEATH(LeakDetector::addGarbageObject((void*) 2),
               "Cache != o && \"Object already in set!\"");
}
#endif
#endif

}