Ejemplo n.º 1
0
func TestVomToMojo(t *testing.T) {
	for _, test := range testCases {
		testName := test.Name + " vom->mojo"

		data, err := transcoder.ToMojom(test.VdlValue)
		if err != nil {
			t.Errorf("%s: error in VomToMojo: %v", testName, err)
			continue
		}

		out := reflect.New(reflect.TypeOf(test.MojoValue).Elem()).Interface()
		if err := mojoDecode(data, out); err != nil {
			t.Errorf("%s: error decoding mojo bytes %x: %v", testName, data, err)
			continue
		}

		if got, want := out, test.MojoValue; !reflect.DeepEqual(got, want) {
			t.Errorf("%s: result doesn't match expectation. got %#v, but want %#v", testName, got, want)
		}
	}
}
Ejemplo n.º 2
0
func TestVomToMojoToVom(t *testing.T) {
	for _, test := range testCases {
		testName := test.Name + " vom->mojo->vom"

		data, err := transcoder.ToMojom(test.VdlValue)
		if err != nil {
			t.Errorf("%s: error in VomToMojo: %v", testName, err)
			continue
		}

		var out interface{}
		if err := transcoder.ValueFromMojo(&out, data, vdl.TypeOf(test.VdlValue)); err != nil {
			t.Errorf("%s: error in MojoToVom: %v (was transcoding from %x)", testName, err, data)
			continue
		}

		if got, want := out, test.VdlValue; !reflect.DeepEqual(got, want) {
			t.Errorf("%s: result doesn't match expectation. got %#v, but want %#v", testName, got, want)
		}
	}
}
Ejemplo n.º 3
0
func BenchmarkVdlToMojomTranscoding(b *testing.B) {
	for i := 0; i < b.N; i++ {
		transcoder.ToMojom(customer)
	}
}