Documentation ¶
Overview ¶
The testencoding package is used in testing serialization and deserialization. It is particularly useful when some sub-sequences of bytes can acceptably be written in any order (e.g if they are generated from representations that do not provide order guaruntees like maps).
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type BytesLiteral ¶
type BytesLiteral struct {
Bytes []byte
}
BytesLiteral matches a literal sequence of bytes.
func LiteralString ¶
func LiteralString(s string) *BytesLiteral
func (*BytesLiteral) String ¶
func (bm *BytesLiteral) String() string
func (*BytesLiteral) Write ¶
func (bm *BytesLiteral) Write(writer *bytes.Buffer)
type BytesMatcherAnyOrder ¶
type BytesMatcherAnyOrder struct {
Matchers []IBytesMatcher
}
BytesMatcherAnyOrder matches a set of BytesMatchers, but they do not have to match in any particular order.
func AnyOrder ¶
func AnyOrder(matchers ...IBytesMatcher) *BytesMatcherAnyOrder
func (*BytesMatcherAnyOrder) Match ¶
func (bm *BytesMatcherAnyOrder) Match(b []byte) (n int, err os.Error)
func (*BytesMatcherAnyOrder) String ¶
func (bm *BytesMatcherAnyOrder) String() string
func (*BytesMatcherAnyOrder) Write ¶
func (bm *BytesMatcherAnyOrder) Write(writer *bytes.Buffer)
type BytesMatcherInOrder ¶
type BytesMatcherInOrder struct {
Matchers []IBytesMatcher
}
BytesMatcherInOrder matches a sequence of BytesMatchers that must match in the order given.
func InOrder ¶
func InOrder(matchers ...IBytesMatcher) *BytesMatcherInOrder
func (*BytesMatcherInOrder) Match ¶
func (bm *BytesMatcherInOrder) Match(b []byte) (n int, err os.Error)
func (*BytesMatcherInOrder) String ¶
func (bm *BytesMatcherInOrder) String() string
func (*BytesMatcherInOrder) Write ¶
func (bm *BytesMatcherInOrder) Write(writer *bytes.Buffer)
type IBytesMatcher ¶
type IBytesMatcher interface { // Match tests if the given sequence of bytes matches. It returns // matches=true if it matches correctly, and returns the number of bytes // matched as n. Match(b []byte) (n int, err os.Error) // Write writes a sequence of bytes to the buffer that is an acceptable match // for the matcher.. Write(writer *bytes.Buffer) String() string }
IBytesMatcher is the interface that tests if a sequence of bytes matches expectations.
type MatchError ¶
type MatchError struct { FailedMatcher IBytesMatcher NextBytes []byte }
func (*MatchError) String ¶
func (err *MatchError) String() string
type TrailingBytesError ¶
type TrailingBytesError struct { FailedMatcher IBytesMatcher TrailingBytes []byte }
func (*TrailingBytesError) String ¶
func (err *TrailingBytesError) String() string
Click to show internal directories.
Click to hide internal directories.