[NFC][Coroutines] Use structured binding with llvm::enumerate in CoroSplit (#116879)
[llvm-project.git] / lldb / unittests / Utility / AnsiTerminalTest.cpp
bloba6dbfd61061420829e1c36681ae584a4ebc486ef
1 //===-- AnsiTerminalTest.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 "gtest/gtest.h"
11 #include "lldb/Utility/AnsiTerminal.h"
13 using namespace lldb_private;
15 TEST(AnsiTerminal, Empty) { EXPECT_EQ("", ansi::FormatAnsiTerminalCodes("")); }
17 TEST(AnsiTerminal, WhiteSpace) {
18 EXPECT_EQ(" ", ansi::FormatAnsiTerminalCodes(" "));
21 TEST(AnsiTerminal, AtEnd) {
22 EXPECT_EQ("abc\x1B[30m",
23 ansi::FormatAnsiTerminalCodes("abc${ansi.fg.black}"));
26 TEST(AnsiTerminal, AtStart) {
27 EXPECT_EQ("\x1B[30mabc",
28 ansi::FormatAnsiTerminalCodes("${ansi.fg.black}abc"));
31 TEST(AnsiTerminal, KnownPrefix) {
32 EXPECT_EQ("${ansi.fg.redish}abc",
33 ansi::FormatAnsiTerminalCodes("${ansi.fg.redish}abc"));
36 TEST(AnsiTerminal, Unknown) {
37 EXPECT_EQ("${ansi.fg.foo}abc",
38 ansi::FormatAnsiTerminalCodes("${ansi.fg.foo}abc"));
41 TEST(AnsiTerminal, Incomplete) {
42 EXPECT_EQ("abc${ansi.", ansi::FormatAnsiTerminalCodes("abc${ansi."));
45 TEST(AnsiTerminal, Twice) {
46 EXPECT_EQ("\x1B[30m\x1B[31mabc",
47 ansi::FormatAnsiTerminalCodes("${ansi.fg.black}${ansi.fg.red}abc"));
50 TEST(AnsiTerminal, Basic) {
51 EXPECT_EQ(
52 "abc\x1B[31mabc\x1B[0mabc",
53 ansi::FormatAnsiTerminalCodes("abc${ansi.fg.red}abc${ansi.normal}abc"));