2 This file is part of systemd.
4 Copyright 2012 Lennart Poettering
6 systemd is free software; you can redistribute it and/or modify it
7 under the terms of the GNU Lesser General Public License as published by
8 the Free Software Foundation; either version 2.1 of the License, or
9 (at your option) any later version.
11 systemd is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
16 You should have received a copy of the GNU Lesser General Public License
17 along with systemd; If not, see <http://www.gnu.org/licenses/>.
22 #include "string-util.h"
23 #include "terminal-util.h"
26 int main(int argc, char *argv[]) {
29 assert_se(p = strdup("\tFoobar\tbar\twaldo\t"));
30 assert_se(strip_tab_ansi(&p, NULL));
31 fprintf(stdout, "<%s>\n", p);
32 assert_se(streq(p, " Foobar bar waldo "));
35 assert_se(p = strdup(ANSI_HIGHLIGHT "Hello" ANSI_NORMAL ANSI_HIGHLIGHT_RED " world!" ANSI_NORMAL));
36 assert_se(strip_tab_ansi(&p, NULL));
37 fprintf(stdout, "<%s>\n", p);
38 assert_se(streq(p, "Hello world!"));
41 assert_se(p = strdup("\x1B[\x1B[\t\x1B[" ANSI_HIGHLIGHT "\x1B[" "Hello" ANSI_NORMAL ANSI_HIGHLIGHT_RED " world!" ANSI_NORMAL));
42 assert_se(strip_tab_ansi(&p, NULL));
43 assert_se(streq(p, "\x1B[\x1B[ \x1B[\x1B[Hello world!"));
46 assert_se(p = strdup("\x1B[waldo"));
47 assert_se(strip_tab_ansi(&p, NULL));
48 assert_se(streq(p, "\x1B[waldo"));