From c089e406b9d7e654fda5e27f34b5747553d75d15 Mon Sep 17 00:00:00 2001 From: Eugene Leviant Date: Tue, 27 Dec 2016 09:31:20 +0000 Subject: Allow setting multiple debug types Differential revision: https://reviews.llvm.org/D28109 llvm-svn: 290597 --- llvm/unittests/Support/DebugTest.cpp | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 llvm/unittests/Support/DebugTest.cpp (limited to 'llvm/unittests/Support/DebugTest.cpp') diff --git a/llvm/unittests/Support/DebugTest.cpp b/llvm/unittests/Support/DebugTest.cpp new file mode 100644 index 00000000000..ed228f5da15 --- /dev/null +++ b/llvm/unittests/Support/DebugTest.cpp @@ -0,0 +1,32 @@ +//===- llvm/unittest/Support/DebugTest.cpp --------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include "llvm/Support/Debug.h" +#include "llvm/Support/raw_ostream.h" +#include "gtest/gtest.h" + +#include +using namespace llvm; + +TEST(DebugTest, Basic) { + std::string s1, s2; + raw_string_ostream os1(s1), os2(s2); + static const char *DT[] = {"A", "B"}; + + llvm::DebugFlag = true; + setCurrentDebugTypes(DT, 2); + DEBUG_WITH_TYPE("A", os1 << "A"); + DEBUG_WITH_TYPE("B", os1 << "B"); + EXPECT_EQ("AB", os1.str()); + + setCurrentDebugType("A"); + DEBUG_WITH_TYPE("A", os2 << "A"); + DEBUG_WITH_TYPE("B", os2 << "B"); + EXPECT_EQ("A", os2.str()); +} -- cgit v1.2.3