For golang/go#45557 Change-Id: I447530cc66896aef7a8d528ccb8d095b80e3cf47 GitHub-Last-Rev: 5f385ff46487ac318bd1147cdbbd26bb0ffd0426 GitHub-Pull-Request: golang/crypto#230 Reviewed-on: https://go-review.googlesource.com/c/crypto/+/430797 Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Meng Zhuo <mzh@golangcn.org> Run-TryBot: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com>
41 lines
880 B
Go
41 lines
880 B
Go
// Copyright 2011 The Go Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style
|
|
// license that can be found in the LICENSE file.
|
|
|
|
package packet
|
|
|
|
import (
|
|
"bytes"
|
|
"encoding/hex"
|
|
"io"
|
|
"testing"
|
|
)
|
|
|
|
func TestCompressed(t *testing.T) {
|
|
packet, err := Read(readerFromHex(compressedHex))
|
|
if err != nil {
|
|
t.Errorf("failed to read Compressed: %s", err)
|
|
return
|
|
}
|
|
|
|
c, ok := packet.(*Compressed)
|
|
if !ok {
|
|
t.Error("didn't find Compressed packet")
|
|
return
|
|
}
|
|
|
|
contents, err := io.ReadAll(c.Body)
|
|
if err != nil && err != io.EOF {
|
|
t.Error(err)
|
|
return
|
|
}
|
|
|
|
expected, _ := hex.DecodeString(compressedExpectedHex)
|
|
if !bytes.Equal(expected, contents) {
|
|
t.Errorf("got:%x want:%x", contents, expected)
|
|
}
|
|
}
|
|
|
|
const compressedHex = "a3013b2d90c4e02b72e25f727e5e496a5e49b11e1700"
|
|
const compressedExpectedHex = "cb1062004d14c8fe636f6e74656e74732e0a"
|