Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(633)

Delta Between Two Patch Sets: src/pkg/compress/bzip2/bzip2_test.go

Issue 131840043: code review 131840043: bzip2: improve performance (Closed)
Left Patch Set: Created 9 years, 7 months ago
Right Patch Set: diff -r 3cf190969915d6d531acd0795eb81974aaa64d19 https://go.googlecode.com/hg/ Created 9 years, 7 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Right: Side by side diff | Download
« no previous file with change/comment | « no previous file | src/pkg/compress/bzip2/move_to_front.go » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
(no file at all)
1 // Copyright 2011 The Go Authors. All rights reserved. 1 // Copyright 2011 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style 2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file. 3 // license that can be found in the LICENSE file.
4 4
5 package bzip2 5 package bzip2
6 6
7 import ( 7 import (
8 "bytes" 8 "bytes"
9 "encoding/base64" 9 "encoding/base64"
10 "encoding/hex" 10 "encoding/hex"
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 // This shouldn't panic. 207 // This shouldn't panic.
208 ioutil.ReadAll(decompressor) 208 ioutil.ReadAll(decompressor)
209 } 209 }
210 210
211 func TestOutOfRangeSelector(t *testing.T) { 211 func TestOutOfRangeSelector(t *testing.T) {
212 // Tests https://code.google.com/p/go/issues/detail?id=8363. 212 // Tests https://code.google.com/p/go/issues/detail?id=8363.
213 buffer := bytes.NewReader(outOfRangeSelector) 213 buffer := bytes.NewReader(outOfRangeSelector)
214 decompressor := NewReader(buffer) 214 decompressor := NewReader(buffer)
215 // This shouldn't panic. 215 // This shouldn't panic.
216 ioutil.ReadAll(decompressor) 216 ioutil.ReadAll(decompressor)
217 }
218
219 func TestMTF(t *testing.T) {
220 mtf := newMTFDecoderWithRange(5)
221
222 // 0 1 2 3 4
223 expect := byte(1)
224 x := mtf.Decode(1)
225 if x != expect {
226 t.Errorf("expected %v, got %v", expect, x)
227 }
228
229 // 1 0 2 3 4
230 x = mtf.Decode(0)
231 if x != expect {
232 t.Errorf("expected %v, got %v", expect, x)
233 }
234
235 // 1 0 2 3 4
236 expect = byte(0)
237 x = mtf.Decode(1)
238 if x != expect {
239 t.Errorf("expected %v, got %v", expect, x)
240 }
241
242 // 0 1 2 3 4
243 expect = byte(4)
244 x = mtf.Decode(4)
245 if x != expect {
246 t.Errorf("expected %v, got %v", expect, x)
247 }
248
249 // 4 0 1 2 3
250 expect = byte(0)
251 x = mtf.Decode(1)
252 if x != expect {
253 t.Errorf("expected %v, got %v", expect, x)
254 }
217 } 255 }
218 256
219 var bufferOverrunBase64 string = ` 257 var bufferOverrunBase64 string = `
220 QlpoNTFBWSZTWTzyiGcACMP/////////////////////////////////3/7f3/// 258 QlpoNTFBWSZTWTzyiGcACMP/////////////////////////////////3/7f3///
221 ////4N/fCZODak2Xo44GIHZgkGzDRbFAuwAAKoFV7T6AO6qwA6APb6s2rOoAkAAD 259 ////4N/fCZODak2Xo44GIHZgkGzDRbFAuwAAKoFV7T6AO6qwA6APb6s2rOoAkAAD
222 oACUoDtndh0iQAPkAAAAaPWihQoCgr5t97Obju21ChQB0NBm3RbA7apXrRoBooAA 260 oACUoDtndh0iQAPkAAAAaPWihQoCgr5t97Obju21ChQB0NBm3RbA7apXrRoBooAA
223 AhA+IAHWl2Us3O7t9yieb3udvd76+4+fd33nd3HO1bVvfcGRne6+3vfPvfc++995 261 AhA+IAHWl2Us3O7t9yieb3udvd76+4+fd33nd3HO1bVvfcGRne6+3vfPvfc++995
224 w7k973eJhasLVec970tzDNXdX28LoPXZ3H3K9z0s5ufWAfes49d5594c3dUYtI+2 262 w7k973eJhasLVec970tzDNXdX28LoPXZ3H3K9z0s5ufWAfes49d5594c3dUYtI+2
225 +h1dvtpRa+uvrVEAG9bl893RVEN7cWvroSqWjPMGgAQi7Gq8TJSgKKdjKFBIB9Ae 263 +h1dvtpRa+uvrVEAG9bl893RVEN7cWvroSqWjPMGgAQi7Gq8TJSgKKdjKFBIB9Ae
226 LqWxleu715eXe7ml9e5098Z6G1vr7t1QZ6ot76YzPd3j7333t2ql2Chm7XrA9ICQ 264 LqWxleu715eXe7ml9e5098Z6G1vr7t1QZ6ot76YzPd3j7333t2ql2Chm7XrA9ICQ
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
372 410
373 var outOfRangeSelector = []byte{ 411 var outOfRangeSelector = []byte{
374 0x42, 0x5a, 0x68, 0x39, 0x31, 0x41, 0x59, 0x26, 412 0x42, 0x5a, 0x68, 0x39, 0x31, 0x41, 0x59, 0x26,
375 0x53, 0x59, 0x4e, 0xec, 0xe8, 0x36, 0x00, 0x00, 413 0x53, 0x59, 0x4e, 0xec, 0xe8, 0x36, 0x00, 0x00,
376 0x02, 0x51, 0x80, 0x00, 0x10, 0x40, 0x00, 0x06, 414 0x02, 0x51, 0x80, 0x00, 0x10, 0x40, 0x00, 0x06,
377 0x44, 0x90, 0x80, 0x20, 0x00, 0x31, 0x06, 0x4c, 415 0x44, 0x90, 0x80, 0x20, 0x00, 0x31, 0x06, 0x4c,
378 0x41, 0x01, 0xa7, 0xa9, 0xa5, 0x80, 0xbb, 0x94, 416 0x41, 0x01, 0xa7, 0xa9, 0xa5, 0x80, 0xbb, 0x94,
379 0x31, 0x17, 0x72, 0x45, 0x38, 0x50, 0x90, 0x00, 417 0x31, 0x17, 0x72, 0x45, 0x38, 0x50, 0x90, 0x00,
380 0x00, 0x00, 0x00, 418 0x00, 0x00, 0x00,
381 } 419 }
LEFTRIGHT

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b