tape: Test DecodeAny method
This commit is contained in:
parent
b2504cda2d
commit
7a03d8d6b5
@ -335,3 +335,24 @@ func TestTagAny(test *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestDecodeAny(test *testing.T) {
|
||||
for index, payload := range samplePayloads {
|
||||
correctValue := sampleValues[index]
|
||||
data := payload[1:]
|
||||
decoder := NewDecoder(bytes.NewBuffer(data))
|
||||
tag := Tag(payload[0])
|
||||
decoded, n, err := DecodeAny(decoder, tag)
|
||||
test.Log("n: ", n)
|
||||
test.Log("tag: ", tag)
|
||||
test.Log("got: ", tu.Describe(decoded))
|
||||
test.Log("correct:", tu.Describe(correctValue))
|
||||
if err != nil { test.Fatal(err) }
|
||||
if !reflect.DeepEqual(decoded, correctValue) {
|
||||
test.Fatal("values not equal")
|
||||
}
|
||||
if n != len(data) {
|
||||
test.Fatalf("n not equal: %d != %d", n, len(data))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user