MCPcopy Create free account
hub / github.com/apache/fory / TestReducedPrecisionSlicesUseListOrdering

Function TestReducedPrecisionSlicesUseListOrdering

go/fory/struct_test.go:489–518  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

487}
488
489func TestReducedPrecisionSlicesUseListOrdering(t *testing.T) {
490 type TestStruct struct {
491 Float16Value float16.Float16
492 Bfloat16Value bfloat16.BFloat16
493 Bfloat16Array []bfloat16.BFloat16
494 Float16Array []float16.Float16
495 }
496
497 f := New(WithXlang(true), WithCompatible(false))
498 require.NoError(t, f.RegisterStruct(TestStruct{}, 1004))
499
500 typeInfo, err := f.typeResolver.getTypeInfo(reflect.ValueOf(TestStruct{}), false)
501 require.NoError(t, err)
502
503 structSer, ok := typeInfo.Serializer.(*structSerializer)
504 require.True(t, ok)
505 require.NoError(t, structSer.initialize(f.typeResolver))
506
507 require.Len(t, structSer.fieldGroup.FixedFields, 2)
508 require.Equal(t, "float16_value", structSer.fieldGroup.FixedFields[0].Meta.Name)
509 require.Equal(t, "bfloat16_value", structSer.fieldGroup.FixedFields[1].Meta.Name)
510
511 require.Len(t, structSer.fieldGroup.RemainingFields, 2)
512 require.Equal(t, "bfloat16_array", structSer.fieldGroup.RemainingFields[0].Meta.Name)
513 require.Equal(t, TypeId(LIST), structSer.fieldGroup.RemainingFields[0].Meta.TypeId)
514 require.IsType(t, primitiveListSerializer{}, structSer.fieldGroup.RemainingFields[0].Serializer)
515 require.Equal(t, "float16_array", structSer.fieldGroup.RemainingFields[1].Meta.Name)
516 require.Equal(t, TypeId(LIST), structSer.fieldGroup.RemainingFields[1].Meta.TypeId)
517 require.IsType(t, primitiveListSerializer{}, structSer.fieldGroup.RemainingFields[1].Serializer)
518}
519
520func TestTaggedFieldsKeepGroupedPayloadOrder(t *testing.T) {
521 type TaggedSortStruct struct {

Callers

nothing calls this directly

Calls 9

WithXlangFunction · 0.85
WithCompatibleFunction · 0.85
LenMethod · 0.80
NewFunction · 0.70
TypeIdEnum · 0.50
RegisterStructMethod · 0.45
getTypeInfoMethod · 0.45
initializeMethod · 0.45
EqualMethod · 0.45

Tested by

no test coverage detected