blob: e68e3764b4383954e7746e95b1355748d9d1e9e1 [file] [log] [blame]
Eugene Leviantc089e402016-12-27 09:31:20 +00001//===- llvm/unittest/Support/DebugTest.cpp --------------------------------===//
2//
Chandler Carruth2946cd72019-01-19 08:50:56 +00003// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
Eugene Leviantc089e402016-12-27 09:31:20 +00006//
7//===----------------------------------------------------------------------===//
8
9#include "llvm/Support/Debug.h"
10#include "llvm/Support/raw_ostream.h"
11#include "gtest/gtest.h"
12
13#include <string>
14using namespace llvm;
15
Eugene Leviantc2f54082016-12-27 11:07:53 +000016#ifndef NDEBUG
Eugene Leviantc089e402016-12-27 09:31:20 +000017TEST(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}
Eugene Leviantc2f54082016-12-27 11:07:53 +000033#endif