Diff

Differences From Artifact [73a8f932ed]:

To Artifact [dd11cf49de]:


27
28
29
30
31
32
33
34

35
36
37
38
39

40
41
42
43
44
45
46
27
28
29
30
31
32
33

34
35
36
37
38

39
40
41
42
43
44
45
46







-
+




-
+







func TestCompressorSample(t *testing.T) {
	var (
		buf bytes.Buffer
		err error
	)

	out := Compressor(&buf)
	err = out(input)
	_, err = out.Write(input)
	if err != nil {
		t.Error(err)
	}

	err = out(nil)
	_, err = out.Write(nil)
	if err != nil {
		t.Error(err)
	}

	result := buf.Bytes()
	delta := diff.Diff(diff.D{len(result), len(output), func(i, j int) bool { return result[i] == output[j] }})

107
108
109
110
111
112
113
114

115
116
117
118
119
120
121
122
123
124
125

126
127
128
129
130
131
132
107
108
109
110
111
112
113

114
115
116
117
118
119
120
121
122
123
124

125
126
127
128
129
130
131
132







-
+










-
+







	var trace []byte = make([]byte, 0)

	for len(data) > 0 {
		if step <= len(data) {

			trace = append(trace, data[:step]...)

			err = compressor(data[:step])
			_, err = compressor.Write(data[:step])
			if err != nil {
				return err
			}
			data = data[step:]
		} else {
			step = len(data)
		}
	}

	// Flush the compressor
	err = compressor(nil)
	_, err = compressor.Write(nil)
	if err != nil {
		return err
	}

	// Attempt to decompress the data
	compressed := buf.Bytes()
	decompressed, err := ioutil.ReadAll(Decompressor(bytes.NewReader(compressed)))