diff options
Diffstat (limited to 'test.pl')
-rwxr-xr-x | test.pl | 41 |
1 files changed, 39 insertions, 2 deletions
@@ -13,7 +13,7 @@ use Getopt::Long qw(:config no_auto_abbrev no_ignore_case); use Test::Harness qw(runtests); use Test::More; -my $tests = 32; +my $tests = 38; my $valgrind_cmd = ''; { @@ -101,7 +101,7 @@ SKIP: { { my $ok = true; - foreach my $option (qw(--attr=bold --exclude-random=black --omit-color-empty)) { + foreach my $option (qw(--attr=bold --exclude-random=black --omit-color-empty --rainbow-fg --rainbow-bg)) { $ok &= qx($valgrind_cmd$program $option $switch $infile1 2>&1 >/dev/null) =~ /switch has no meaning with/; } ok($ok, "$type strict options"); @@ -135,6 +135,23 @@ SKIP: { is_deeply([split /\n/, qx(cat $infile2 | $valgrind_cmd$program none/none)], [split /\n/, $repeated], "read ${\length $repeated} bytes (BUF_SIZE=$BUF_SIZE{normal})"); + SKIP: { + my $program_buf = tmpnam(); + skip 'compiling failed (short buffer)', 2 unless system("$compiler -DTEST -DBUF_SIZE=$BUF_SIZE{short} -o $program_buf $source") == 0; + + my $short_text = 'foo bar baz' x 2; + + is(qx(printf %s "$short_text" | $valgrind_cmd$program_buf blue --rainbow-fg), + "\e[34mfoo bar ba\e[0m\e[34mzfoo bar b\e[0m\e[34maz\e[0m", + "partial line (BUF_SIZE=$BUF_SIZE{short}, rainbow-fg)"); + + is(qx(printf %s "$short_text" | $valgrind_cmd$program_buf blue/black --rainbow-bg), + "\e[40m\e[34mfoo bar ba\e[0m\e[40m\e[34mzfoo bar b\e[0m\e[40m\e[34maz\e[0m", + "partial line (BUF_SIZE=$BUF_SIZE{short}, rainbow-bg)"); + + unlink $program_buf; + } + { my $colored_text = qx(printf '%s\n' "foo bar baz" | $valgrind_cmd$program red); my $sequences = 0; @@ -160,6 +177,26 @@ SKIP: { 'switch omit-color-empty'); } + { + my $infile = $write_to_tmpfile->("foo\nbar\nbaz"); + + is_deeply([split /\n/, qx($valgrind_cmd$program black/black --rainbow-fg $infile)], + [split /\n/, "\e[40m\e[31mfoo\e[0m\n\e[40m\e[32mbar\e[0m\n\e[40m\e[33mbaz\e[0m"], + 'switch rainbow-fg (init)'); + + is_deeply([split /\n/, qx($valgrind_cmd$program white --rainbow-fg $infile)], + [split /\n/, "\e[37mfoo\e[0m\n\e[30mbar\e[0m\n\e[31mbaz\e[0m"], + 'switch rainbow-fg (reset)'); + + is_deeply([split /\n/, qx($valgrind_cmd$program black/black --rainbow-bg $infile)], + [split /\n/, "\e[41m\e[30mfoo\e[0m\n\e[42m\e[30mbar\e[0m\n\e[43m\e[30mbaz\e[0m"], + 'switch rainbow-bg (init)'); + + is_deeply([split /\n/, qx($valgrind_cmd$program green/white --rainbow-bg $infile)], + [split /\n/, "\e[47m\e[32mfoo\e[0m\n\e[40m\e[32mbar\e[0m\n\e[41m\e[32mbaz\e[0m"], + 'switch rainbow-bg (reset)'); + } + SKIP: { skip 'valgrind not found', 1 unless system('which valgrind >/dev/null 2>&1') == 0; like(qx(valgrind $program none/none $infile1 2>&1 >/dev/null), qr/no leaks are possible/, 'valgrind memleaks'); |