78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
|
t.Error(err)
}
}
}
func TestStepCycle(t *testing.T) {
for i := 0; i < len(testData); i++ {
for j := 1; j < len(testData); j++ {
if err := cycle(testData[i], j); err != nil {
t.Error("Error for testData[", i, "], step[", j, "] ", err)
}
}
}
}
|
|
|
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
|
t.Error(err)
}
}
}
func TestStepCycle(t *testing.T) {
for i := 0; i < len(testData); i++ {
for j := 1; j < len(testData[i]); j++ {
if err := cycle(testData[i], j); err != nil {
t.Error("Error for testData[", i, "], step[", j, "] ", err)
}
}
}
}
|
111
112
113
114
115
116
117
118
119
120
121
122
123
124
|
trace = append(trace, data[:step]...)
_, err = compressor.Write(data[:step])
if err != nil {
return err
}
data = data[step:]
} else {
step = len(data)
}
}
// Flush the compressor
|
>
|
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
|
trace = append(trace, data[:step]...)
_, err = compressor.Write(data[:step])
if err != nil {
return err
}
data = data[step:]
} else {
step = len(data)
}
}
// Flush the compressor
|
136
137
138
139
140
141
142
143
144
145
146
147
148
149
|
// Diff the result against the initial input
delta := diff.Diff(diff.D{len(input), len(decompressed),
func(i, j int) bool { return input[i] == decompressed[j] }})
// Return a well-formated error if any differences are found
if len(delta.Added) > 0 || len(delta.Removed) > 0 {
return fmt.Errorf("Unexpected decompressed output %v\ninput: (%d) %#x\ntrace: (%d) %#x\noutput: (%d) %#x\n",
delta, len(input), input, len(trace), trace, len(decompressed), decompressed)
}
// All is good :)
return nil
}
|
|
|
|
137
138
139
140
141
142
143
144
145
146
147
148
149
150
|
// Diff the result against the initial input
delta := diff.Diff(diff.D{len(input), len(decompressed),
func(i, j int) bool { return input[i] == decompressed[j] }})
// Return a well-formated error if any differences are found
if len(delta.Added) > 0 || len(delta.Removed) > 0 {
return fmt.Errorf("Unexpected decompressed output for step %d, delta %v\ninput: (%d) %#x\ntrace: (%d) %#x\noutput: (%d) %#x\n",
step, delta, len(input), input, len(trace), trace, len(decompressed), decompressed)
}
// All is good :)
return nil
}
|