@@ -62,7 +62,7 @@ func (s *DeltaSuite) SetUpSuite(c *C) {
62
62
target : []piece {{"1" , 30 }, {"2" , 20 }, {"7" , 40 }, {"4" , 400 },
63
63
{"5" , 10 }},
64
64
}, {
65
- description : "A copy operation bigger tan 64kb" ,
65
+ description : "A copy operation bigger than 64kb" ,
66
66
base : []piece {{bigRandStr , 1 }, {"1" , 200 }},
67
67
target : []piece {{bigRandStr , 1 }},
68
68
}}
@@ -72,12 +72,16 @@ var bigRandStr = randStringBytes(100 * 1024)
72
72
73
73
const letterBytes = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
74
74
75
- func randStringBytes (n int ) string {
75
+ func randBytes (n int ) [] byte {
76
76
b := make ([]byte , n )
77
77
for i := range b {
78
78
b [i ] = letterBytes [rand .Intn (len (letterBytes ))]
79
79
}
80
- return string (b )
80
+ return b
81
+ }
82
+
83
+ func randStringBytes (n int ) string {
84
+ return string (randBytes (n ))
81
85
}
82
86
83
87
func (s * DeltaSuite ) TestAddDelta (c * C ) {
@@ -110,3 +114,14 @@ func (s *DeltaSuite) TestIncompleteDelta(c *C) {
110
114
c .Assert (err , NotNil )
111
115
c .Assert (result , IsNil )
112
116
}
117
+
118
+ func (s * DeltaSuite ) TestMaxCopySizeDelta (c * C ) {
119
+ baseBuf := randBytes (maxCopySize )
120
+ targetBuf := baseBuf [0 :]
121
+ targetBuf = append (targetBuf , byte (1 ))
122
+
123
+ delta := DiffDelta (baseBuf , targetBuf )
124
+ result , err := PatchDelta (baseBuf , delta )
125
+ c .Assert (err , IsNil )
126
+ c .Assert (result , DeepEquals , targetBuf )
127
+ }
0 commit comments