1 //===- WithColorTest.cpp --------------------------------------------------===//
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
7 //===----------------------------------------------------------------------===//
9 #include "llvm/Support/WithColor.h"
10 #include "llvm/Config/llvm-config.h" // for LLVM_ON_UNIX
11 #include "gtest/gtest.h"
15 TEST(WithColorTest
, ColorMode
) {
18 llvm::raw_string_ostream
OS(S
);
19 OS
.enable_colors(true);
21 WithColor(OS
, HighlightColor::Error
, ColorMode::Disable
) << "test";
27 llvm::raw_string_ostream
OS(S
);
28 OS
.enable_colors(true);
30 WithColor(OS
, HighlightColor::Error
, ColorMode::Auto
) << "test";
37 llvm::raw_string_ostream
OS(S
);
38 OS
.enable_colors(true);
40 WithColor(OS
, HighlightColor::Error
, ColorMode::Enable
) << "test";
41 EXPECT_EQ("\x1B[0;1;31mtest\x1B[0m", S
);