Exemple #1
0
func TestStructWithRefChunks(t *testing.T) {
	assert := assert.New(t)

	set := gen.SetOfFloat32Def{0: true}.New()
	str := gen.StructWithRefDef{
		R: set.Ref(),
	}.New()

	// 1 for the Type and 1 for the ref in the R field.
	assert.Len(str.Chunks(), 2)
}
Exemple #2
0
func TestStructWithRef(t *testing.T) {
	assert := assert.New(t)
	ds := datas.NewDataStore(chunks.NewMemoryStore())

	set := gen.SetOfFloat32Def{0: true, 1: true, 2: true}.New()
	ds.WriteValue(set)

	str := gen.StructWithRefDef{
		R: set.Ref(),
	}.New()
	ds.WriteValue(str)

	r := str.R()
	r2 := gen.NewRefOfSetOfFloat32(set.Ref())
	assert.True(r.Equals(r2))
	assert.True(r2.TargetValue(ds).Equals(set))

	set2 := r2.TargetValue(ds)
	assert.True(set.Equals(set2))

	def := str.Def()
	assert.EqualValues(set.Ref(), def.R)
}