Catch more cases of a pointer being marked garbage twice. This helps when
[oota-llvm.git] / unittests / Support / LeakDetectorTest.cpp
1 //===- llvm/unittest/LeakDetector/LeakDetector.cpp - LeakDetector tests ---===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9
10 #include "gtest/gtest.h"
11 #include "llvm/Support/LeakDetector.h"
12
13 using namespace llvm;
14
15 namespace {
16
17 #ifdef GTEST_HAS_DEATH_TEST
18 TEST(LeakDetector, Death1) {
19   LeakDetector::addGarbageObject((void*) 1);
20   LeakDetector::addGarbageObject((void*) 2);
21
22   EXPECT_DEATH(LeakDetector::addGarbageObject((void*) 1),
23                ".*Ts.count\\(o\\) == 0 && \"Object already in set!\"");
24   EXPECT_DEATH(LeakDetector::addGarbageObject((void*) 2),
25                "Cache != o && \"Object already in set!\"");
26 }
27 #endif
28
29 }