Пример #1
0
func Test_Write_SingleBuiltinLong(t *testing.T) {
	what := &mock.SingleBuiltinLong{232688356}
	expect := []byte{
		0x90, 0x29, 0x9e, 0x6f,
		0xe4, 0x8a, 0xde, 0xd, 0x0, 0x0, 0x0, 0x0}
	utils.WriteCheck(t, expect, what.Box())
}
Пример #2
0
func Test_Write_VectorDeepBoxed(t *testing.T) {
	what := &mock.SingleVectorDeepBoxed{
		[][]mock.SingleBuiltinBox{
			{*((&mock.SingleBuiltinInt32{45}).Box().(*mock.SingleBuiltinBox)),
				*((&mock.SingleBuiltinInt32{678}).Box().(*mock.SingleBuiltinBox))},
			{*((&mock.SingleBuiltinInt32{45}).Box().(*mock.SingleBuiltinBox)),
				*((&mock.SingleBuiltinInt32{678}).Box().(*mock.SingleBuiltinBox))},
		},
	}
	expect := []byte{
		0x41, 0x51, 0xf, 0x56,
		0x15, 0xc4, 0xb5, 0x1c,
		0x2, 0x0, 0x0, 0x0,
		0x15, 0xc4, 0xb5, 0x1c,
		0x2, 0x0, 0x0, 0x0,
		0xee, 0x70, 0x1b, 0x1f,
		0x2d, 0x0, 0x0, 0x0,
		0xee, 0x70, 0x1b, 0x1f,
		0xa6, 0x2, 0x0, 0x0,
		0x15, 0xc4, 0xb5, 0x1c,
		0x2, 0x0, 0x0, 0x0,
		0xee, 0x70, 0x1b, 0x1f,
		0x2d, 0x0, 0x0, 0x0,
		0xee, 0x70, 0x1b, 0x1f,
		0xa6, 0x2, 0x0, 0x0}
	utils.WriteCheck(t, expect, what.Box())
}
Пример #3
0
func Test_Write_MsgContainerEmpty(t *testing.T) {
	expect := &mock.MsgContainer{}
	data := []byte{
		0xdc, 0xf8, 0xf1, 0x73,
		0x0, 0x0, 0x0, 0x0}
	utils.WriteCheck(t, data, expect.Box())
}
Пример #4
0
func Test_Write_SingleX(t *testing.T) {
	expect := &mock.SingleX{*builtin.NewObject(&mock.SingleBuiltinInt32{45})}
	data := []byte{
		0xa9, 0xb7, 0x84, 0x75,
		0xee, 0x70, 0x1b, 0x1f,
		0x2d, 0x0, 0x0, 0x0}
	utils.WriteCheck(t, data, expect.Box())
}
Пример #5
0
func Test_Write_SingleMultiInt32_1(t *testing.T) {
	expect := &mock.SingleMultiInt32{[]int32{1, 2}}
	data := []byte{
		0xe5, 0x7b, 0xed, 0xf5,
		0x2, 0x0, 0x0, 0x0,
		0x1, 0x0, 0x0, 0x0,
		0x2, 0x0, 0x0, 0x0,
	}
	utils.WriteCheck(t, data, expect.Box())
}
Пример #6
0
func Test_Write_SingleMultiIntR4(t *testing.T) {
	expect := &mock.SingleMultiInt32R4{[]int32{1, 2, 3, 4}}
	data := []byte{
		0xf9, 0x6e, 0xac, 0x3a,
		0x1, 0x0, 0x0, 0x0,
		0x2, 0x0, 0x0, 0x0,
		0x3, 0x0, 0x0, 0x0,
		0x4, 0x0, 0x0, 0x0}
	utils.WriteCheck(t, data, expect.Box())
}
Пример #7
0
func Test_Write_VectorBytes(t *testing.T) {
	what := &mock.SingleVectorBytes{[][]byte{[]byte("test1"), []byte("test2")}}
	expect := []byte{
		0xd2, 0xca, 0xdf, 0x51,
		0x15, 0xc4, 0xb5, 0x1c,
		0x2, 0x0, 0x0, 0x0,
		0x5, 0x74, 0x65, 0x73, 0x74, 0x31, 0x0, 0x0,
		0x5, 0x74, 0x65, 0x73, 0x74, 0x32, 0x0, 0x0}
	utils.WriteCheck(t, expect, what.Box())
}
Пример #8
0
func Test_Write_VectorInt(t *testing.T) {
	what := &mock.SingleVectorInt{[]int32{1, 2, 3, 4}}
	expect := []byte{
		0xc8, 0xa2, 0xc3, 0xcd,
		0x15, 0xc4, 0xb5, 0x1c,
		0x4, 0x0, 0x0, 0x0,
		0x1, 0x0, 0x0, 0x0,
		0x2, 0x0, 0x0, 0x0,
		0x3, 0x0, 0x0, 0x0,
		0x4, 0x0, 0x0, 0x0}
	utils.WriteCheck(t, expect, what.Box())
}
Пример #9
0
func Test_Write_VectorString(t *testing.T) {
	what := &mock.SingleVectorString{[]string{"test1", "test2"}}
	expect := []byte{
		0x8, 0x5e, 0x7d, 0x7,
		0x15, 0xc4, 0xb5, 0x1c,
		0x2, 0x0, 0x0, 0x0,
		0x5,
		0x74, 0x65, 0x73, 0x74, 0x31, 0x0, 0x0,
		0x5,
		0x74, 0x65, 0x73, 0x74, 0x32, 0x0, 0x0}
	utils.WriteCheck(t, expect, what.Box())
}
Пример #10
0
func Test_Write_VectorDouble(t *testing.T) {
	what := &mock.SingleVectorDouble{[]float64{1.1, 2.2, 3.3, 4.4}}
	expect := []byte{
		0xae, 0xd, 0xd5, 0xfb,
		0x15, 0xc4, 0xb5, 0x1c,
		0x4, 0x0, 0x0, 0x0,
		0x9a, 0x99, 0x99, 0x99, 0x99, 0x99, 0xf1, 0x3f,
		0x9a, 0x99, 0x99, 0x99, 0x99, 0x99, 0x1, 0x40,
		0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0xa, 0x40,
		0x9a, 0x99, 0x99, 0x99, 0x99, 0x99, 0x11, 0x40}
	utils.WriteCheck(t, expect, what.Box())
}
Пример #11
0
func Test_Write_VectorLong(t *testing.T) {
	what := &mock.SingleVectorLong{[]int64{1, 2, 3, 4}}
	expect := []byte{
		0xe8, 0x95, 0xe0, 0xff,
		0x15, 0xc4, 0xb5, 0x1c,
		0x4, 0x0, 0x0, 0x0,
		0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
		0x2, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
		0x3, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
		0x4, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}
	utils.WriteCheck(t, expect, what.Box())
}
Пример #12
0
func Test_Write_SingleMultiInt32_2(t *testing.T) {
	one1 := &mock.SingleMultiInt32{[]int32{1, 2, 3, 4}}
	expect := []byte{
		0xe5, 0x7b, 0xed, 0xf5,
		0x4, 0x0, 0x0, 0x0,
		0x1, 0x0, 0x0, 0x0,
		0x2, 0x0, 0x0, 0x0,
		0x3, 0x0, 0x0, 0x0,
		0x4, 0x0, 0x0, 0x0,
	}
	utils.WriteCheck(t, expect, one1.Box())
}
Пример #13
0
func Test_Write_SingleMultiBoxed(t *testing.T) {
	one1 := &mock.SingleMultiBoxed{[]mock.SingleBuiltinBox{
		(&mock.SingleBuiltinInt32{45}).Boxed(),
		(&mock.SingleBuiltinInt32{678}).Boxed(),
	}}
	expect := []byte{
		0xfc, 0x21, 0x1, 0xef,
		0x2, 0x0, 0x0, 0x0,
		0xee, 0x70, 0x1b, 0x1f,
		0x2d, 0x0, 0x0, 0x0,
		0xee, 0x70, 0x1b, 0x1f,
		0xa6, 0x2, 0x0, 0x0}
	utils.WriteCheck(t, expect, one1.Box())
}
Пример #14
0
func Test_Write_SingleVectorX(t *testing.T) {
	expect := &mock.SingleVectorX{
		[]builtin.ObjectBox{
			*builtin.NewObject(&mock.SingleBuiltinInt32{45}),
		},
	}
	data := []byte{
		0xa7, 0x3b, 0x53, 0x68,
		0x15, 0xc4, 0xb5, 0x1c,
		0x1, 0x0, 0x0, 0x0,
		0xee, 0x70, 0x1b, 0x1f,
		0x2d, 0x0, 0x0, 0x0}
	utils.WriteCheck(t, data, expect.Box())
}
Пример #15
0
func Test_Write_MsgContainer(t *testing.T) {
	expect := &mock.MsgContainer{[]mock.Message{
		mock.Message{34, 3, 67, *(builtin.NewObject(&mock.SingleBuiltinInt32{45}))},
	}}
	data := []byte{
		0xdc, 0xf8, 0xf1, 0x73,
		0x1, 0x0, 0x0, 0x0,
		0x22, 0x0, 0x0, 0x0,
		0x0, 0x0, 0x0, 0x0,
		0x3, 0x0, 0x0, 0x0,
		0x43, 0x0, 0x0, 0x0,
		0xee, 0x70, 0x1b, 0x1f,
		0x2d, 0x0, 0x0, 0x0}
	utils.WriteCheck(t, data, expect.Box())
}
Пример #16
0
func Test_Write_SingleMultiBoxedR4(t *testing.T) {
	one1 := &mock.SingleMultiBoxedR4{[]mock.SingleBuiltinBox{
		*((&mock.SingleBuiltinInt32{45}).Box().(*mock.SingleBuiltinBox)),
		*((&mock.SingleBuiltinInt32{678}).Box().(*mock.SingleBuiltinBox)),
		*((&mock.SingleBuiltinInt32{89}).Box().(*mock.SingleBuiltinBox)),
		*((&mock.SingleBuiltinString{"test"}).Box().(*mock.SingleBuiltinBox)),
	}}
	expect := []byte{
		0xc4, 0xd4, 0x10, 0x21,
		0xee, 0x70, 0x1b, 0x1f,
		0x2d, 0x0, 0x0, 0x0,
		0xee, 0x70, 0x1b, 0x1f,
		0xa6, 0x2, 0x0, 0x0,
		0xee, 0x70, 0x1b, 0x1f,
		0x59, 0x0, 0x0, 0x0,
		0x64, 0x27, 0x23, 0x16,
		0x4, 0x74, 0x65, 0x73,
		0x74, 0x0, 0x0, 0x0}
	utils.WriteCheck(t, expect, one1.Box())
}
Пример #17
0
func Test_Write_SingleBuiltinBytes(t *testing.T) {
	expect := &mock.SingleBuiltinBytes{[]byte("Мама мыла Раму. Рама был индус.")}
	data := []byte{
		0xe9, 0xae, 0x23, 0x60,
		0x37, 0xd0, 0x9c, 0xd0,
		0xb0, 0xd0, 0xbc, 0xd0,
		0xb0, 0x20, 0xd0, 0xbc,
		0xd1, 0x8b, 0xd0, 0xbb,
		0xd0, 0xb0, 0x20, 0xd0,
		0xa0, 0xd0, 0xb0, 0xd0,
		0xbc, 0xd1, 0x83, 0x2e,
		0x20, 0xd0, 0xa0, 0xd0,
		0xb0, 0xd0, 0xbc, 0xd0,
		0xb0, 0x20, 0xd0, 0xb1,
		0xd1, 0x8b, 0xd0, 0xbb,
		0x20, 0xd0, 0xb8, 0xd0,
		0xbd, 0xd0, 0xb4, 0xd1,
		0x83, 0xd1, 0x81, 0x2e}
	utils.WriteCheck(t, data, expect.Box())
}
Пример #18
0
func Test_Write_MultiVectorInt(t *testing.T) {
	what := &mock.SingleMultiVectorInt{[][]int32{
		{1, 2, 3, 4},
		{1, 2, 3, 4},
	}}
	expect := []byte{
		0xfe, 0xae, 0xd6, 0xea,
		0x15, 0xc4, 0xb5, 0x1c,
		0x4, 0x0, 0x0, 0x0,
		0x1, 0x0, 0x0, 0x0,
		0x2, 0x0, 0x0, 0x0,
		0x3, 0x0, 0x0, 0x0,
		0x4, 0x0, 0x0, 0x0,
		0x15, 0xc4, 0xb5, 0x1c,
		0x4, 0x0, 0x0, 0x0,
		0x1, 0x0, 0x0, 0x0,
		0x2, 0x0, 0x0, 0x0,
		0x3, 0x0, 0x0, 0x0,
		0x4, 0x0, 0x0, 0x0}
	utils.WriteCheck(t, expect, what.Box())
}
Пример #19
0
func Test_Write_VectorDeepInt(t *testing.T) {
	what := &mock.SingleVectorDeepInt{[][]int32{
		{1, 2, 3, 4},
		{1, 2, 3, 4},
	}}
	expect := []byte{
		0xf5, 0x85, 0xce, 0xa9,
		0x15, 0xc4, 0xb5, 0x1c,
		0x2, 0x0, 0x0, 0x0,
		0x15, 0xc4, 0xb5, 0x1c,
		0x4, 0x0, 0x0, 0x0,
		0x1, 0x0, 0x0, 0x0,
		0x2, 0x0, 0x0, 0x0,
		0x3, 0x0, 0x0, 0x0,
		0x4, 0x0, 0x0, 0x0,
		0x15, 0xc4, 0xb5, 0x1c,
		0x4, 0x0, 0x0, 0x0,
		0x1, 0x0, 0x0, 0x0,
		0x2, 0x0, 0x0, 0x0,
		0x3, 0x0, 0x0, 0x0,
		0x4, 0x0, 0x0, 0x0}
	utils.WriteCheck(t, expect, what.Box())
}
Пример #20
0
func Test_Write_SingleBuiltinDouble(t *testing.T) {
	what := &mock.SingleBuiltinDouble{232688356.34}
	expect := []byte{0x9f, 0x99, 0x66, 0x61,
		0x7b, 0x14, 0xae, 0xc8, 0x15, 0xbd, 0xab, 0x41}
	utils.WriteCheck(t, expect, what.Box())
}
Пример #21
0
func Test_Write_SingleBuiltinInt(t *testing.T) {
	what := &mock.SingleBuiltinInt32{232688356}
	expect := []byte{0xee, 0x70, 0x1b, 0x1f, 0xe4, 0x8a, 0xde, 0xd}
	utils.WriteCheck(t, expect, what.Box())
}