blob: d198c7a8bda0bc7fccc1fd7d454fc91558a657f8 [file] [log] [blame]
Shih-wei Liaoe264f622010-02-10 11:10:31 -08001//===- 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
13using namespace llvm;
14
15namespace {
16
17#ifdef GTEST_HAS_DEATH_TEST
Shih-wei Liao7abe37e2010-04-28 01:47:00 -070018#ifndef NDEBUG
Shih-wei Liaoe264f622010-02-10 11:10:31 -080019TEST(LeakDetector, Death1) {
20 LeakDetector::addGarbageObject((void*) 1);
21 LeakDetector::addGarbageObject((void*) 2);
22
23 EXPECT_DEATH(LeakDetector::addGarbageObject((void*) 1),
24 ".*Ts.count\\(o\\) == 0 && \"Object already in set!\"");
25 EXPECT_DEATH(LeakDetector::addGarbageObject((void*) 2),
26 "Cache != o && \"Object already in set!\"");
27}
28#endif
Shih-wei Liao7abe37e2010-04-28 01:47:00 -070029#endif
Shih-wei Liaoe264f622010-02-10 11:10:31 -080030
31}