aboutsummaryrefslogtreecommitdiff
path: root/t/t9002-column.sh
diff options
context:
space:
mode:
authorNguyễn Thái Ngọc Duy <pclouds@gmail.com>2012-04-13 17:54:35 +0700
committerJunio C Hamano <gitster@pobox.com>2012-04-27 09:26:38 -0700
commit077539d734cdc4b0a3d2ea87fc487fa5c21d0311 (patch)
tree0e6899e3287619e7f92628c8f1c451b1173a958b /t/t9002-column.sh
parent88e8f908f2b0c56f9ccf8134d8ff9f689af9cc84 (diff)
downloadgit-077539d734cdc4b0a3d2ea87fc487fa5c21d0311.tar.gz
git-077539d734cdc4b0a3d2ea87fc487fa5c21d0311.tar.xz
column: add columnar layout
COL_COLUMN and COL_ROW fill column by column (or row by row respectively), given the terminal width and how many space between columns. All cells have equal width. Strings are supposed to be in UTF-8. Valid ANSI escape strings are OK. Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t9002-column.sh')
-rwxr-xr-xt/t9002-column.sh86
1 files changed, 86 insertions, 0 deletions
diff --git a/t/t9002-column.sh b/t/t9002-column.sh
index a7f3cd928..ec288aeb9 100755
--- a/t/t9002-column.sh
+++ b/t/t9002-column.sh
@@ -42,4 +42,90 @@ EOF
test_cmp expected actual
'
+test_expect_success '80 columns' '
+ cat >expected <<\EOF &&
+one two three four five six seven eight nine ten eleven
+EOF
+ COLUMNS=80 git column --mode=column <lista >actual &&
+ test_cmp expected actual
+'
+
+test_expect_success 'COLUMNS = 1' '
+ cat >expected <<\EOF &&
+one
+two
+three
+four
+five
+six
+seven
+eight
+nine
+ten
+eleven
+EOF
+ COLUMNS=1 git column --mode=column <lista >actual &&
+ test_cmp expected actual
+'
+
+test_expect_success 'width = 1' '
+ git column --mode=column --width=1 <lista >actual &&
+ test_cmp expected actual
+'
+
+COLUMNS=20
+export COLUMNS
+
+test_expect_success '20 columns' '
+ cat >expected <<\EOF &&
+one seven
+two eight
+three nine
+four ten
+five eleven
+six
+EOF
+ git column --mode=column <lista >actual &&
+ test_cmp expected actual
+'
+
+test_expect_success '20 columns, padding 2' '
+ cat >expected <<\EOF &&
+one seven
+two eight
+three nine
+four ten
+five eleven
+six
+EOF
+ git column --mode=column --padding 2 <lista >actual &&
+ test_cmp expected actual
+'
+
+test_expect_success '20 columns, indented' '
+ cat >expected <<\EOF &&
+ one seven
+ two eight
+ three nine
+ four ten
+ five eleven
+ six
+EOF
+ git column --mode=column --indent=" " <lista >actual &&
+ test_cmp expected actual
+'
+
+test_expect_success '20 columns, row first' '
+ cat >expected <<\EOF &&
+one two
+three four
+five six
+seven eight
+nine ten
+eleven
+EOF
+ git column --mode=row <lista >actual &&
+ test_cmp expected actual
+'
+
test_done