Bump version to 19.1.0-rc3
[llvm-project.git] / llvm / unittests / Support / DebugTest.cpp
blobe68e3764b4383954e7746e95b1355748d9d1e9e1
1 //===- llvm/unittest/Support/DebugTest.cpp --------------------------------===//
2 //
3 // 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
6 //
7 //===----------------------------------------------------------------------===//
9 #include "llvm/Support/Debug.h"
10 #include "llvm/Support/raw_ostream.h"
11 #include "gtest/gtest.h"
13 #include <string>
14 using namespace llvm;
16 #ifndef NDEBUG
17 TEST(DebugTest, Basic) {
18 std::string s1, s2;
19 raw_string_ostream os1(s1), os2(s2);
20 static const char *DT[] = {"A", "B"};
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());
28 setCurrentDebugType("A");
29 DEBUG_WITH_TYPE("A", os2 << "A");
30 DEBUG_WITH_TYPE("B", os2 << "B");
31 EXPECT_EQ("A", os2.str());
33 #endif