From: Timo Hirvonen <tihirvon@gmail.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: git@vger.kernel.org
Subject: [PATCH] Add tests for diff/status color parser
Date: Wed, 6 Feb 2008 14:16:26 +0200 [thread overview]
Message-ID: <20080206141626.0f2b532c.tihirvon@gmail.com> (raw)
In-Reply-To: <7vzluez9q9.fsf@gitster.siamese.dyndns.org>
Signed-off-by: Timo Hirvonen <tihirvon@gmail.com>
---
I don't know if t4026-color.sh is good name for this. Feel free to change.
t/t4026-color.sh | 69 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 69 insertions(+), 0 deletions(-)
create mode 100755 t/t4026-color.sh
diff --git a/t/t4026-color.sh b/t/t4026-color.sh
new file mode 100755
index 0000000..b61e516
--- /dev/null
+++ b/t/t4026-color.sh
@@ -0,0 +1,69 @@
+#!/bin/sh
+#
+# Copyright (c) 2008 Timo Hirvonen
+#
+
+test_description='Test diff/status color escape codes'
+. ./test-lib.sh
+
+color()
+{
+ git config diff.color.new "$1" &&
+ test "`git config --get-color diff.color.new`" = "^[$2"
+}
+
+invalid_color()
+{
+ git config diff.color.new "$1" &&
+ test -z "`git config --get-color diff.color.new 2>/dev/null`"
+}
+
+test_expect_success 'reset' '
+ color "reset" "[m"
+'
+
+test_expect_success 'attribute before color name' '
+ color "bold red" "[1;31m"
+'
+
+test_expect_success 'color name before attribute' '
+ color "red bold" "[1;31m"
+'
+
+test_expect_success 'attr fg bg' '
+ color "ul blue red" "[4;34;41m"
+'
+
+test_expect_success 'fg attr bg' '
+ color "blue ul red" "[4;34;41m"
+'
+
+test_expect_success 'fg bg attr' '
+ color "blue red ul" "[4;34;41m"
+'
+
+test_expect_success '256 colors' '
+ color "254 bold 255" "[1;38;5;254;48;5;255m"
+'
+
+test_expect_success 'color too small' '
+ invalid_color "-2"
+'
+
+test_expect_success 'color too big' '
+ invalid_color "256"
+'
+
+test_expect_success 'extra character after color number' '
+ invalid_color "3X"
+'
+
+test_expect_success 'extra character after color name' '
+ invalid_color "redX"
+'
+
+test_expect_success 'extra character after attribute' '
+ invalid_color "dimX"
+'
+
+test_done
--
1.5.4.1135.gae084
prev parent reply other threads:[~2008-02-06 12:17 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-02-05 17:34 [PATCH] Fix bug in parse_color that prevented the user from changing the background colors Chris Larson
2008-02-05 18:39 ` Timo Hirvonen
[not found] ` <b6ebd0a50802051045t4949df68u7e405ea618403a31@mail.gmail.com>
2008-02-05 18:48 ` Chris Larson
2008-02-05 18:58 ` Timo Hirvonen
2008-02-05 19:18 ` [PATCH] Fix parsing numeric color values Timo Hirvonen
2008-02-06 9:59 ` Junio C Hamano
2008-02-06 12:16 ` [PATCH v2] " Timo Hirvonen
2008-02-06 12:16 ` Timo Hirvonen [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20080206141626.0f2b532c.tihirvon@gmail.com \
--to=tihirvon@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).