blob: ed228f5da152d1dae2872eb2c5d48f5d0db1414e [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
17TEST(DebugTest, Basic) {
18 std::string s1, s2;
19 raw_string_ostream os1(s1), os2(s2);
20 static const char *DT[] = {"A", "B"};
21
22 llvm::DebugFlag = true;
23 setCurrentDebugTypes(DT, 2);
24 DEBUG_WITH_TYPE("A", os1 << "A");
25 DEBUG_WITH_TYPE("B", os1 << "B");
26 EXPECT_EQ("AB", os1.str());
27
28 setCurrentDebugType("A");
29 DEBUG_WITH_TYPE("A", os2 << "A");
30 DEBUG_WITH_TYPE("B", os2 << "B");
31 EXPECT_EQ("A", os2.str());
32}