Bump version to 19.1.0-rc3
[llvm-project.git] / llvm / unittests / Support / WithColorTest.cpp
blob8afb092575c704fa03d917428f0ba39c13e30be1
1 //===- WithColorTest.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/WithColor.h"
10 #include "gtest/gtest.h"
12 using namespace llvm;
14 TEST(WithColorTest, ColorMode) {
16 std::string S;
17 llvm::raw_string_ostream OS(S);
18 OS.enable_colors(true);
20 WithColor(OS, HighlightColor::Error, ColorMode::Disable) << "test";
21 EXPECT_EQ("test", OS.str());
25 std::string S;
26 llvm::raw_string_ostream OS(S);
27 OS.enable_colors(true);
29 WithColor(OS, HighlightColor::Error, ColorMode::Auto) << "test";
30 EXPECT_EQ("test", OS.str());
33 #ifdef LLVM_ON_UNIX
35 std::string S;
36 llvm::raw_string_ostream OS(S);
37 OS.enable_colors(true);
39 WithColor(OS, HighlightColor::Error, ColorMode::Enable) << "test";
40 EXPECT_EQ("\x1B[0;1;31mtest\x1B[0m", OS.str());
42 #endif