blob: 1b7a769b89defa7b4b1e05a7ac21b3470e5f0545 [file] [log] [blame]
// Copyright 2015 The Vanadium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// This file was auto-generated by the vanadium vdl tool.
// Source: encoding.vdl
package testdata
import (
"v.io/v23/vdl"
"v.io/x/ref/lib/discovery"
)
// PackAddressTest represents a test case for PackAddress.
type PackAddressTest struct {
// In is the addresses to pack.
In []string
// Packed is the expected packed output.
Packed []byte
}
func (PackAddressTest) __VDLReflect(struct {
Name string `vdl:"v.io/x/ref/lib/discovery/testdata.PackAddressTest"`
}) {
}
func (m *PackAddressTest) FillVDLTarget(t vdl.Target, tt *vdl.Type) error {
if __VDLType_encoding_v_io_x_ref_lib_discovery_testdata_PackAddressTest == nil || __VDLTypeencoding0 == nil {
panic("Initialization order error: types generated for FillVDLTarget not initialized. Consider moving caller to an init() block.")
}
fieldsTarget1, err := t.StartFields(tt)
if err != nil {
return err
}
keyTarget2, fieldTarget3, err := fieldsTarget1.StartField("In")
if err != vdl.ErrFieldNoExist && err != nil {
return err
}
if err != vdl.ErrFieldNoExist {
listTarget4, err := fieldTarget3.StartList(__VDLTypeencoding1, len(m.In))
if err != nil {
return err
}
for i, elem6 := range m.In {
elemTarget5, err := listTarget4.StartElem(i)
if err != nil {
return err
}
if err := elemTarget5.FromString(string(elem6), vdl.StringType); err != nil {
return err
}
if err := listTarget4.FinishElem(elemTarget5); err != nil {
return err
}
}
if err := fieldTarget3.FinishList(listTarget4); err != nil {
return err
}
if err := fieldsTarget1.FinishField(keyTarget2, fieldTarget3); err != nil {
return err
}
}
keyTarget7, fieldTarget8, err := fieldsTarget1.StartField("Packed")
if err != vdl.ErrFieldNoExist && err != nil {
return err
}
if err != vdl.ErrFieldNoExist {
if err := fieldTarget8.FromBytes([]byte(m.Packed), __VDLTypeencoding2); err != nil {
return err
}
if err := fieldsTarget1.FinishField(keyTarget7, fieldTarget8); err != nil {
return err
}
}
if err := t.FinishFields(fieldsTarget1); err != nil {
return err
}
return nil
}
func (m *PackAddressTest) MakeVDLTarget() vdl.Target {
return nil
}
// PackEncryptionKeysTest represents a test case for PackEncryptionKeys
type PackEncryptionKeysTest struct {
// Algo is the algorithm that's in use.
// but that isn't defined in vdl yet.
Algo discovery.EncryptionAlgorithm
// Keys are the encryption keys.
// but that isn't defined in vdl yet.
Keys []discovery.EncryptionKey
// Packed is the expected output bytes.
Packed []byte
}
func (PackEncryptionKeysTest) __VDLReflect(struct {
Name string `vdl:"v.io/x/ref/lib/discovery/testdata.PackEncryptionKeysTest"`
}) {
}
func (m *PackEncryptionKeysTest) FillVDLTarget(t vdl.Target, tt *vdl.Type) error {
if __VDLType_encoding_v_io_x_ref_lib_discovery_testdata_PackEncryptionKeysTest == nil || __VDLTypeencoding3 == nil {
panic("Initialization order error: types generated for FillVDLTarget not initialized. Consider moving caller to an init() block.")
}
fieldsTarget1, err := t.StartFields(tt)
if err != nil {
return err
}
keyTarget2, fieldTarget3, err := fieldsTarget1.StartField("Algo")
if err != vdl.ErrFieldNoExist && err != nil {
return err
}
if err != vdl.ErrFieldNoExist {
if err := m.Algo.FillVDLTarget(fieldTarget3, __VDLType_encoding_v_io_x_ref_lib_discovery_EncryptionAlgorithm); err != nil {
return err
}
if err := fieldsTarget1.FinishField(keyTarget2, fieldTarget3); err != nil {
return err
}
}
keyTarget4, fieldTarget5, err := fieldsTarget1.StartField("Keys")
if err != vdl.ErrFieldNoExist && err != nil {
return err
}
if err != vdl.ErrFieldNoExist {
listTarget6, err := fieldTarget5.StartList(__VDLTypeencoding4, len(m.Keys))
if err != nil {
return err
}
for i, elem8 := range m.Keys {
elemTarget7, err := listTarget6.StartElem(i)
if err != nil {
return err
}
if err := elem8.FillVDLTarget(elemTarget7, __VDLType_encoding_v_io_x_ref_lib_discovery_EncryptionKey); err != nil {
return err
}
if err := listTarget6.FinishElem(elemTarget7); err != nil {
return err
}
}
if err := fieldTarget5.FinishList(listTarget6); err != nil {
return err
}
if err := fieldsTarget1.FinishField(keyTarget4, fieldTarget5); err != nil {
return err
}
}
keyTarget9, fieldTarget10, err := fieldsTarget1.StartField("Packed")
if err != vdl.ErrFieldNoExist && err != nil {
return err
}
if err != vdl.ErrFieldNoExist {
if err := fieldTarget10.FromBytes([]byte(m.Packed), __VDLTypeencoding2); err != nil {
return err
}
if err := fieldsTarget1.FinishField(keyTarget9, fieldTarget10); err != nil {
return err
}
}
if err := t.FinishFields(fieldsTarget1); err != nil {
return err
}
return nil
}
func (m *PackEncryptionKeysTest) MakeVDLTarget() vdl.Target {
return nil
}
func init() {
vdl.Register((*PackAddressTest)(nil))
vdl.Register((*PackEncryptionKeysTest)(nil))
}
var __VDLTypeencoding0 *vdl.Type = vdl.TypeOf((*PackAddressTest)(nil))
var __VDLTypeencoding3 *vdl.Type = vdl.TypeOf((*PackEncryptionKeysTest)(nil))
var __VDLTypeencoding2 *vdl.Type = vdl.TypeOf([]byte(nil))
var __VDLTypeencoding1 *vdl.Type = vdl.TypeOf([]string(nil))
var __VDLTypeencoding4 *vdl.Type = vdl.TypeOf([]discovery.EncryptionKey(nil))
var __VDLType_encoding_v_io_x_ref_lib_discovery_EncryptionAlgorithm *vdl.Type = vdl.TypeOf(discovery.EncryptionAlgorithm(0))
var __VDLType_encoding_v_io_x_ref_lib_discovery_EncryptionKey *vdl.Type = vdl.TypeOf(discovery.EncryptionKey(nil))
var __VDLType_encoding_v_io_x_ref_lib_discovery_testdata_PackAddressTest *vdl.Type = vdl.TypeOf(PackAddressTest{})
var __VDLType_encoding_v_io_x_ref_lib_discovery_testdata_PackEncryptionKeysTest *vdl.Type = vdl.TypeOf(PackEncryptionKeysTest{})
func __VDLEnsureNativeBuilt_encoding() {
}
var PackAddressTestData = []PackAddressTest{
{
In: []string{
"a12345",
},
Packed: []byte("\x06a12345"),
},
{
In: []string{
"a1234",
"b5678",
"c9012",
},
Packed: []byte("\x05a1234\x05b5678\x05c9012"),
},
{},
}
var PackEncryptionKeysTestData = []PackEncryptionKeysTest{
{
Algo: 1,
Keys: []discovery.EncryptionKey{
discovery.EncryptionKey("0123456789"),
},
Packed: []byte("\x01\n0123456789"),
},
{
Algo: 2,
Keys: []discovery.EncryptionKey{
discovery.EncryptionKey("012345"),
discovery.EncryptionKey("123456"),
discovery.EncryptionKey("234567"),
},
Packed: []byte("\x02\x06012345\x06123456\x06234567"),
},
{
Packed: []byte("\x00"),
},
}