chore: refresh gramsrv public release
This commit is contained in:
parent
75cebe8dbf
commit
70b6820474
1274 changed files with 378751 additions and 59919 deletions
35
internal/compat/layerwire/walk_test.go
Normal file
35
internal/compat/layerwire/walk_test.go
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
package layerwire
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/gotd/td/bin"
|
||||
)
|
||||
|
||||
func mustEncode(t *testing.T, o bin.Encoder) []byte {
|
||||
t.Helper()
|
||||
var b bin.Buffer
|
||||
if err := o.Encode(&b); err != nil {
|
||||
t.Fatalf("encode %T: %v", o, err)
|
||||
}
|
||||
return b.Copy()
|
||||
}
|
||||
|
||||
// TestWalkConsumesCanonicalObjects encodes a diverse corpus of canonical (gotd,
|
||||
// Layer 227) objects and asserts the generic walker consumes every byte. Full
|
||||
// consumption proves the layout handles each field's wire kind (flags,
|
||||
// multi-flags, conditionals, vectors, nested boxed/bare objects) exactly as gotd
|
||||
// encoded them.
|
||||
func TestWalkConsumesCanonicalObjects(t *testing.T) {
|
||||
for _, o := range canonicalCorpus() {
|
||||
raw := mustEncode(t, o)
|
||||
b := &bin.Buffer{Buf: append([]byte(nil), raw...)}
|
||||
if err := canonical.skipObject(b); err != nil {
|
||||
t.Errorf("%T: walk error: %v", o, err)
|
||||
continue
|
||||
}
|
||||
if b.Len() != 0 {
|
||||
t.Errorf("%T: %d/%d bytes left after walk", o, b.Len(), len(raw))
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue