aboutsummaryrefslogtreecommitdiff
path: root/tests/patch.test
blob: 42eed9373b27001d183e585bb354f5635aa8b647 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#!/bin/bash

[ -f testing.sh ] && . testing.sh

#testing "name" "command" "result" "infile" "stdin"

testing "create file" "patch >/dev/null && cat bork" "one\ntwo\nthree\n" "" "
--- /dev/null
+++ bork
@@ -0,0 +1,3 @@
+one
+two
+three
"
testing "insert in middle" "patch > /dev/null && cat bork" \
  "one\nfour\ntwo\nthree\n" "" "
--- bork
+++ bork
@@ -1,3 +1,4 @@
 one
+four
 two
 three
"
testing "append at end" "patch > /dev/null && cat bork" \
  "one\nfour\ntwo\nthree\nfive\nsix\n" "" "
--- bork
+++ bork
@@ -2,3 +2,5 @@
 four
 two
 three
+five
+six
"
testing "insert at start" "patch > /dev/null && cat bork" \
  "seven\none\nfour\ntwo\nthree\nfive\nsix\n" "" "
--- bork
+++ bork
@@ -1,3 +1,4 @@
+seven
 one
 four
 two
"
testing "delete at end" "patch > /dev/null && cat bork" \
  "seven\none\nfour\ntwo\nthree\nfive\n" "" "
--- bork
+++ bork
@@ -4,4 +4,3 @@
 two
 three
 five
-six
"

testing "delete at start" "patch > /dev/null && cat bork" \
  "four\ntwo\nthree\nfive\n" "" "
--- bork
+++ bork
@@ -1,5 +1,3 @@
-seven
-one
 four
 two
 three
"

testing "filter timestamps" "patch > /dev/null && cat bork" \
  "four\ntwo\nthree\neight\nfive\n" "" "
--- bork	2019-12-20 16:54:35.735630973 -0600
+++ bork	2019-12-20 16:57:03.083625706 -0600
@@ -1,4 +1,5 @@
 four
 two
 three
+eight
 five
"

testing "quoted name" "patch > /dev/null && cat 'fruit bat'" \
  "hello\n" "" '
--- /dev/null
+++ "fruit bat"
@@ -0,0 +1 @@
+hello
'
# todo bork bork2