debian: new upstream point release
[git/debian.git] / t / t9002-column.sh
blobd5b98e615bca6647761e0e6f046d474ea8275015
1 #!/bin/sh
3 test_description='git column'
4 TEST_PASSES_SANITIZE_LEAK=true
5 . ./test-lib.sh
7 test_expect_success 'setup' '
8 cat >lista <<\EOF
9 one
10 two
11 three
12 four
13 five
14 six
15 seven
16 eight
17 nine
18 ten
19 eleven
20 EOF
23 test_expect_success 'never' '
24 git column --indent=Z --mode=never <lista >actual &&
25 test_cmp lista actual
28 test_expect_success 'always' '
29 cat >expected <<\EOF &&
30 Zone
31 Ztwo
32 Zthree
33 Zfour
34 Zfive
35 Zsix
36 Zseven
37 Zeight
38 Znine
39 Zten
40 Zeleven
41 EOF
42 git column --indent=Z --mode=plain <lista >actual &&
43 test_cmp expected actual
46 test_expect_success '--nl' '
47 cat >expected <<\EOF &&
48 oneZ
49 twoZ
50 threeZ
51 fourZ
52 fiveZ
53 sixZ
54 sevenZ
55 eightZ
56 nineZ
57 tenZ
58 elevenZ
59 EOF
60 git column --nl="Z$LF" --mode=plain <lista >actual &&
61 test_cmp expected actual
64 test_expect_success '80 columns' '
65 cat >expected <<\EOF &&
66 one two three four five six seven eight nine ten eleven
67 EOF
68 COLUMNS=80 git column --mode=column <lista >actual &&
69 test_cmp expected actual
72 cat >expected <<\EOF
73 one
74 two
75 three
76 four
77 five
78 six
79 seven
80 eight
81 nine
82 ten
83 eleven
84 EOF
86 test_expect_success COLUMNS_CAN_BE_1 'COLUMNS = 1' '
87 COLUMNS=1 git column --mode=column <lista >actual &&
88 test_cmp expected actual
91 test_expect_success 'width = 1' '
92 git column --mode=column --width=1 <lista >actual &&
93 test_cmp expected actual
96 COLUMNS=20
97 export COLUMNS
99 test_expect_success '20 columns' '
100 cat >expected <<\EOF &&
101 one seven
102 two eight
103 three nine
104 four ten
105 five eleven
108 git column --mode=column <lista >actual &&
109 test_cmp expected actual
112 test_expect_success '20 columns, nodense' '
113 cat >expected <<\EOF &&
114 one seven
115 two eight
116 three nine
117 four ten
118 five eleven
121 git column --mode=column,nodense < lista > actual &&
122 test_cmp expected actual
125 test_expect_success '20 columns, dense' '
126 cat >expected <<\EOF &&
127 one five nine
128 two six ten
129 three seven eleven
130 four eight
132 git column --mode=column,dense < lista > actual &&
133 test_cmp expected actual
136 test_expect_success '20 columns, padding 2' '
137 cat >expected <<\EOF &&
138 one seven
139 two eight
140 three nine
141 four ten
142 five eleven
145 git column --mode=column --padding 2 <lista >actual &&
146 test_cmp expected actual
149 test_expect_success '20 columns, indented' '
150 cat >expected <<\EOF &&
151 one seven
152 two eight
153 three nine
154 four ten
155 five eleven
158 git column --mode=column --indent=" " <lista >actual &&
159 test_cmp expected actual
162 test_expect_success '20 columns, row first' '
163 cat >expected <<\EOF &&
164 one two
165 three four
166 five six
167 seven eight
168 nine ten
169 eleven
171 git column --mode=row <lista >actual &&
172 test_cmp expected actual
175 test_expect_success '20 columns, row first, nodense' '
176 cat >expected <<\EOF &&
177 one two
178 three four
179 five six
180 seven eight
181 nine ten
182 eleven
184 git column --mode=row,nodense <lista >actual &&
185 test_cmp expected actual
188 test_expect_success '20 columns, row first, dense' '
189 cat >expected <<\EOF &&
190 one two three
191 four five six
192 seven eight nine
193 ten eleven
195 git column --mode=row,dense <lista >actual &&
196 test_cmp expected actual
199 test_expect_success 'padding must be non-negative' '
200 cat >input <<\EOF &&
201 1 2 3 4 5 6
203 cat >expected <<\EOF &&
204 fatal: --padding must be non-negative
206 test_must_fail git column --mode=column --padding=-1 <input >actual 2>&1 &&
207 test_cmp expected actual
210 test_done