Documentation
¶
Overview ¶
Package tinygo_test contains integration tests that verify the protobuf library's core packages work correctly under both the standard Go compiler and TinyGo. These tests exercise wire encoding, scalar types, field tags, and full message marshal/unmarshal roundtrips without importing the fmt package, ensuring compatibility with TinyGo's constrained stdlib.
The tests use a manually defined message type (not code-generated) that exercises all 15 protobuf scalar kinds, repeated fields, map fields, oneof fields, and nested messages. This provides end-to-end verification that the wire, scalar, field, encode, and decode packages function correctly in TinyGo environments.
All test output uses t.Errorf, t.Fatalf, and t.Logf exclusively.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type NestedMessage ¶
NestedMessage is a simple nested message with two fields used to exercise nested message encoding and decoding.
type TestMessage ¶
type TestMessage struct {
DoubleVal float64
FloatVal float32
Int32Val int32
Int64Val int64
Uint32Val uint32
Uint64Val uint64
Sint32Val int32
Sint64Val int64
Fixed32Val uint32
Fixed64Val uint64
Sfixed32Val int32
Sfixed64Val int64
BoolVal bool
StringVal string
BytesVal []byte
RepeatedInt32 []int32
Nested *NestedMessage
MapField map[string]int64
OneofKind OneofKind
OneofStrVal string
OneofNumVal int64
}
TestMessage is a manually defined protobuf message type that exercises all 15 protobuf scalar kinds plus repeated, map, oneof, and nested message fields. It implements Marshal, Unmarshal, and Size using the wire package directly, without code generation.
fieldalignment: fields ordered by protobuf field number for readability
func (*TestMessage) Marshal ¶
func (m *TestMessage) Marshal() ([]byte, error)
Marshal serializes the TestMessage to wire format.
func (*TestMessage) MarshalAppend ¶
func (m *TestMessage) MarshalAppend(b []byte) ([]byte, error)
MarshalAppend appends the wire-format encoding of the TestMessage to b.
func (*TestMessage) Size ¶
func (m *TestMessage) Size() int
Size returns the wire-encoded size of the TestMessage.
func (*TestMessage) Unmarshal ¶
func (m *TestMessage) Unmarshal(data []byte) error
Unmarshal decodes wire-format bytes into the TestMessage.