github.com/xushiwei/go@v0.0.0-20130601165731-2b9d83f45bc9/src/pkg/compress/flate/flate_test.go (about)

     1  // Copyright 2009 The Go Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  // This test tests some internals of the flate package.
     6  // The tests in package compress/gzip serve as the
     7  // end-to-end test of the decompressor.
     8  
     9  package flate
    10  
    11  import (
    12  	"bytes"
    13  	"testing"
    14  )
    15  
    16  func TestUncompressedSource(t *testing.T) {
    17  	decoder := NewReader(bytes.NewBuffer([]byte{0x01, 0x01, 0x00, 0xfe, 0xff, 0x11}))
    18  	output := make([]byte, 1)
    19  	n, error := decoder.Read(output)
    20  	if n != 1 || error != nil {
    21  		t.Fatalf("decoder.Read() = %d, %v, want 1, nil", n, error)
    22  	}
    23  	if output[0] != 0x11 {
    24  		t.Errorf("output[0] = %x, want 0x11", output[0])
    25  	}
    26  }