2 |
# Copyright 2008 by Denys Vlasenko |
# Copyright 2008 by Denys Vlasenko |
3 |
# Licensed under GPL v2, see file LICENSE for details. |
# Licensed under GPL v2, see file LICENSE for details. |
4 |
|
|
5 |
. testing.sh |
. ./testing.sh |
6 |
|
|
7 |
# testing "test name" "options" "expected result" "file input" "stdin" |
# testing "test name" "options" "expected result" "file input" "stdin" |
8 |
|
|
39 |
|
|
40 |
# we also test that stdin is in fact NOT read |
# we also test that stdin is in fact NOT read |
41 |
testing "diff of stdin, twice" \ |
testing "diff of stdin, twice" \ |
42 |
"diff - -; echo $?; wc -c" \ |
'diff - -; echo $?; wc -c' \ |
43 |
"0\n5\n" \ |
"0\n5\n" \ |
44 |
"" \ |
"" \ |
45 |
"stdin" |
"stdin" |
46 |
|
|
47 |
|
testing "diff of empty file against nonempty one" \ |
48 |
|
"diff -u - input | $TRIM_TAB" \ |
49 |
|
"\ |
50 |
|
--- - |
51 |
|
+++ input |
52 |
|
@@ -0,0 +1 @@ |
53 |
|
+a |
54 |
|
" \ |
55 |
|
"a\n" \ |
56 |
|
"" |
57 |
|
|
58 |
|
testing "diff -b treats EOF as whitespace" \ |
59 |
|
'diff -ub - input; echo $?' \ |
60 |
|
"0\n" \ |
61 |
|
"abc" \ |
62 |
|
"abc " |
63 |
|
|
64 |
|
testing "diff -b treats all spaces as equal" \ |
65 |
|
'diff -ub - input; echo $?' \ |
66 |
|
"0\n" \ |
67 |
|
"a \t c\n" \ |
68 |
|
"a\t \tc\n" |
69 |
|
|
70 |
|
testing "diff -B ignores changes whose lines are all blank" \ |
71 |
|
'diff -uB - input; echo $?' \ |
72 |
|
"0\n" \ |
73 |
|
"a\n" \ |
74 |
|
"\na\n\n" |
75 |
|
|
76 |
|
testing "diff -B does not ignore changes whose lines are not all blank" \ |
77 |
|
"diff -uB - input | $TRIM_TAB" \ |
78 |
|
"\ |
79 |
|
--- - |
80 |
|
+++ input |
81 |
|
@@ -1,3 +1 @@ |
82 |
|
- |
83 |
|
-b |
84 |
|
- |
85 |
|
+a |
86 |
|
" \ |
87 |
|
"a\n" \ |
88 |
|
"\nb\n\n" |
89 |
|
|
90 |
|
testing "diff always takes context from old file" \ |
91 |
|
"diff -ub - input | $TRIM_TAB" \ |
92 |
|
"\ |
93 |
|
--- - |
94 |
|
+++ input |
95 |
|
@@ -1 +1,3 @@ |
96 |
|
+abc |
97 |
|
a c |
98 |
|
+def |
99 |
|
" \ |
100 |
|
"abc\na c\ndef\n" \ |
101 |
|
"a c\n" |
102 |
|
|
103 |
# testing "test name" "options" "expected result" "file input" "stdin" |
# testing "test name" "options" "expected result" "file input" "stdin" |
104 |
|
|
105 |
rm -rf diff1 diff2 |
rm -rf diff1 diff2 |