Skip to content

Commit 41d91e8

Browse files
committed
Add more tests
Fixes #1
1 parent e0c877c commit 41d91e8

File tree

2 files changed

+73
-1
lines changed

2 files changed

+73
-1
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ all: clean $(ALL)
1111

1212
# cram is a python app, so 'easy_install/pip install cram' to run tests
1313
test:
14-
cram tests/main.t
14+
cram tests/*.t
1515

1616
clean:
1717
rm -f $(ALL)

tests/main.t

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,12 @@ Usage:
4141
$ goreplace -V
4242
goreplace version [0-9]+.[0-9]+.[0-9]+ (re)
4343
44+
45+
Testing ignoring missing arguments:
46+
$ goreplace -s foobar -r ___xxx --ignore-empty
47+
48+
49+
4450
Testing replace mode:
4551
4652
$ cat > test.txt <<EOF
@@ -73,6 +79,69 @@ Testing replace mode with multiple matches:
7379
this is the ___xxx forth ___xxx line
7480
this is the last line
7581
82+
Testing replace mode without match:
83+
84+
$ cat > test.txt <<EOF
85+
> this is a testline
86+
> this is the second line
87+
> this is the third foobar line
88+
> this is the foobar forth foobar line
89+
> this is the last line
90+
> EOF
91+
$ goreplace -s barfoo -r ___xxx test.txt
92+
$ cat test.txt
93+
this is a testline
94+
this is the second line
95+
this is the third foobar line
96+
this is the foobar forth foobar line
97+
this is the last line
98+
99+
Testing replace mode with regex:
100+
101+
$ cat > test.txt <<EOF
102+
> this is a testline
103+
> this is the second line
104+
> this is the third foobar line
105+
> this is the last line
106+
> EOF
107+
$ goreplace --regex -s 'f[o]+b[a]*r' -r ___xxx test.txt
108+
$ cat test.txt
109+
this is a testline
110+
this is the second line
111+
this is the third ___xxx line
112+
this is the last line
113+
114+
Testing replace mode with regex:
115+
116+
$ cat > test.txt <<EOF
117+
> this is a testline
118+
> this is the second line
119+
> this is the third foobar line
120+
> this is the last line
121+
> EOF
122+
$ goreplace --regex --regex-backrefs -s 'f[o]+(b[a]*r)' -r '___$1' test.txt
123+
$ cat test.txt
124+
this is a testline
125+
this is the second line
126+
this is the third ___bar line
127+
this is the last line
128+
129+
Testing replace mode with regex and case-insensitive:
130+
131+
$ cat > test.txt <<EOF
132+
> this is a testline
133+
> this is the second line
134+
> this is the third foobar line
135+
> this is the last line
136+
> EOF
137+
$ goreplace --regex --regex-backrefs -s 'F[O]+(b[a]*r)' -r '___$1' --case-insensitive test.txt
138+
$ cat test.txt
139+
this is a testline
140+
this is the second line
141+
this is the third ___bar line
142+
this is the last line
143+
144+
76145
Testing line mode:
77146
78147
$ cat > test.txt <<EOF
@@ -138,6 +207,9 @@ Testing line mode with multiple matches and --once-remove-match:
138207
___xxx
139208
this is the last line
140209
210+
211+
212+
141213
Testing lineinfile mode:
142214
143215
$ cat > test.txt <<EOF

0 commit comments

Comments
 (0)