xref: /freebsd/usr.bin/diff3/tests/diff3_test.sh (revision 5956d97f4b3204318ceb6aa9c77bd0bc6ea87a41)
1# $FreeBSD$
2
3atf_test_case diff3
4atf_test_case diff3_lesssimple
5atf_test_case diff3_ed
6atf_test_case diff3_A
7atf_test_case diff3_merge
8
9diff3_body()
10{
11	atf_check -o file:$(atf_get_srcdir)/1.out \
12		diff3 $(atf_get_srcdir)/1.txt $(atf_get_srcdir)/2.txt $(atf_get_srcdir)/3.txt
13
14	atf_check -o file:$(atf_get_srcdir)/1.out \
15		diff3 --strip-trailing-cr $(atf_get_srcdir)/1cr.txt $(atf_get_srcdir)/2.txt $(atf_get_srcdir)/3.txt
16
17	atf_check -o file:$(atf_get_srcdir)/1t.out \
18		diff3 -T $(atf_get_srcdir)/1.txt $(atf_get_srcdir)/2.txt $(atf_get_srcdir)/3.txt
19
20	atf_check -o file:$(atf_get_srcdir)/2.out \
21		diff3 -e $(atf_get_srcdir)/1.txt $(atf_get_srcdir)/2.txt $(atf_get_srcdir)/3.txt
22
23	atf_check -o file:$(atf_get_srcdir)/3.out \
24		diff3 -E -L 1 -L 2 -L 3 $(atf_get_srcdir)/1.txt $(atf_get_srcdir)/2.txt $(atf_get_srcdir)/3.txt
25
26	atf_check -o file:$(atf_get_srcdir)/4.out \
27		diff3 -X -L 1 -L 2 -L 3 $(atf_get_srcdir)/1.txt $(atf_get_srcdir)/2.txt $(atf_get_srcdir)/3.txt
28
29	atf_check -o file:$(atf_get_srcdir)/5.out \
30		diff3 -x $(atf_get_srcdir)/1.txt $(atf_get_srcdir)/2.txt $(atf_get_srcdir)/3.txt
31
32	atf_check -o file:$(atf_get_srcdir)/6.out \
33		diff3 -3 $(atf_get_srcdir)/1.txt $(atf_get_srcdir)/2.txt $(atf_get_srcdir)/3.txt
34
35	atf_check -o file:$(atf_get_srcdir)/7.out \
36		diff3 -i $(atf_get_srcdir)/1.txt $(atf_get_srcdir)/2.txt $(atf_get_srcdir)/3.txt
37}
38
39diff3_lesssimple_body()
40{
41	atf_check -s exit:1 -o file:$(atf_get_srcdir)/10.out \
42		diff3 -m -L 1 -L 2 -L 3 $(atf_get_srcdir)/4.txt $(atf_get_srcdir)/5.txt $(atf_get_srcdir)/6.txt
43}
44
45diff3_ed_body()
46{
47	atf_check -s exit:0 -o file:$(atf_get_srcdir)/long-ed.out \
48		diff3 -e $(atf_get_srcdir)/long-m.txt $(atf_get_srcdir)/long-o.txt $(atf_get_srcdir)/long-y.txt
49}
50
51diff3_A_body()
52{
53	atf_check -s exit:1 -o file:$(atf_get_srcdir)/8.out \
54		diff3 -A -L 1 -L 2 -L 3 $(atf_get_srcdir)/1.txt $(atf_get_srcdir)/2.txt $(atf_get_srcdir)/3.txt
55
56	atf_check -s exit:1 -o file:$(atf_get_srcdir)/long-A.out \
57		diff3 -A -L long-m.txt -L long-o.txt -L long-y.txt $(atf_get_srcdir)/long-m.txt $(atf_get_srcdir)/long-o.txt $(atf_get_srcdir)/long-y.txt
58}
59
60
61diff3_merge_body()
62{
63	atf_check -s exit:1 -o file:$(atf_get_srcdir)/9.out \
64		diff3 -m -L 1 -L 2 -L 3 $(atf_get_srcdir)/1.txt $(atf_get_srcdir)/2.txt $(atf_get_srcdir)/3.txt
65
66	atf_check -s exit:1 -o file:$(atf_get_srcdir)/long-merge.out \
67		diff3 -m -L long-m.txt -L long-o.txt -L long-y.txt $(atf_get_srcdir)/long-m.txt $(atf_get_srcdir)/long-o.txt $(atf_get_srcdir)/long-y.txt
68}
69
70atf_init_test_cases()
71{
72	atf_add_test_case diff3
73#	atf_add_test_case diff3_lesssimple
74	atf_add_test_case diff3_ed
75	atf_add_test_case diff3_A
76	atf_add_test_case diff3_merge
77}
78