blob: 7db91ff0d854fb83876b8e86861e1a1860ec39cd [file] [log] [blame]
Eugene Leviantc089e402016-12-27 09:31:20 +00001//===- llvm/unittest/Support/DebugTest.cpp --------------------------------===//
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 "llvm/Support/Debug.h"
11#include "llvm/Support/raw_ostream.h"
12#include "gtest/gtest.h"
13
14#include <string>
15using namespace llvm;
16
Eugene Leviantc2f54082016-12-27 11:07:53 +000017#ifndef NDEBUG
Eugene Leviantc089e402016-12-27 09:31:20 +000018TEST(DebugTest, Basic) {
19 std::string s1, s2;
20 raw_string_ostream os1(s1), os2(s2);
21 static const char *DT[] = {"A", "B"};
22
23 llvm::DebugFlag = true;
24 setCurrentDebugTypes(DT, 2);
25 DEBUG_WITH_TYPE("A", os1 << "A");
26 DEBUG_WITH_TYPE("B", os1 << "B");
27 EXPECT_EQ("AB", os1.str());
28
29 setCurrentDebugType("A");
30 DEBUG_WITH_TYPE("A", os2 << "A");
31 DEBUG_WITH_TYPE("B", os2 << "B");
32 EXPECT_EQ("A", os2.str());
33}
Eugene Leviantc2f54082016-12-27 11:07:53 +000034#endif