forked from balacode/go-delta
-
Notifications
You must be signed in to change notification settings - Fork 0
/
integrated_test.go
103 lines (98 loc) · 3.14 KB
/
integrated_test.go
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
// -----------------------------------------------------------------------------
// github.com/balacode/go-delta go-delta/[integrated_test.go]
// (c) [email protected] License: MIT
// -----------------------------------------------------------------------------
package delta
// This unit test checks the functioning of the entire module.
// It calls Make(), Delta.Apply(), Delta.Bytes() and delta.Load().
import (
"bytes"
"testing"
)
// go test --run Test_Integrated_
func Test_Integrated_(t *testing.T) {
if PrintTestNames {
printTestName()
}
vals := [][]byte{
ab(""),
ab(" "),
ab(AtoZ),
ab(AtoM),
//
ab("start" + Nums),
ab(Nums + "middle" + Nums),
ab(Nums + Nums + "end"),
//
ab(
"Lorem ipsum dolor sit amet, consetetur sadipscing elitr," +
" sed diam nonumy eirmod tempor invidunt ut labore et" +
" dolore magna aliquyam erat, sed diam voluptua. At vero" +
" eos et accusam et justo duo dolores et ea rebum. Stet" +
" clita kasd gubergren, no sea takimata sanctus est Lorem" +
" ipsum dolor sit amet. Lorem ipsum dolor sit amet," +
" consetetur sadipscing elitr, sed diam nonumy eirmod" +
" tempor invidunt ut labore et dolore magna aliquyam erat," +
" sed diam voluptua. At vero eos et accusam et justo duo" +
" dolores et ea rebum. Stet clita kasd gubergren, no sea" +
" takimata sanctus est Lorem ipsum dolor sit amet. Lorem" +
" ipsum dolor sit amet, consetetur sadipscing elitr, sed" +
" diam nonumy eirmod tempor invidunt ut labore et dolore" +
" magna aliquyam erat, sed diam voluptua. At vero eos et" +
" accusam et justo duo dolores et ea rebum. Stet clita" +
" kasd gubergren, no sea takimata sanctus est Lorem ipsum" +
" dolor sit amet. suscipit lobortis nisl ut aliquip ex ea" +
" commodo consequat"),
ab(
"Lorem ipsum dolor sit amet, consetetur sadipscing elitr"),
ab(
" consetetur sadipscing elitr, sed diam nonumy eirmod" +
" magna aliquyam erat, sed diam voluptua. At vero eos et"),
ab(
"sit amet, consetetur sadipscing elitr" +
" sed diam nonumy eirmod tempor"),
ab(
"suscipit lobortis nisl ut aliquip ex ea commodo consequat."),
ab(
"Lorem ipsum dolor sit amet, consetetur sadipscing elitr," +
AtoZ +
" sed diam voluptua. At vero eos et accusam et justo duo" +
AtoM +
" commodo consequat"),
}
for _, a := range vals {
for _, b := range vals {
var ar []byte
{
d := Make(a, b)
ar = d.Bytes()
}
var d Delta
var err error
d, err = Load(ar)
if err != nil {
PL("FAILED @1")
PL("SOURCE:", "\n", string(a))
PL("TARGET:", "\n", string(b))
PL("ERROR:", err)
continue
}
var result []byte
result, err = d.Apply(a)
if err != nil {
PL("FAILED @2")
PL("SOURCE:", "\n", string(a))
PL("TARGET:", "\n", string(b))
PL("ERROR:", err)
continue
}
if !bytes.Equal(result, b) {
PL("FAILED @3")
PL("SOURCE:", "\n", string(a))
PL("TARGET:", "\n", string(b))
PL("RETURNED:", "\n", string(result))
}
}
}
} // Test_Integrated_
// end