brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.1 KiB · b3bd827 Raw
45 lines · cpp
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-exception6//7//===----------------------------------------------------------------------===//8 9#include "llvm/Support/WithColor.h"10#include "llvm/Config/llvm-config.h" // for LLVM_ON_UNIX11#include "gtest/gtest.h"12 13using namespace llvm;14 15TEST(WithColorTest, ColorMode) {16  {17    std::string S;18    llvm::raw_string_ostream OS(S);19    OS.enable_colors(true);20 21    WithColor(OS, HighlightColor::Error, ColorMode::Disable) << "test";22    EXPECT_EQ("test", S);23  }24 25  {26    std::string S;27    llvm::raw_string_ostream OS(S);28    OS.enable_colors(true);29 30    WithColor(OS, HighlightColor::Error, ColorMode::Auto) << "test";31    EXPECT_EQ("test", S);32  }33 34#ifdef LLVM_ON_UNIX35  {36    std::string S;37    llvm::raw_string_ostream OS(S);38    OS.enable_colors(true);39 40    WithColor(OS, HighlightColor::Error, ColorMode::Enable) << "test";41    EXPECT_EQ("\x1B[0;1;31mtest\x1B[0m", S);42  }43#endif44}45