]>
Commit | Line | Data |
---|---|---|
7e29b825 NTND |
1 | #!/bin/sh |
2 | ||
3 | test_description='git column' | |
4 | . ./test-lib.sh | |
5 | ||
6 | test_expect_success 'setup' ' | |
7 | cat >lista <<\EOF | |
8 | one | |
9 | two | |
10 | three | |
11 | four | |
12 | five | |
13 | six | |
14 | seven | |
15 | eight | |
16 | nine | |
17 | ten | |
18 | eleven | |
19 | EOF | |
20 | ' | |
21 | ||
22 | test_expect_success 'never' ' | |
23 | git column --indent=Z --mode=never <lista >actual && | |
24 | test_cmp lista actual | |
25 | ' | |
26 | ||
27 | test_expect_success 'always' ' | |
28 | cat >expected <<\EOF && | |
29 | Zone | |
30 | Ztwo | |
31 | Zthree | |
32 | Zfour | |
33 | Zfive | |
34 | Zsix | |
35 | Zseven | |
36 | Zeight | |
37 | Znine | |
38 | Zten | |
39 | Zeleven | |
40 | EOF | |
41 | git column --indent=Z --mode=plain <lista >actual && | |
42 | test_cmp expected actual | |
43 | ' | |
44 | ||
c93ca46c SG |
45 | test_expect_success '--nl' ' |
46 | cat >expected <<\EOF && | |
47 | oneZ | |
48 | twoZ | |
49 | threeZ | |
50 | fourZ | |
51 | fiveZ | |
52 | sixZ | |
53 | sevenZ | |
54 | eightZ | |
55 | nineZ | |
56 | tenZ | |
57 | elevenZ | |
58 | EOF | |
59 | git column --nl="Z$LF" --mode=plain <lista >actual && | |
60 | test_cmp expected actual | |
61 | ' | |
62 | ||
077539d7 NTND |
63 | test_expect_success '80 columns' ' |
64 | cat >expected <<\EOF && | |
65 | one two three four five six seven eight nine ten eleven | |
66 | EOF | |
67 | COLUMNS=80 git column --mode=column <lista >actual && | |
68 | test_cmp expected actual | |
69 | ' | |
70 | ||
f78b1c5f | 71 | cat >expected <<\EOF |
077539d7 NTND |
72 | one |
73 | two | |
74 | three | |
75 | four | |
76 | five | |
77 | six | |
78 | seven | |
79 | eight | |
80 | nine | |
81 | ten | |
82 | eleven | |
83 | EOF | |
f78b1c5f ZJS |
84 | |
85 | test_expect_success COLUMNS_CAN_BE_1 'COLUMNS = 1' ' | |
077539d7 NTND |
86 | COLUMNS=1 git column --mode=column <lista >actual && |
87 | test_cmp expected actual | |
88 | ' | |
89 | ||
90 | test_expect_success 'width = 1' ' | |
91 | git column --mode=column --width=1 <lista >actual && | |
92 | test_cmp expected actual | |
93 | ' | |
94 | ||
95 | COLUMNS=20 | |
96 | export COLUMNS | |
97 | ||
98 | test_expect_success '20 columns' ' | |
99 | cat >expected <<\EOF && | |
100 | one seven | |
101 | two eight | |
102 | three nine | |
103 | four ten | |
104 | five eleven | |
105 | six | |
106 | EOF | |
107 | git column --mode=column <lista >actual && | |
108 | test_cmp expected actual | |
109 | ' | |
110 | ||
3f8eccbe NTND |
111 | test_expect_success '20 columns, nodense' ' |
112 | cat >expected <<\EOF && | |
113 | one seven | |
114 | two eight | |
115 | three nine | |
116 | four ten | |
117 | five eleven | |
118 | six | |
119 | EOF | |
120 | git column --mode=column,nodense < lista > actual && | |
121 | test_cmp expected actual | |
122 | ' | |
123 | ||
124 | test_expect_success '20 columns, dense' ' | |
125 | cat >expected <<\EOF && | |
126 | one five nine | |
127 | two six ten | |
128 | three seven eleven | |
129 | four eight | |
130 | EOF | |
131 | git column --mode=column,dense < lista > actual && | |
132 | test_cmp expected actual | |
133 | ' | |
134 | ||
077539d7 NTND |
135 | test_expect_success '20 columns, padding 2' ' |
136 | cat >expected <<\EOF && | |
137 | one seven | |
138 | two eight | |
139 | three nine | |
140 | four ten | |
141 | five eleven | |
142 | six | |
143 | EOF | |
144 | git column --mode=column --padding 2 <lista >actual && | |
145 | test_cmp expected actual | |
146 | ' | |
147 | ||
148 | test_expect_success '20 columns, indented' ' | |
149 | cat >expected <<\EOF && | |
150 | one seven | |
151 | two eight | |
152 | three nine | |
153 | four ten | |
154 | five eleven | |
155 | six | |
156 | EOF | |
157 | git column --mode=column --indent=" " <lista >actual && | |
158 | test_cmp expected actual | |
159 | ' | |
160 | ||
161 | test_expect_success '20 columns, row first' ' | |
162 | cat >expected <<\EOF && | |
163 | one two | |
164 | three four | |
165 | five six | |
166 | seven eight | |
167 | nine ten | |
168 | eleven | |
169 | EOF | |
170 | git column --mode=row <lista >actual && | |
171 | test_cmp expected actual | |
172 | ' | |
173 | ||
3f8eccbe NTND |
174 | test_expect_success '20 columns, row first, nodense' ' |
175 | cat >expected <<\EOF && | |
176 | one two | |
177 | three four | |
178 | five six | |
179 | seven eight | |
180 | nine ten | |
181 | eleven | |
182 | EOF | |
183 | git column --mode=row,nodense <lista >actual && | |
184 | test_cmp expected actual | |
185 | ' | |
186 | ||
187 | test_expect_success '20 columns, row first, dense' ' | |
188 | cat >expected <<\EOF && | |
189 | one two three | |
190 | four five six | |
191 | seven eight nine | |
192 | ten eleven | |
193 | EOF | |
194 | git column --mode=row,dense <lista >actual && | |
195 | test_cmp expected actual | |
196 | ' | |
197 | ||
f2d31c69 KH |
198 | test_expect_success 'padding must be non-negative' ' |
199 | cat >input <<\EOF && | |
200 | 1 2 3 4 5 6 | |
201 | EOF | |
202 | cat >expected <<\EOF && | |
203 | fatal: --padding must be non-negative | |
204 | EOF | |
205 | test_must_fail git column --mode=column --padding=-1 <input >actual 2>&1 && | |
206 | test_cmp expected actual | |
207 | ' | |
208 | ||
7e29b825 | 209 | test_done |