[chore] Change JSON/Proto tests to tests for empty and filled types (#13618)
Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
This commit is contained in:
parent
03ff8252f4
commit
c6594a2b5e
|
|
@ -19,6 +19,8 @@ type Field interface {
|
|||
GenerateSizeProto(ms *messageStruct) string
|
||||
|
||||
GenerateMarshalProto(ms *messageStruct) string
|
||||
|
||||
GenerateTestValue(ms *messageStruct) string
|
||||
}
|
||||
|
||||
func origAccessor(hasWrapper bool) string {
|
||||
|
|
|
|||
|
|
@ -57,6 +57,8 @@ func (mf *MessageField) GenerateSetWithTestValue(ms *messageStruct) string {
|
|||
return executeTemplate(t, mf.templateFields(ms))
|
||||
}
|
||||
|
||||
func (mf *MessageField) GenerateTestValue(*messageStruct) string { return "" }
|
||||
|
||||
func (mf *MessageField) GenerateCopyOrig(ms *messageStruct) string {
|
||||
t := template.Must(templateNew("messageCopyOrigTemplate").Parse(messageCopyOrigTemplate))
|
||||
return executeTemplate(t, mf.templateFields(ms))
|
||||
|
|
|
|||
|
|
@ -33,6 +33,8 @@ const oneOfAccessorTestTemplate = `func Test{{ .structName }}_{{ .typeFuncName }
|
|||
{{ end }}
|
||||
`
|
||||
|
||||
const oneOfTestValuesTemplate = `{{- range .values }}{{ .GenerateTestValue $.baseStruct $.OneOfField }}{{- end }}`
|
||||
|
||||
const oneOfCopyOrigTemplate = `switch t := src.{{ .originFieldName }}.(type) {
|
||||
{{- range .values }}
|
||||
{{ .GenerateCopyOrig $.baseStruct $.OneOfField }}
|
||||
|
|
@ -95,6 +97,11 @@ func (of *OneOfField) GenerateSetWithTestValue(ms *messageStruct) string {
|
|||
return of.values[of.testValueIdx].GenerateSetWithTestValue(ms, of)
|
||||
}
|
||||
|
||||
func (of *OneOfField) GenerateTestValue(ms *messageStruct) string {
|
||||
t := template.Must(templateNew("oneOfTestValuesTemplate").Parse(oneOfTestValuesTemplate))
|
||||
return executeTemplate(t, of.templateFields(ms))
|
||||
}
|
||||
|
||||
func (of *OneOfField) GenerateCopyOrig(ms *messageStruct) string {
|
||||
t := template.Must(templateNew("oneOfCopyOrigTemplate").Parse(oneOfCopyOrigTemplate))
|
||||
return executeTemplate(t, of.templateFields(ms))
|
||||
|
|
@ -144,6 +151,7 @@ type oneOfValue interface {
|
|||
GenerateAccessors(ms *messageStruct, of *OneOfField) string
|
||||
GenerateTests(ms *messageStruct, of *OneOfField) string
|
||||
GenerateSetWithTestValue(ms *messageStruct, of *OneOfField) string
|
||||
GenerateTestValue(ms *messageStruct, of *OneOfField) string
|
||||
GenerateCopyOrig(ms *messageStruct, of *OneOfField) string
|
||||
GenerateType(ms *messageStruct, of *OneOfField) string
|
||||
GenerateMarshalJSON(ms *messageStruct, of *OneOfField) string
|
||||
|
|
|
|||
|
|
@ -46,10 +46,17 @@ const oneOfMessageAccessorsTestTemplate = `func Test{{ .structName }}_{{ .fieldN
|
|||
}
|
||||
`
|
||||
|
||||
const oneOfMessageSetTestTemplate = `orig.{{ .originOneOfFieldName }} = &{{ .originStructName }}_{{ .fieldName -}}{
|
||||
const oneOfMessageSetTestTemplate = `orig.{{ .originOneOfFieldName }} = &{{ .originStructType }}{
|
||||
{{- .fieldName }}: &{{ .originFieldPackageName }}.{{ .fieldName }}{}}
|
||||
FillOrigTest{{ .fieldOriginName }}(orig.Get{{ .returnType }}())`
|
||||
|
||||
const oneOfMessageTestValuesTemplate = `
|
||||
"oneof_{{ .lowerFieldName }}": { {{ .originOneOfFieldName }}: func() *{{ .originStructType }}{
|
||||
val := &{{ .originFieldPackageName }}.{{ .fieldName }}{}
|
||||
FillOrigTest{{ .fieldOriginName }}(val)
|
||||
return &{{ .originStructType }}{{ "{" }}{{ .fieldName }}: val}
|
||||
}()},`
|
||||
|
||||
const oneOfMessageCopyOrigTemplate = ` case *{{ .originStructType }}:
|
||||
{{ .lowerFieldName }} := &{{ .originFieldPackageName}}.{{ .fieldName }}{}
|
||||
CopyOrig{{ .fieldOriginName }}({{ .lowerFieldName }}, t.{{ .fieldName }})
|
||||
|
|
@ -57,7 +64,7 @@ const oneOfMessageCopyOrigTemplate = ` case *{{ .originStructType }}:
|
|||
{{ .fieldName }}: {{ .lowerFieldName }},
|
||||
}`
|
||||
|
||||
const oneOfMessageTypeTemplate = `case *{{ .originStructName }}_{{ .originFieldName }}:
|
||||
const oneOfMessageTypeTemplate = `case *{{ .originStructType }}:
|
||||
return {{ .typeName }}`
|
||||
|
||||
const oneOfMessageUnmarshalJSONTemplate = `case "{{ lowerFirst .originFieldName }}"{{ if needSnake .originFieldName -}}, "{{ toSnake .originFieldName }}"{{- end }}:
|
||||
|
|
@ -91,6 +98,11 @@ func (omv *OneOfMessageValue) GenerateSetWithTestValue(ms *messageStruct, of *On
|
|||
return executeTemplate(t, omv.templateFields(ms, of))
|
||||
}
|
||||
|
||||
func (omv *OneOfMessageValue) GenerateTestValue(ms *messageStruct, of *OneOfField) string {
|
||||
t := template.Must(templateNew("oneOfMessageTestValuesTemplate").Parse(oneOfMessageTestValuesTemplate))
|
||||
return executeTemplate(t, omv.templateFields(ms, of))
|
||||
}
|
||||
|
||||
func (omv *OneOfMessageValue) GenerateCopyOrig(ms *messageStruct, of *OneOfField) string {
|
||||
t := template.Must(templateNew("oneOfMessageCopyOrigTemplate").Parse(oneOfMessageCopyOrigTemplate))
|
||||
return executeTemplate(t, omv.templateFields(ms, of))
|
||||
|
|
|
|||
|
|
@ -44,14 +44,17 @@ const oneOfPrimitiveAccessorTestTemplate = `func Test{{ .structName }}_{{ .acces
|
|||
}
|
||||
`
|
||||
|
||||
const oneOfPrimitiveSetTestTemplate = `orig.{{ .originOneOfFieldName }} = &{{ .originStructName }}_{{ .originFieldName }}{
|
||||
const oneOfPrimitiveSetTestTemplate = `orig.{{ .originOneOfFieldName }} = &{{ .originStructType }}{
|
||||
{{- .originFieldName }}: {{ .testValue }}}`
|
||||
|
||||
const oneOfPrimitiveCopyOrigTemplate = `case *{{ .originStructName }}_{{ .originFieldName }}:
|
||||
dest.{{ .originOneOfFieldName }} = &{{ .originStructName }}_{{ .originFieldName }}{
|
||||
const oneOfPrimitiveTestValuesTemplate = `
|
||||
"oneof_{{ .lowerFieldName }}": { {{ .originOneOfFieldName }}: &{{ .originStructType }}{{ "{" }}{{ .originFieldName }}: {{ .defaultVal }}} },`
|
||||
|
||||
const oneOfPrimitiveCopyOrigTemplate = `case *{{ .originStructType }}:
|
||||
dest.{{ .originOneOfFieldName }} = &{{ .originStructType }}{
|
||||
{{- .originFieldName }}: t.{{ .originFieldName }}}`
|
||||
|
||||
const oneOfPrimitiveTypeTemplate = `case *{{ .originStructName }}_{{ .originFieldName }}:
|
||||
const oneOfPrimitiveTypeTemplate = `case *{{ .originStructType }}:
|
||||
return {{ .typeName }}`
|
||||
|
||||
const oneOfPrimitiveUnmarshalJSONTemplate = `case "{{ lowerFirst .originFieldName }}"{{ if needSnake .originFieldName -}}, "{{ toSnake .originFieldName }}"{{- end }}:
|
||||
|
|
@ -85,6 +88,11 @@ func (opv *OneOfPrimitiveValue) GenerateSetWithTestValue(ms *messageStruct, of *
|
|||
return executeTemplate(t, opv.templateFields(ms, of))
|
||||
}
|
||||
|
||||
func (opv *OneOfPrimitiveValue) GenerateTestValue(ms *messageStruct, of *OneOfField) string {
|
||||
t := template.Must(templateNew("oneOfPrimitiveTestValuesTemplate").Parse(oneOfPrimitiveTestValuesTemplate))
|
||||
return executeTemplate(t, opv.templateFields(ms, of))
|
||||
}
|
||||
|
||||
func (opv *OneOfPrimitiveValue) GenerateCopyOrig(ms *messageStruct, of *OneOfField) string {
|
||||
t := template.Must(templateNew("oneOfPrimitiveCopyOrigTemplate").Parse(oneOfPrimitiveCopyOrigTemplate))
|
||||
return executeTemplate(t, opv.templateFields(ms, of))
|
||||
|
|
|
|||
|
|
@ -55,6 +55,9 @@ const optionalPrimitiveAccessorsTestTemplate = `func Test{{ .structName }}_{{ .f
|
|||
const optionalPrimitiveSetTestTemplate = `orig.{{ .fieldName }}_ = &{{ .originStructType }}{
|
||||
{{- .fieldName }}: {{ .testValue }}}`
|
||||
|
||||
const optionalPrimitiveTestValuesTemplate = `
|
||||
"default_{{ .lowerFieldName }}": { {{ .fieldName }}_: &{{ .originStructType }}{{ "{" }}{{ .fieldName }}: {{ .defaultVal }}} },`
|
||||
|
||||
const optionalPrimitiveCopyOrigTemplate = `if src{{ .fieldName }}, ok := src.{{ .fieldName }}_.(*{{ .originStructType }}); ok {
|
||||
dest{{ .fieldName }}, ok := dest.{{ .fieldName }}_.(*{{ .originStructType }})
|
||||
if !ok {
|
||||
|
|
@ -90,6 +93,11 @@ func (opv *OptionalPrimitiveField) GenerateSetWithTestValue(ms *messageStruct) s
|
|||
return executeTemplate(t, opv.templateFields(ms))
|
||||
}
|
||||
|
||||
func (opv *OptionalPrimitiveField) GenerateTestValue(ms *messageStruct) string {
|
||||
t := template.Must(templateNew("optionalPrimitiveTestValuesTemplate").Parse(optionalPrimitiveTestValuesTemplate))
|
||||
return executeTemplate(t, opv.templateFields(ms))
|
||||
}
|
||||
|
||||
func (opv *OptionalPrimitiveField) GenerateCopyOrig(ms *messageStruct) string {
|
||||
t := template.Must(templateNew("optionalPrimitiveCopyOrigTemplate").Parse(optionalPrimitiveCopyOrigTemplate))
|
||||
return executeTemplate(t, opv.templateFields(ms))
|
||||
|
|
|
|||
|
|
@ -72,6 +72,8 @@ func (pf *PrimitiveField) GenerateSetWithTestValue(ms *messageStruct) string {
|
|||
return executeTemplate(t, pf.templateFields(ms))
|
||||
}
|
||||
|
||||
func (pf *PrimitiveField) GenerateTestValue(*messageStruct) string { return "" }
|
||||
|
||||
func (pf *PrimitiveField) GenerateCopyOrig(ms *messageStruct) string {
|
||||
t := template.Must(templateNew("primitiveCopyOrigTemplate").Parse(primitiveCopyOrigTemplate))
|
||||
return executeTemplate(t, pf.templateFields(ms))
|
||||
|
|
|
|||
|
|
@ -63,6 +63,8 @@ func (sf *SliceField) GenerateSetWithTestValue(ms *messageStruct) string {
|
|||
return executeTemplate(t, sf.templateFields(ms))
|
||||
}
|
||||
|
||||
func (sf *SliceField) GenerateTestValue(*messageStruct) string { return "" }
|
||||
|
||||
func (sf *SliceField) GenerateCopyOrig(ms *messageStruct) string {
|
||||
t := template.Must(templateNew("sliceCopyOrigTemplate").Parse(sliceCopyOrigTemplate))
|
||||
return executeTemplate(t, sf.templateFields(ms))
|
||||
|
|
|
|||
|
|
@ -22,46 +22,55 @@ func TestCopyOrig{{ .originName }}(t *testing.T) {
|
|||
assert.Equal(t, src, dest)
|
||||
}
|
||||
|
||||
func TestMarshalAndUnmarshalJSONOrig{{ .originName }}(t *testing.T) {
|
||||
src := &{{ .originFullName }}{}
|
||||
FillOrigTest{{ .originName }}(src)
|
||||
stream := json.BorrowStream(nil)
|
||||
defer json.ReturnStream(stream)
|
||||
MarshalJSONOrig{{ .originName }}(src, stream)
|
||||
require.NoError(t, stream.Error())
|
||||
|
||||
// Append an unknown field at the start to ensure unknown fields are skipped
|
||||
// and the unmarshal logic continues.
|
||||
buf := stream.Buffer()
|
||||
assert.EqualValues(t, '{', buf[0])
|
||||
iter := json.BorrowIterator(append([]byte(`{"unknown": "string",`), buf[1:]...))
|
||||
func TestMarshalAndUnmarshalJSONOrig{{ .originName }}Unknown(t *testing.T) {
|
||||
iter := json.BorrowIterator([]byte(`{"unknown": "string"}`))
|
||||
defer json.ReturnIterator(iter)
|
||||
dest := &{{ .originFullName }}{}
|
||||
UnmarshalJSONOrig{{ .originName }}(dest, iter)
|
||||
require.NoError(t, iter.Error())
|
||||
assert.Equal(t, &{{ .originFullName }}{}, dest)
|
||||
}
|
||||
|
||||
assert.Equal(t, src, dest)
|
||||
func TestMarshalAndUnmarshalJSONOrig{{ .originName }}(t *testing.T) {
|
||||
for name, src := range getEncodingTestValues{{ .originName }}() {
|
||||
t.Run(name, func(t *testing.T) {
|
||||
stream := json.BorrowStream(nil)
|
||||
defer json.ReturnStream(stream)
|
||||
MarshalJSONOrig{{ .originName }}(src, stream)
|
||||
require.NoError(t, stream.Error())
|
||||
|
||||
iter := json.BorrowIterator(stream.Buffer())
|
||||
defer json.ReturnIterator(iter)
|
||||
dest := &{{ .originFullName }}{}
|
||||
UnmarshalJSONOrig{{ .originName }}(dest, iter)
|
||||
require.NoError(t, iter.Error())
|
||||
|
||||
assert.Equal(t, src, dest)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestMarshalAndUnmarshalProtoOrig{{ .originName }}(t *testing.T) {
|
||||
src := &{{ .originFullName }}{}
|
||||
FillOrigTest{{ .originName }}(src)
|
||||
buf := make([]byte, SizeProtoOrig{{ .originName }}(src))
|
||||
gotSize := MarshalProtoOrig{{ .originName }}(src, buf)
|
||||
assert.Equal(t, len(buf), gotSize)
|
||||
for name, src := range getEncodingTestValues{{ .originName }}(){
|
||||
t.Run(name, func(t *testing.T) {
|
||||
buf := make([]byte, SizeProtoOrig{{ .originName }}(src))
|
||||
gotSize := MarshalProtoOrig{{ .originName }}(src, buf)
|
||||
assert.Equal(t, len(buf), gotSize)
|
||||
|
||||
dest := &{{ .originFullName }}{}
|
||||
require.NoError(t, UnmarshalProtoOrig{{ .originName }}(dest, buf))
|
||||
assert.Equal(t, src, dest)
|
||||
dest := &{{ .originFullName }}{}
|
||||
require.NoError(t, UnmarshalProtoOrig{{ .originName }}(dest, buf))
|
||||
assert.Equal(t, src, dest)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestMarshalAndUnmarshalProtoOrigEmpty{{ .originName }}(t *testing.T) {
|
||||
src := &{{ .originFullName }}{}
|
||||
buf := make([]byte, SizeProtoOrig{{ .originName }}(src))
|
||||
gotSize := MarshalProtoOrig{{ .originName }}(src, buf)
|
||||
assert.Equal(t, len(buf), gotSize)
|
||||
|
||||
dest := &{{ .originFullName }}{}
|
||||
require.NoError(t, UnmarshalProtoOrig{{ .originName }}(dest, buf))
|
||||
assert.Equal(t, src, dest)
|
||||
func getEncodingTestValues{{ .originName }}() map[string]*{{ .originFullName }} {
|
||||
return map[string]*{{ .originFullName }}{
|
||||
"empty": &{{ .originFullName }}{},
|
||||
"fill_test": func() *{{ .originFullName }} {
|
||||
src := &{{ .originFullName }}{}
|
||||
FillOrigTest{{ .originName }}(src)
|
||||
return src
|
||||
}(), {{ range .fields -}}{{ .GenerateTestValue $.messageStruct }}{{ end }}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -74,6 +74,8 @@ func (ptf *TypedField) GenerateSetWithTestValue(ms *messageStruct) string {
|
|||
return executeTemplate(t, ptf.templateFields(ms))
|
||||
}
|
||||
|
||||
func (ptf *TypedField) GenerateTestValue(*messageStruct) string { return "" }
|
||||
|
||||
func (ptf *TypedField) GenerateCopyOrig(ms *messageStruct) string {
|
||||
t := template.Must(templateNew("typedCopyOrigTemplate").Parse(typedCopyOrigTemplate))
|
||||
return executeTemplate(t, ptf.templateFields(ms))
|
||||
|
|
|
|||
|
|
@ -26,46 +26,55 @@ func TestCopyOrigAttributeUnit(t *testing.T) {
|
|||
assert.Equal(t, src, dest)
|
||||
}
|
||||
|
||||
func TestMarshalAndUnmarshalJSONOrigAttributeUnit(t *testing.T) {
|
||||
src := &otlpprofiles.AttributeUnit{}
|
||||
FillOrigTestAttributeUnit(src)
|
||||
stream := json.BorrowStream(nil)
|
||||
defer json.ReturnStream(stream)
|
||||
MarshalJSONOrigAttributeUnit(src, stream)
|
||||
require.NoError(t, stream.Error())
|
||||
|
||||
// Append an unknown field at the start to ensure unknown fields are skipped
|
||||
// and the unmarshal logic continues.
|
||||
buf := stream.Buffer()
|
||||
assert.EqualValues(t, '{', buf[0])
|
||||
iter := json.BorrowIterator(append([]byte(`{"unknown": "string",`), buf[1:]...))
|
||||
func TestMarshalAndUnmarshalJSONOrigAttributeUnitUnknown(t *testing.T) {
|
||||
iter := json.BorrowIterator([]byte(`{"unknown": "string"}`))
|
||||
defer json.ReturnIterator(iter)
|
||||
dest := &otlpprofiles.AttributeUnit{}
|
||||
UnmarshalJSONOrigAttributeUnit(dest, iter)
|
||||
require.NoError(t, iter.Error())
|
||||
assert.Equal(t, &otlpprofiles.AttributeUnit{}, dest)
|
||||
}
|
||||
|
||||
assert.Equal(t, src, dest)
|
||||
func TestMarshalAndUnmarshalJSONOrigAttributeUnit(t *testing.T) {
|
||||
for name, src := range getEncodingTestValuesAttributeUnit() {
|
||||
t.Run(name, func(t *testing.T) {
|
||||
stream := json.BorrowStream(nil)
|
||||
defer json.ReturnStream(stream)
|
||||
MarshalJSONOrigAttributeUnit(src, stream)
|
||||
require.NoError(t, stream.Error())
|
||||
|
||||
iter := json.BorrowIterator(stream.Buffer())
|
||||
defer json.ReturnIterator(iter)
|
||||
dest := &otlpprofiles.AttributeUnit{}
|
||||
UnmarshalJSONOrigAttributeUnit(dest, iter)
|
||||
require.NoError(t, iter.Error())
|
||||
|
||||
assert.Equal(t, src, dest)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestMarshalAndUnmarshalProtoOrigAttributeUnit(t *testing.T) {
|
||||
src := &otlpprofiles.AttributeUnit{}
|
||||
FillOrigTestAttributeUnit(src)
|
||||
buf := make([]byte, SizeProtoOrigAttributeUnit(src))
|
||||
gotSize := MarshalProtoOrigAttributeUnit(src, buf)
|
||||
assert.Equal(t, len(buf), gotSize)
|
||||
for name, src := range getEncodingTestValuesAttributeUnit() {
|
||||
t.Run(name, func(t *testing.T) {
|
||||
buf := make([]byte, SizeProtoOrigAttributeUnit(src))
|
||||
gotSize := MarshalProtoOrigAttributeUnit(src, buf)
|
||||
assert.Equal(t, len(buf), gotSize)
|
||||
|
||||
dest := &otlpprofiles.AttributeUnit{}
|
||||
require.NoError(t, UnmarshalProtoOrigAttributeUnit(dest, buf))
|
||||
assert.Equal(t, src, dest)
|
||||
dest := &otlpprofiles.AttributeUnit{}
|
||||
require.NoError(t, UnmarshalProtoOrigAttributeUnit(dest, buf))
|
||||
assert.Equal(t, src, dest)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestMarshalAndUnmarshalProtoOrigEmptyAttributeUnit(t *testing.T) {
|
||||
src := &otlpprofiles.AttributeUnit{}
|
||||
buf := make([]byte, SizeProtoOrigAttributeUnit(src))
|
||||
gotSize := MarshalProtoOrigAttributeUnit(src, buf)
|
||||
assert.Equal(t, len(buf), gotSize)
|
||||
|
||||
dest := &otlpprofiles.AttributeUnit{}
|
||||
require.NoError(t, UnmarshalProtoOrigAttributeUnit(dest, buf))
|
||||
assert.Equal(t, src, dest)
|
||||
func getEncodingTestValuesAttributeUnit() map[string]*otlpprofiles.AttributeUnit {
|
||||
return map[string]*otlpprofiles.AttributeUnit{
|
||||
"empty": {},
|
||||
"fill_test": func() *otlpprofiles.AttributeUnit {
|
||||
src := &otlpprofiles.AttributeUnit{}
|
||||
FillOrigTestAttributeUnit(src)
|
||||
return src
|
||||
}(),
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,46 +26,55 @@ func TestCopyOrigEntityRef(t *testing.T) {
|
|||
assert.Equal(t, src, dest)
|
||||
}
|
||||
|
||||
func TestMarshalAndUnmarshalJSONOrigEntityRef(t *testing.T) {
|
||||
src := &otlpcommon.EntityRef{}
|
||||
FillOrigTestEntityRef(src)
|
||||
stream := json.BorrowStream(nil)
|
||||
defer json.ReturnStream(stream)
|
||||
MarshalJSONOrigEntityRef(src, stream)
|
||||
require.NoError(t, stream.Error())
|
||||
|
||||
// Append an unknown field at the start to ensure unknown fields are skipped
|
||||
// and the unmarshal logic continues.
|
||||
buf := stream.Buffer()
|
||||
assert.EqualValues(t, '{', buf[0])
|
||||
iter := json.BorrowIterator(append([]byte(`{"unknown": "string",`), buf[1:]...))
|
||||
func TestMarshalAndUnmarshalJSONOrigEntityRefUnknown(t *testing.T) {
|
||||
iter := json.BorrowIterator([]byte(`{"unknown": "string"}`))
|
||||
defer json.ReturnIterator(iter)
|
||||
dest := &otlpcommon.EntityRef{}
|
||||
UnmarshalJSONOrigEntityRef(dest, iter)
|
||||
require.NoError(t, iter.Error())
|
||||
assert.Equal(t, &otlpcommon.EntityRef{}, dest)
|
||||
}
|
||||
|
||||
assert.Equal(t, src, dest)
|
||||
func TestMarshalAndUnmarshalJSONOrigEntityRef(t *testing.T) {
|
||||
for name, src := range getEncodingTestValuesEntityRef() {
|
||||
t.Run(name, func(t *testing.T) {
|
||||
stream := json.BorrowStream(nil)
|
||||
defer json.ReturnStream(stream)
|
||||
MarshalJSONOrigEntityRef(src, stream)
|
||||
require.NoError(t, stream.Error())
|
||||
|
||||
iter := json.BorrowIterator(stream.Buffer())
|
||||
defer json.ReturnIterator(iter)
|
||||
dest := &otlpcommon.EntityRef{}
|
||||
UnmarshalJSONOrigEntityRef(dest, iter)
|
||||
require.NoError(t, iter.Error())
|
||||
|
||||
assert.Equal(t, src, dest)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestMarshalAndUnmarshalProtoOrigEntityRef(t *testing.T) {
|
||||
src := &otlpcommon.EntityRef{}
|
||||
FillOrigTestEntityRef(src)
|
||||
buf := make([]byte, SizeProtoOrigEntityRef(src))
|
||||
gotSize := MarshalProtoOrigEntityRef(src, buf)
|
||||
assert.Equal(t, len(buf), gotSize)
|
||||
for name, src := range getEncodingTestValuesEntityRef() {
|
||||
t.Run(name, func(t *testing.T) {
|
||||
buf := make([]byte, SizeProtoOrigEntityRef(src))
|
||||
gotSize := MarshalProtoOrigEntityRef(src, buf)
|
||||
assert.Equal(t, len(buf), gotSize)
|
||||
|
||||
dest := &otlpcommon.EntityRef{}
|
||||
require.NoError(t, UnmarshalProtoOrigEntityRef(dest, buf))
|
||||
assert.Equal(t, src, dest)
|
||||
dest := &otlpcommon.EntityRef{}
|
||||
require.NoError(t, UnmarshalProtoOrigEntityRef(dest, buf))
|
||||
assert.Equal(t, src, dest)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestMarshalAndUnmarshalProtoOrigEmptyEntityRef(t *testing.T) {
|
||||
src := &otlpcommon.EntityRef{}
|
||||
buf := make([]byte, SizeProtoOrigEntityRef(src))
|
||||
gotSize := MarshalProtoOrigEntityRef(src, buf)
|
||||
assert.Equal(t, len(buf), gotSize)
|
||||
|
||||
dest := &otlpcommon.EntityRef{}
|
||||
require.NoError(t, UnmarshalProtoOrigEntityRef(dest, buf))
|
||||
assert.Equal(t, src, dest)
|
||||
func getEncodingTestValuesEntityRef() map[string]*otlpcommon.EntityRef {
|
||||
return map[string]*otlpcommon.EntityRef{
|
||||
"empty": {},
|
||||
"fill_test": func() *otlpcommon.EntityRef {
|
||||
src := &otlpcommon.EntityRef{}
|
||||
FillOrigTestEntityRef(src)
|
||||
return src
|
||||
}(),
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,46 +26,57 @@ func TestCopyOrigExemplar(t *testing.T) {
|
|||
assert.Equal(t, src, dest)
|
||||
}
|
||||
|
||||
func TestMarshalAndUnmarshalJSONOrigExemplar(t *testing.T) {
|
||||
src := &otlpmetrics.Exemplar{}
|
||||
FillOrigTestExemplar(src)
|
||||
stream := json.BorrowStream(nil)
|
||||
defer json.ReturnStream(stream)
|
||||
MarshalJSONOrigExemplar(src, stream)
|
||||
require.NoError(t, stream.Error())
|
||||
|
||||
// Append an unknown field at the start to ensure unknown fields are skipped
|
||||
// and the unmarshal logic continues.
|
||||
buf := stream.Buffer()
|
||||
assert.EqualValues(t, '{', buf[0])
|
||||
iter := json.BorrowIterator(append([]byte(`{"unknown": "string",`), buf[1:]...))
|
||||
func TestMarshalAndUnmarshalJSONOrigExemplarUnknown(t *testing.T) {
|
||||
iter := json.BorrowIterator([]byte(`{"unknown": "string"}`))
|
||||
defer json.ReturnIterator(iter)
|
||||
dest := &otlpmetrics.Exemplar{}
|
||||
UnmarshalJSONOrigExemplar(dest, iter)
|
||||
require.NoError(t, iter.Error())
|
||||
assert.Equal(t, &otlpmetrics.Exemplar{}, dest)
|
||||
}
|
||||
|
||||
assert.Equal(t, src, dest)
|
||||
func TestMarshalAndUnmarshalJSONOrigExemplar(t *testing.T) {
|
||||
for name, src := range getEncodingTestValuesExemplar() {
|
||||
t.Run(name, func(t *testing.T) {
|
||||
stream := json.BorrowStream(nil)
|
||||
defer json.ReturnStream(stream)
|
||||
MarshalJSONOrigExemplar(src, stream)
|
||||
require.NoError(t, stream.Error())
|
||||
|
||||
iter := json.BorrowIterator(stream.Buffer())
|
||||
defer json.ReturnIterator(iter)
|
||||
dest := &otlpmetrics.Exemplar{}
|
||||
UnmarshalJSONOrigExemplar(dest, iter)
|
||||
require.NoError(t, iter.Error())
|
||||
|
||||
assert.Equal(t, src, dest)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestMarshalAndUnmarshalProtoOrigExemplar(t *testing.T) {
|
||||
src := &otlpmetrics.Exemplar{}
|
||||
FillOrigTestExemplar(src)
|
||||
buf := make([]byte, SizeProtoOrigExemplar(src))
|
||||
gotSize := MarshalProtoOrigExemplar(src, buf)
|
||||
assert.Equal(t, len(buf), gotSize)
|
||||
for name, src := range getEncodingTestValuesExemplar() {
|
||||
t.Run(name, func(t *testing.T) {
|
||||
buf := make([]byte, SizeProtoOrigExemplar(src))
|
||||
gotSize := MarshalProtoOrigExemplar(src, buf)
|
||||
assert.Equal(t, len(buf), gotSize)
|
||||
|
||||
dest := &otlpmetrics.Exemplar{}
|
||||
require.NoError(t, UnmarshalProtoOrigExemplar(dest, buf))
|
||||
assert.Equal(t, src, dest)
|
||||
dest := &otlpmetrics.Exemplar{}
|
||||
require.NoError(t, UnmarshalProtoOrigExemplar(dest, buf))
|
||||
assert.Equal(t, src, dest)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestMarshalAndUnmarshalProtoOrigEmptyExemplar(t *testing.T) {
|
||||
src := &otlpmetrics.Exemplar{}
|
||||
buf := make([]byte, SizeProtoOrigExemplar(src))
|
||||
gotSize := MarshalProtoOrigExemplar(src, buf)
|
||||
assert.Equal(t, len(buf), gotSize)
|
||||
|
||||
dest := &otlpmetrics.Exemplar{}
|
||||
require.NoError(t, UnmarshalProtoOrigExemplar(dest, buf))
|
||||
assert.Equal(t, src, dest)
|
||||
func getEncodingTestValuesExemplar() map[string]*otlpmetrics.Exemplar {
|
||||
return map[string]*otlpmetrics.Exemplar{
|
||||
"empty": {},
|
||||
"fill_test": func() *otlpmetrics.Exemplar {
|
||||
src := &otlpmetrics.Exemplar{}
|
||||
FillOrigTestExemplar(src)
|
||||
return src
|
||||
}(),
|
||||
"oneof_double": {Value: &otlpmetrics.Exemplar_AsDouble{AsDouble: float64(0)}},
|
||||
"oneof_int": {Value: &otlpmetrics.Exemplar_AsInt{AsInt: int64(0)}},
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,46 +26,55 @@ func TestCopyOrigExponentialHistogram(t *testing.T) {
|
|||
assert.Equal(t, src, dest)
|
||||
}
|
||||
|
||||
func TestMarshalAndUnmarshalJSONOrigExponentialHistogram(t *testing.T) {
|
||||
src := &otlpmetrics.ExponentialHistogram{}
|
||||
FillOrigTestExponentialHistogram(src)
|
||||
stream := json.BorrowStream(nil)
|
||||
defer json.ReturnStream(stream)
|
||||
MarshalJSONOrigExponentialHistogram(src, stream)
|
||||
require.NoError(t, stream.Error())
|
||||
|
||||
// Append an unknown field at the start to ensure unknown fields are skipped
|
||||
// and the unmarshal logic continues.
|
||||
buf := stream.Buffer()
|
||||
assert.EqualValues(t, '{', buf[0])
|
||||
iter := json.BorrowIterator(append([]byte(`{"unknown": "string",`), buf[1:]...))
|
||||
func TestMarshalAndUnmarshalJSONOrigExponentialHistogramUnknown(t *testing.T) {
|
||||
iter := json.BorrowIterator([]byte(`{"unknown": "string"}`))
|
||||
defer json.ReturnIterator(iter)
|
||||
dest := &otlpmetrics.ExponentialHistogram{}
|
||||
UnmarshalJSONOrigExponentialHistogram(dest, iter)
|
||||
require.NoError(t, iter.Error())
|
||||
assert.Equal(t, &otlpmetrics.ExponentialHistogram{}, dest)
|
||||
}
|
||||
|
||||
assert.Equal(t, src, dest)
|
||||
func TestMarshalAndUnmarshalJSONOrigExponentialHistogram(t *testing.T) {
|
||||
for name, src := range getEncodingTestValuesExponentialHistogram() {
|
||||
t.Run(name, func(t *testing.T) {
|
||||
stream := json.BorrowStream(nil)
|
||||
defer json.ReturnStream(stream)
|
||||
MarshalJSONOrigExponentialHistogram(src, stream)
|
||||
require.NoError(t, stream.Error())
|
||||
|
||||
iter := json.BorrowIterator(stream.Buffer())
|
||||
defer json.ReturnIterator(iter)
|
||||
dest := &otlpmetrics.ExponentialHistogram{}
|
||||
UnmarshalJSONOrigExponentialHistogram(dest, iter)
|
||||
require.NoError(t, iter.Error())
|
||||
|
||||
assert.Equal(t, src, dest)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestMarshalAndUnmarshalProtoOrigExponentialHistogram(t *testing.T) {
|
||||
src := &otlpmetrics.ExponentialHistogram{}
|
||||
FillOrigTestExponentialHistogram(src)
|
||||
buf := make([]byte, SizeProtoOrigExponentialHistogram(src))
|
||||
gotSize := MarshalProtoOrigExponentialHistogram(src, buf)
|
||||
assert.Equal(t, len(buf), gotSize)
|
||||
for name, src := range getEncodingTestValuesExponentialHistogram() {
|
||||
t.Run(name, func(t *testing.T) {
|
||||
buf := make([]byte, SizeProtoOrigExponentialHistogram(src))
|
||||
gotSize := MarshalProtoOrigExponentialHistogram(src, buf)
|
||||
assert.Equal(t, len(buf), gotSize)
|
||||
|
||||
dest := &otlpmetrics.ExponentialHistogram{}
|
||||
require.NoError(t, UnmarshalProtoOrigExponentialHistogram(dest, buf))
|
||||
assert.Equal(t, src, dest)
|
||||
dest := &otlpmetrics.ExponentialHistogram{}
|
||||
require.NoError(t, UnmarshalProtoOrigExponentialHistogram(dest, buf))
|
||||
assert.Equal(t, src, dest)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestMarshalAndUnmarshalProtoOrigEmptyExponentialHistogram(t *testing.T) {
|
||||
src := &otlpmetrics.ExponentialHistogram{}
|
||||
buf := make([]byte, SizeProtoOrigExponentialHistogram(src))
|
||||
gotSize := MarshalProtoOrigExponentialHistogram(src, buf)
|
||||
assert.Equal(t, len(buf), gotSize)
|
||||
|
||||
dest := &otlpmetrics.ExponentialHistogram{}
|
||||
require.NoError(t, UnmarshalProtoOrigExponentialHistogram(dest, buf))
|
||||
assert.Equal(t, src, dest)
|
||||
func getEncodingTestValuesExponentialHistogram() map[string]*otlpmetrics.ExponentialHistogram {
|
||||
return map[string]*otlpmetrics.ExponentialHistogram{
|
||||
"empty": {},
|
||||
"fill_test": func() *otlpmetrics.ExponentialHistogram {
|
||||
src := &otlpmetrics.ExponentialHistogram{}
|
||||
FillOrigTestExponentialHistogram(src)
|
||||
return src
|
||||
}(),
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,46 +26,55 @@ func TestCopyOrigExponentialHistogramDataPoint_Buckets(t *testing.T) {
|
|||
assert.Equal(t, src, dest)
|
||||
}
|
||||
|
||||
func TestMarshalAndUnmarshalJSONOrigExponentialHistogramDataPoint_Buckets(t *testing.T) {
|
||||
src := &otlpmetrics.ExponentialHistogramDataPoint_Buckets{}
|
||||
FillOrigTestExponentialHistogramDataPoint_Buckets(src)
|
||||
stream := json.BorrowStream(nil)
|
||||
defer json.ReturnStream(stream)
|
||||
MarshalJSONOrigExponentialHistogramDataPoint_Buckets(src, stream)
|
||||
require.NoError(t, stream.Error())
|
||||
|
||||
// Append an unknown field at the start to ensure unknown fields are skipped
|
||||
// and the unmarshal logic continues.
|
||||
buf := stream.Buffer()
|
||||
assert.EqualValues(t, '{', buf[0])
|
||||
iter := json.BorrowIterator(append([]byte(`{"unknown": "string",`), buf[1:]...))
|
||||
func TestMarshalAndUnmarshalJSONOrigExponentialHistogramDataPoint_BucketsUnknown(t *testing.T) {
|
||||
iter := json.BorrowIterator([]byte(`{"unknown": "string"}`))
|
||||
defer json.ReturnIterator(iter)
|
||||
dest := &otlpmetrics.ExponentialHistogramDataPoint_Buckets{}
|
||||
UnmarshalJSONOrigExponentialHistogramDataPoint_Buckets(dest, iter)
|
||||
require.NoError(t, iter.Error())
|
||||
assert.Equal(t, &otlpmetrics.ExponentialHistogramDataPoint_Buckets{}, dest)
|
||||
}
|
||||
|
||||
assert.Equal(t, src, dest)
|
||||
func TestMarshalAndUnmarshalJSONOrigExponentialHistogramDataPoint_Buckets(t *testing.T) {
|
||||
for name, src := range getEncodingTestValuesExponentialHistogramDataPoint_Buckets() {
|
||||
t.Run(name, func(t *testing.T) {
|
||||
stream := json.BorrowStream(nil)
|
||||
defer json.ReturnStream(stream)
|
||||
MarshalJSONOrigExponentialHistogramDataPoint_Buckets(src, stream)
|
||||
require.NoError(t, stream.Error())
|
||||
|
||||
iter := json.BorrowIterator(stream.Buffer())
|
||||
defer json.ReturnIterator(iter)
|
||||
dest := &otlpmetrics.ExponentialHistogramDataPoint_Buckets{}
|
||||
UnmarshalJSONOrigExponentialHistogramDataPoint_Buckets(dest, iter)
|
||||
require.NoError(t, iter.Error())
|
||||
|
||||
assert.Equal(t, src, dest)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestMarshalAndUnmarshalProtoOrigExponentialHistogramDataPoint_Buckets(t *testing.T) {
|
||||
src := &otlpmetrics.ExponentialHistogramDataPoint_Buckets{}
|
||||
FillOrigTestExponentialHistogramDataPoint_Buckets(src)
|
||||
buf := make([]byte, SizeProtoOrigExponentialHistogramDataPoint_Buckets(src))
|
||||
gotSize := MarshalProtoOrigExponentialHistogramDataPoint_Buckets(src, buf)
|
||||
assert.Equal(t, len(buf), gotSize)
|
||||
for name, src := range getEncodingTestValuesExponentialHistogramDataPoint_Buckets() {
|
||||
t.Run(name, func(t *testing.T) {
|
||||
buf := make([]byte, SizeProtoOrigExponentialHistogramDataPoint_Buckets(src))
|
||||
gotSize := MarshalProtoOrigExponentialHistogramDataPoint_Buckets(src, buf)
|
||||
assert.Equal(t, len(buf), gotSize)
|
||||
|
||||
dest := &otlpmetrics.ExponentialHistogramDataPoint_Buckets{}
|
||||
require.NoError(t, UnmarshalProtoOrigExponentialHistogramDataPoint_Buckets(dest, buf))
|
||||
assert.Equal(t, src, dest)
|
||||
dest := &otlpmetrics.ExponentialHistogramDataPoint_Buckets{}
|
||||
require.NoError(t, UnmarshalProtoOrigExponentialHistogramDataPoint_Buckets(dest, buf))
|
||||
assert.Equal(t, src, dest)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestMarshalAndUnmarshalProtoOrigEmptyExponentialHistogramDataPoint_Buckets(t *testing.T) {
|
||||
src := &otlpmetrics.ExponentialHistogramDataPoint_Buckets{}
|
||||
buf := make([]byte, SizeProtoOrigExponentialHistogramDataPoint_Buckets(src))
|
||||
gotSize := MarshalProtoOrigExponentialHistogramDataPoint_Buckets(src, buf)
|
||||
assert.Equal(t, len(buf), gotSize)
|
||||
|
||||
dest := &otlpmetrics.ExponentialHistogramDataPoint_Buckets{}
|
||||
require.NoError(t, UnmarshalProtoOrigExponentialHistogramDataPoint_Buckets(dest, buf))
|
||||
assert.Equal(t, src, dest)
|
||||
func getEncodingTestValuesExponentialHistogramDataPoint_Buckets() map[string]*otlpmetrics.ExponentialHistogramDataPoint_Buckets {
|
||||
return map[string]*otlpmetrics.ExponentialHistogramDataPoint_Buckets{
|
||||
"empty": {},
|
||||
"fill_test": func() *otlpmetrics.ExponentialHistogramDataPoint_Buckets {
|
||||
src := &otlpmetrics.ExponentialHistogramDataPoint_Buckets{}
|
||||
FillOrigTestExponentialHistogramDataPoint_Buckets(src)
|
||||
return src
|
||||
}(),
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,46 +26,58 @@ func TestCopyOrigExponentialHistogramDataPoint(t *testing.T) {
|
|||
assert.Equal(t, src, dest)
|
||||
}
|
||||
|
||||
func TestMarshalAndUnmarshalJSONOrigExponentialHistogramDataPoint(t *testing.T) {
|
||||
src := &otlpmetrics.ExponentialHistogramDataPoint{}
|
||||
FillOrigTestExponentialHistogramDataPoint(src)
|
||||
stream := json.BorrowStream(nil)
|
||||
defer json.ReturnStream(stream)
|
||||
MarshalJSONOrigExponentialHistogramDataPoint(src, stream)
|
||||
require.NoError(t, stream.Error())
|
||||
|
||||
// Append an unknown field at the start to ensure unknown fields are skipped
|
||||
// and the unmarshal logic continues.
|
||||
buf := stream.Buffer()
|
||||
assert.EqualValues(t, '{', buf[0])
|
||||
iter := json.BorrowIterator(append([]byte(`{"unknown": "string",`), buf[1:]...))
|
||||
func TestMarshalAndUnmarshalJSONOrigExponentialHistogramDataPointUnknown(t *testing.T) {
|
||||
iter := json.BorrowIterator([]byte(`{"unknown": "string"}`))
|
||||
defer json.ReturnIterator(iter)
|
||||
dest := &otlpmetrics.ExponentialHistogramDataPoint{}
|
||||
UnmarshalJSONOrigExponentialHistogramDataPoint(dest, iter)
|
||||
require.NoError(t, iter.Error())
|
||||
assert.Equal(t, &otlpmetrics.ExponentialHistogramDataPoint{}, dest)
|
||||
}
|
||||
|
||||
assert.Equal(t, src, dest)
|
||||
func TestMarshalAndUnmarshalJSONOrigExponentialHistogramDataPoint(t *testing.T) {
|
||||
for name, src := range getEncodingTestValuesExponentialHistogramDataPoint() {
|
||||
t.Run(name, func(t *testing.T) {
|
||||
stream := json.BorrowStream(nil)
|
||||
defer json.ReturnStream(stream)
|
||||
MarshalJSONOrigExponentialHistogramDataPoint(src, stream)
|
||||
require.NoError(t, stream.Error())
|
||||
|
||||
iter := json.BorrowIterator(stream.Buffer())
|
||||
defer json.ReturnIterator(iter)
|
||||
dest := &otlpmetrics.ExponentialHistogramDataPoint{}
|
||||
UnmarshalJSONOrigExponentialHistogramDataPoint(dest, iter)
|
||||
require.NoError(t, iter.Error())
|
||||
|
||||
assert.Equal(t, src, dest)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestMarshalAndUnmarshalProtoOrigExponentialHistogramDataPoint(t *testing.T) {
|
||||
src := &otlpmetrics.ExponentialHistogramDataPoint{}
|
||||
FillOrigTestExponentialHistogramDataPoint(src)
|
||||
buf := make([]byte, SizeProtoOrigExponentialHistogramDataPoint(src))
|
||||
gotSize := MarshalProtoOrigExponentialHistogramDataPoint(src, buf)
|
||||
assert.Equal(t, len(buf), gotSize)
|
||||
for name, src := range getEncodingTestValuesExponentialHistogramDataPoint() {
|
||||
t.Run(name, func(t *testing.T) {
|
||||
buf := make([]byte, SizeProtoOrigExponentialHistogramDataPoint(src))
|
||||
gotSize := MarshalProtoOrigExponentialHistogramDataPoint(src, buf)
|
||||
assert.Equal(t, len(buf), gotSize)
|
||||
|
||||
dest := &otlpmetrics.ExponentialHistogramDataPoint{}
|
||||
require.NoError(t, UnmarshalProtoOrigExponentialHistogramDataPoint(dest, buf))
|
||||
assert.Equal(t, src, dest)
|
||||
dest := &otlpmetrics.ExponentialHistogramDataPoint{}
|
||||
require.NoError(t, UnmarshalProtoOrigExponentialHistogramDataPoint(dest, buf))
|
||||
assert.Equal(t, src, dest)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestMarshalAndUnmarshalProtoOrigEmptyExponentialHistogramDataPoint(t *testing.T) {
|
||||
src := &otlpmetrics.ExponentialHistogramDataPoint{}
|
||||
buf := make([]byte, SizeProtoOrigExponentialHistogramDataPoint(src))
|
||||
gotSize := MarshalProtoOrigExponentialHistogramDataPoint(src, buf)
|
||||
assert.Equal(t, len(buf), gotSize)
|
||||
|
||||
dest := &otlpmetrics.ExponentialHistogramDataPoint{}
|
||||
require.NoError(t, UnmarshalProtoOrigExponentialHistogramDataPoint(dest, buf))
|
||||
assert.Equal(t, src, dest)
|
||||
func getEncodingTestValuesExponentialHistogramDataPoint() map[string]*otlpmetrics.ExponentialHistogramDataPoint {
|
||||
return map[string]*otlpmetrics.ExponentialHistogramDataPoint{
|
||||
"empty": {},
|
||||
"fill_test": func() *otlpmetrics.ExponentialHistogramDataPoint {
|
||||
src := &otlpmetrics.ExponentialHistogramDataPoint{}
|
||||
FillOrigTestExponentialHistogramDataPoint(src)
|
||||
return src
|
||||
}(),
|
||||
"default_sum": {Sum_: &otlpmetrics.ExponentialHistogramDataPoint_Sum{Sum: float64(0)}},
|
||||
"default_min": {Min_: &otlpmetrics.ExponentialHistogramDataPoint_Min{Min: float64(0)}},
|
||||
"default_max": {Max_: &otlpmetrics.ExponentialHistogramDataPoint_Max{Max: float64(0)}},
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,46 +26,55 @@ func TestCopyOrigExportLogsPartialSuccess(t *testing.T) {
|
|||
assert.Equal(t, src, dest)
|
||||
}
|
||||
|
||||
func TestMarshalAndUnmarshalJSONOrigExportLogsPartialSuccess(t *testing.T) {
|
||||
src := &otlpcollectorlog.ExportLogsPartialSuccess{}
|
||||
FillOrigTestExportLogsPartialSuccess(src)
|
||||
stream := json.BorrowStream(nil)
|
||||
defer json.ReturnStream(stream)
|
||||
MarshalJSONOrigExportLogsPartialSuccess(src, stream)
|
||||
require.NoError(t, stream.Error())
|
||||
|
||||
// Append an unknown field at the start to ensure unknown fields are skipped
|
||||
// and the unmarshal logic continues.
|
||||
buf := stream.Buffer()
|
||||
assert.EqualValues(t, '{', buf[0])
|
||||
iter := json.BorrowIterator(append([]byte(`{"unknown": "string",`), buf[1:]...))
|
||||
func TestMarshalAndUnmarshalJSONOrigExportLogsPartialSuccessUnknown(t *testing.T) {
|
||||
iter := json.BorrowIterator([]byte(`{"unknown": "string"}`))
|
||||
defer json.ReturnIterator(iter)
|
||||
dest := &otlpcollectorlog.ExportLogsPartialSuccess{}
|
||||
UnmarshalJSONOrigExportLogsPartialSuccess(dest, iter)
|
||||
require.NoError(t, iter.Error())
|
||||
assert.Equal(t, &otlpcollectorlog.ExportLogsPartialSuccess{}, dest)
|
||||
}
|
||||
|
||||
assert.Equal(t, src, dest)
|
||||
func TestMarshalAndUnmarshalJSONOrigExportLogsPartialSuccess(t *testing.T) {
|
||||
for name, src := range getEncodingTestValuesExportLogsPartialSuccess() {
|
||||
t.Run(name, func(t *testing.T) {
|
||||
stream := json.BorrowStream(nil)
|
||||
defer json.ReturnStream(stream)
|
||||
MarshalJSONOrigExportLogsPartialSuccess(src, stream)
|
||||
require.NoError(t, stream.Error())
|
||||
|
||||
iter := json.BorrowIterator(stream.Buffer())
|
||||
defer json.ReturnIterator(iter)
|
||||
dest := &otlpcollectorlog.ExportLogsPartialSuccess{}
|
||||
UnmarshalJSONOrigExportLogsPartialSuccess(dest, iter)
|
||||
require.NoError(t, iter.Error())
|
||||
|
||||
assert.Equal(t, src, dest)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestMarshalAndUnmarshalProtoOrigExportLogsPartialSuccess(t *testing.T) {
|
||||
src := &otlpcollectorlog.ExportLogsPartialSuccess{}
|
||||
FillOrigTestExportLogsPartialSuccess(src)
|
||||
buf := make([]byte, SizeProtoOrigExportLogsPartialSuccess(src))
|
||||
gotSize := MarshalProtoOrigExportLogsPartialSuccess(src, buf)
|
||||
assert.Equal(t, len(buf), gotSize)
|
||||
for name, src := range getEncodingTestValuesExportLogsPartialSuccess() {
|
||||
t.Run(name, func(t *testing.T) {
|
||||
buf := make([]byte, SizeProtoOrigExportLogsPartialSuccess(src))
|
||||
gotSize := MarshalProtoOrigExportLogsPartialSuccess(src, buf)
|
||||
assert.Equal(t, len(buf), gotSize)
|
||||
|
||||
dest := &otlpcollectorlog.ExportLogsPartialSuccess{}
|
||||
require.NoError(t, UnmarshalProtoOrigExportLogsPartialSuccess(dest, buf))
|
||||
assert.Equal(t, src, dest)
|
||||
dest := &otlpcollectorlog.ExportLogsPartialSuccess{}
|
||||
require.NoError(t, UnmarshalProtoOrigExportLogsPartialSuccess(dest, buf))
|
||||
assert.Equal(t, src, dest)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestMarshalAndUnmarshalProtoOrigEmptyExportLogsPartialSuccess(t *testing.T) {
|
||||
src := &otlpcollectorlog.ExportLogsPartialSuccess{}
|
||||
buf := make([]byte, SizeProtoOrigExportLogsPartialSuccess(src))
|
||||
gotSize := MarshalProtoOrigExportLogsPartialSuccess(src, buf)
|
||||
assert.Equal(t, len(buf), gotSize)
|
||||
|
||||
dest := &otlpcollectorlog.ExportLogsPartialSuccess{}
|
||||
require.NoError(t, UnmarshalProtoOrigExportLogsPartialSuccess(dest, buf))
|
||||
assert.Equal(t, src, dest)
|
||||
func getEncodingTestValuesExportLogsPartialSuccess() map[string]*otlpcollectorlog.ExportLogsPartialSuccess {
|
||||
return map[string]*otlpcollectorlog.ExportLogsPartialSuccess{
|
||||
"empty": {},
|
||||
"fill_test": func() *otlpcollectorlog.ExportLogsPartialSuccess {
|
||||
src := &otlpcollectorlog.ExportLogsPartialSuccess{}
|
||||
FillOrigTestExportLogsPartialSuccess(src)
|
||||
return src
|
||||
}(),
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,46 +26,55 @@ func TestCopyOrigExportLogsServiceRequest(t *testing.T) {
|
|||
assert.Equal(t, src, dest)
|
||||
}
|
||||
|
||||
func TestMarshalAndUnmarshalJSONOrigExportLogsServiceRequest(t *testing.T) {
|
||||
src := &otlpcollectorlog.ExportLogsServiceRequest{}
|
||||
FillOrigTestExportLogsServiceRequest(src)
|
||||
stream := json.BorrowStream(nil)
|
||||
defer json.ReturnStream(stream)
|
||||
MarshalJSONOrigExportLogsServiceRequest(src, stream)
|
||||
require.NoError(t, stream.Error())
|
||||
|
||||
// Append an unknown field at the start to ensure unknown fields are skipped
|
||||
// and the unmarshal logic continues.
|
||||
buf := stream.Buffer()
|
||||
assert.EqualValues(t, '{', buf[0])
|
||||
iter := json.BorrowIterator(append([]byte(`{"unknown": "string",`), buf[1:]...))
|
||||
func TestMarshalAndUnmarshalJSONOrigExportLogsServiceRequestUnknown(t *testing.T) {
|
||||
iter := json.BorrowIterator([]byte(`{"unknown": "string"}`))
|
||||
defer json.ReturnIterator(iter)
|
||||
dest := &otlpcollectorlog.ExportLogsServiceRequest{}
|
||||
UnmarshalJSONOrigExportLogsServiceRequest(dest, iter)
|
||||
require.NoError(t, iter.Error())
|
||||
assert.Equal(t, &otlpcollectorlog.ExportLogsServiceRequest{}, dest)
|
||||
}
|
||||
|
||||
assert.Equal(t, src, dest)
|
||||
func TestMarshalAndUnmarshalJSONOrigExportLogsServiceRequest(t *testing.T) {
|
||||
for name, src := range getEncodingTestValuesExportLogsServiceRequest() {
|
||||
t.Run(name, func(t *testing.T) {
|
||||
stream := json.BorrowStream(nil)
|
||||
defer json.ReturnStream(stream)
|
||||
MarshalJSONOrigExportLogsServiceRequest(src, stream)
|
||||
require.NoError(t, stream.Error())
|
||||
|
||||
iter := json.BorrowIterator(stream.Buffer())
|
||||
defer json.ReturnIterator(iter)
|
||||
dest := &otlpcollectorlog.ExportLogsServiceRequest{}
|
||||
UnmarshalJSONOrigExportLogsServiceRequest(dest, iter)
|
||||
require.NoError(t, iter.Error())
|
||||
|
||||
assert.Equal(t, src, dest)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestMarshalAndUnmarshalProtoOrigExportLogsServiceRequest(t *testing.T) {
|
||||
src := &otlpcollectorlog.ExportLogsServiceRequest{}
|
||||
FillOrigTestExportLogsServiceRequest(src)
|
||||
buf := make([]byte, SizeProtoOrigExportLogsServiceRequest(src))
|
||||
gotSize := MarshalProtoOrigExportLogsServiceRequest(src, buf)
|
||||
assert.Equal(t, len(buf), gotSize)
|
||||
for name, src := range getEncodingTestValuesExportLogsServiceRequest() {
|
||||
t.Run(name, func(t *testing.T) {
|
||||
buf := make([]byte, SizeProtoOrigExportLogsServiceRequest(src))
|
||||
gotSize := MarshalProtoOrigExportLogsServiceRequest(src, buf)
|
||||
assert.Equal(t, len(buf), gotSize)
|
||||
|
||||
dest := &otlpcollectorlog.ExportLogsServiceRequest{}
|
||||
require.NoError(t, UnmarshalProtoOrigExportLogsServiceRequest(dest, buf))
|
||||
assert.Equal(t, src, dest)
|
||||
dest := &otlpcollectorlog.ExportLogsServiceRequest{}
|
||||
require.NoError(t, UnmarshalProtoOrigExportLogsServiceRequest(dest, buf))
|
||||
assert.Equal(t, src, dest)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestMarshalAndUnmarshalProtoOrigEmptyExportLogsServiceRequest(t *testing.T) {
|
||||
src := &otlpcollectorlog.ExportLogsServiceRequest{}
|
||||
buf := make([]byte, SizeProtoOrigExportLogsServiceRequest(src))
|
||||
gotSize := MarshalProtoOrigExportLogsServiceRequest(src, buf)
|
||||
assert.Equal(t, len(buf), gotSize)
|
||||
|
||||
dest := &otlpcollectorlog.ExportLogsServiceRequest{}
|
||||
require.NoError(t, UnmarshalProtoOrigExportLogsServiceRequest(dest, buf))
|
||||
assert.Equal(t, src, dest)
|
||||
func getEncodingTestValuesExportLogsServiceRequest() map[string]*otlpcollectorlog.ExportLogsServiceRequest {
|
||||
return map[string]*otlpcollectorlog.ExportLogsServiceRequest{
|
||||
"empty": {},
|
||||
"fill_test": func() *otlpcollectorlog.ExportLogsServiceRequest {
|
||||
src := &otlpcollectorlog.ExportLogsServiceRequest{}
|
||||
FillOrigTestExportLogsServiceRequest(src)
|
||||
return src
|
||||
}(),
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,46 +26,55 @@ func TestCopyOrigExportLogsServiceResponse(t *testing.T) {
|
|||
assert.Equal(t, src, dest)
|
||||
}
|
||||
|
||||
func TestMarshalAndUnmarshalJSONOrigExportLogsServiceResponse(t *testing.T) {
|
||||
src := &otlpcollectorlog.ExportLogsServiceResponse{}
|
||||
FillOrigTestExportLogsServiceResponse(src)
|
||||
stream := json.BorrowStream(nil)
|
||||
defer json.ReturnStream(stream)
|
||||
MarshalJSONOrigExportLogsServiceResponse(src, stream)
|
||||
require.NoError(t, stream.Error())
|
||||
|
||||
// Append an unknown field at the start to ensure unknown fields are skipped
|
||||
// and the unmarshal logic continues.
|
||||
buf := stream.Buffer()
|
||||
assert.EqualValues(t, '{', buf[0])
|
||||
iter := json.BorrowIterator(append([]byte(`{"unknown": "string",`), buf[1:]...))
|
||||
func TestMarshalAndUnmarshalJSONOrigExportLogsServiceResponseUnknown(t *testing.T) {
|
||||
iter := json.BorrowIterator([]byte(`{"unknown": "string"}`))
|
||||
defer json.ReturnIterator(iter)
|
||||
dest := &otlpcollectorlog.ExportLogsServiceResponse{}
|
||||
UnmarshalJSONOrigExportLogsServiceResponse(dest, iter)
|
||||
require.NoError(t, iter.Error())
|
||||
assert.Equal(t, &otlpcollectorlog.ExportLogsServiceResponse{}, dest)
|
||||
}
|
||||
|
||||
assert.Equal(t, src, dest)
|
||||
func TestMarshalAndUnmarshalJSONOrigExportLogsServiceResponse(t *testing.T) {
|
||||
for name, src := range getEncodingTestValuesExportLogsServiceResponse() {
|
||||
t.Run(name, func(t *testing.T) {
|
||||
stream := json.BorrowStream(nil)
|
||||
defer json.ReturnStream(stream)
|
||||
MarshalJSONOrigExportLogsServiceResponse(src, stream)
|
||||
require.NoError(t, stream.Error())
|
||||
|
||||
iter := json.BorrowIterator(stream.Buffer())
|
||||
defer json.ReturnIterator(iter)
|
||||
dest := &otlpcollectorlog.ExportLogsServiceResponse{}
|
||||
UnmarshalJSONOrigExportLogsServiceResponse(dest, iter)
|
||||
require.NoError(t, iter.Error())
|
||||
|
||||
assert.Equal(t, src, dest)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestMarshalAndUnmarshalProtoOrigExportLogsServiceResponse(t *testing.T) {
|
||||
src := &otlpcollectorlog.ExportLogsServiceResponse{}
|
||||
FillOrigTestExportLogsServiceResponse(src)
|
||||
buf := make([]byte, SizeProtoOrigExportLogsServiceResponse(src))
|
||||
gotSize := MarshalProtoOrigExportLogsServiceResponse(src, buf)
|
||||
assert.Equal(t, len(buf), gotSize)
|
||||
for name, src := range getEncodingTestValuesExportLogsServiceResponse() {
|
||||
t.Run(name, func(t *testing.T) {
|
||||
buf := make([]byte, SizeProtoOrigExportLogsServiceResponse(src))
|
||||
gotSize := MarshalProtoOrigExportLogsServiceResponse(src, buf)
|
||||
assert.Equal(t, len(buf), gotSize)
|
||||
|
||||
dest := &otlpcollectorlog.ExportLogsServiceResponse{}
|
||||
require.NoError(t, UnmarshalProtoOrigExportLogsServiceResponse(dest, buf))
|
||||
assert.Equal(t, src, dest)
|
||||
dest := &otlpcollectorlog.ExportLogsServiceResponse{}
|
||||
require.NoError(t, UnmarshalProtoOrigExportLogsServiceResponse(dest, buf))
|
||||
assert.Equal(t, src, dest)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestMarshalAndUnmarshalProtoOrigEmptyExportLogsServiceResponse(t *testing.T) {
|
||||
src := &otlpcollectorlog.ExportLogsServiceResponse{}
|
||||
buf := make([]byte, SizeProtoOrigExportLogsServiceResponse(src))
|
||||
gotSize := MarshalProtoOrigExportLogsServiceResponse(src, buf)
|
||||
assert.Equal(t, len(buf), gotSize)
|
||||
|
||||
dest := &otlpcollectorlog.ExportLogsServiceResponse{}
|
||||
require.NoError(t, UnmarshalProtoOrigExportLogsServiceResponse(dest, buf))
|
||||
assert.Equal(t, src, dest)
|
||||
func getEncodingTestValuesExportLogsServiceResponse() map[string]*otlpcollectorlog.ExportLogsServiceResponse {
|
||||
return map[string]*otlpcollectorlog.ExportLogsServiceResponse{
|
||||
"empty": {},
|
||||
"fill_test": func() *otlpcollectorlog.ExportLogsServiceResponse {
|
||||
src := &otlpcollectorlog.ExportLogsServiceResponse{}
|
||||
FillOrigTestExportLogsServiceResponse(src)
|
||||
return src
|
||||
}(),
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,46 +26,55 @@ func TestCopyOrigExportMetricsPartialSuccess(t *testing.T) {
|
|||
assert.Equal(t, src, dest)
|
||||
}
|
||||
|
||||
func TestMarshalAndUnmarshalJSONOrigExportMetricsPartialSuccess(t *testing.T) {
|
||||
src := &otlpcollectormetrics.ExportMetricsPartialSuccess{}
|
||||
FillOrigTestExportMetricsPartialSuccess(src)
|
||||
stream := json.BorrowStream(nil)
|
||||
defer json.ReturnStream(stream)
|
||||
MarshalJSONOrigExportMetricsPartialSuccess(src, stream)
|
||||
require.NoError(t, stream.Error())
|
||||
|
||||
// Append an unknown field at the start to ensure unknown fields are skipped
|
||||
// and the unmarshal logic continues.
|
||||
buf := stream.Buffer()
|
||||
assert.EqualValues(t, '{', buf[0])
|
||||
iter := json.BorrowIterator(append([]byte(`{"unknown": "string",`), buf[1:]...))
|
||||
func TestMarshalAndUnmarshalJSONOrigExportMetricsPartialSuccessUnknown(t *testing.T) {
|
||||
iter := json.BorrowIterator([]byte(`{"unknown": "string"}`))
|
||||
defer json.ReturnIterator(iter)
|
||||
dest := &otlpcollectormetrics.ExportMetricsPartialSuccess{}
|
||||
UnmarshalJSONOrigExportMetricsPartialSuccess(dest, iter)
|
||||
require.NoError(t, iter.Error())
|
||||
assert.Equal(t, &otlpcollectormetrics.ExportMetricsPartialSuccess{}, dest)
|
||||
}
|
||||
|
||||
assert.Equal(t, src, dest)
|
||||
func TestMarshalAndUnmarshalJSONOrigExportMetricsPartialSuccess(t *testing.T) {
|
||||
for name, src := range getEncodingTestValuesExportMetricsPartialSuccess() {
|
||||
t.Run(name, func(t *testing.T) {
|
||||
stream := json.BorrowStream(nil)
|
||||
defer json.ReturnStream(stream)
|
||||
MarshalJSONOrigExportMetricsPartialSuccess(src, stream)
|
||||
require.NoError(t, stream.Error())
|
||||
|
||||
iter := json.BorrowIterator(stream.Buffer())
|
||||
defer json.ReturnIterator(iter)
|
||||
dest := &otlpcollectormetrics.ExportMetricsPartialSuccess{}
|
||||
UnmarshalJSONOrigExportMetricsPartialSuccess(dest, iter)
|
||||
require.NoError(t, iter.Error())
|
||||
|
||||
assert.Equal(t, src, dest)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestMarshalAndUnmarshalProtoOrigExportMetricsPartialSuccess(t *testing.T) {
|
||||
src := &otlpcollectormetrics.ExportMetricsPartialSuccess{}
|
||||
FillOrigTestExportMetricsPartialSuccess(src)
|
||||
buf := make([]byte, SizeProtoOrigExportMetricsPartialSuccess(src))
|
||||
gotSize := MarshalProtoOrigExportMetricsPartialSuccess(src, buf)
|
||||
assert.Equal(t, len(buf), gotSize)
|
||||
for name, src := range getEncodingTestValuesExportMetricsPartialSuccess() {
|
||||
t.Run(name, func(t *testing.T) {
|
||||
buf := make([]byte, SizeProtoOrigExportMetricsPartialSuccess(src))
|
||||
gotSize := MarshalProtoOrigExportMetricsPartialSuccess(src, buf)
|
||||
assert.Equal(t, len(buf), gotSize)
|
||||
|
||||
dest := &otlpcollectormetrics.ExportMetricsPartialSuccess{}
|
||||
require.NoError(t, UnmarshalProtoOrigExportMetricsPartialSuccess(dest, buf))
|
||||
assert.Equal(t, src, dest)
|
||||
dest := &otlpcollectormetrics.ExportMetricsPartialSuccess{}
|
||||
require.NoError(t, UnmarshalProtoOrigExportMetricsPartialSuccess(dest, buf))
|
||||
assert.Equal(t, src, dest)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestMarshalAndUnmarshalProtoOrigEmptyExportMetricsPartialSuccess(t *testing.T) {
|
||||
src := &otlpcollectormetrics.ExportMetricsPartialSuccess{}
|
||||
buf := make([]byte, SizeProtoOrigExportMetricsPartialSuccess(src))
|
||||
gotSize := MarshalProtoOrigExportMetricsPartialSuccess(src, buf)
|
||||
assert.Equal(t, len(buf), gotSize)
|
||||
|
||||
dest := &otlpcollectormetrics.ExportMetricsPartialSuccess{}
|
||||
require.NoError(t, UnmarshalProtoOrigExportMetricsPartialSuccess(dest, buf))
|
||||
assert.Equal(t, src, dest)
|
||||
func getEncodingTestValuesExportMetricsPartialSuccess() map[string]*otlpcollectormetrics.ExportMetricsPartialSuccess {
|
||||
return map[string]*otlpcollectormetrics.ExportMetricsPartialSuccess{
|
||||
"empty": {},
|
||||
"fill_test": func() *otlpcollectormetrics.ExportMetricsPartialSuccess {
|
||||
src := &otlpcollectormetrics.ExportMetricsPartialSuccess{}
|
||||
FillOrigTestExportMetricsPartialSuccess(src)
|
||||
return src
|
||||
}(),
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,46 +26,55 @@ func TestCopyOrigExportMetricsServiceRequest(t *testing.T) {
|
|||
assert.Equal(t, src, dest)
|
||||
}
|
||||
|
||||
func TestMarshalAndUnmarshalJSONOrigExportMetricsServiceRequest(t *testing.T) {
|
||||
src := &otlpcollectormetrics.ExportMetricsServiceRequest{}
|
||||
FillOrigTestExportMetricsServiceRequest(src)
|
||||
stream := json.BorrowStream(nil)
|
||||
defer json.ReturnStream(stream)
|
||||
MarshalJSONOrigExportMetricsServiceRequest(src, stream)
|
||||
require.NoError(t, stream.Error())
|
||||
|
||||
// Append an unknown field at the start to ensure unknown fields are skipped
|
||||
// and the unmarshal logic continues.
|
||||
buf := stream.Buffer()
|
||||
assert.EqualValues(t, '{', buf[0])
|
||||
iter := json.BorrowIterator(append([]byte(`{"unknown": "string",`), buf[1:]...))
|
||||
func TestMarshalAndUnmarshalJSONOrigExportMetricsServiceRequestUnknown(t *testing.T) {
|
||||
iter := json.BorrowIterator([]byte(`{"unknown": "string"}`))
|
||||
defer json.ReturnIterator(iter)
|
||||
dest := &otlpcollectormetrics.ExportMetricsServiceRequest{}
|
||||
UnmarshalJSONOrigExportMetricsServiceRequest(dest, iter)
|
||||
require.NoError(t, iter.Error())
|
||||
assert.Equal(t, &otlpcollectormetrics.ExportMetricsServiceRequest{}, dest)
|
||||
}
|
||||
|
||||
assert.Equal(t, src, dest)
|
||||
func TestMarshalAndUnmarshalJSONOrigExportMetricsServiceRequest(t *testing.T) {
|
||||
for name, src := range getEncodingTestValuesExportMetricsServiceRequest() {
|
||||
t.Run(name, func(t *testing.T) {
|
||||
stream := json.BorrowStream(nil)
|
||||
defer json.ReturnStream(stream)
|
||||
MarshalJSONOrigExportMetricsServiceRequest(src, stream)
|
||||
require.NoError(t, stream.Error())
|
||||
|
||||
iter := json.BorrowIterator(stream.Buffer())
|
||||
defer json.ReturnIterator(iter)
|
||||
dest := &otlpcollectormetrics.ExportMetricsServiceRequest{}
|
||||
UnmarshalJSONOrigExportMetricsServiceRequest(dest, iter)
|
||||
require.NoError(t, iter.Error())
|
||||
|
||||
assert.Equal(t, src, dest)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestMarshalAndUnmarshalProtoOrigExportMetricsServiceRequest(t *testing.T) {
|
||||
src := &otlpcollectormetrics.ExportMetricsServiceRequest{}
|
||||
FillOrigTestExportMetricsServiceRequest(src)
|
||||
buf := make([]byte, SizeProtoOrigExportMetricsServiceRequest(src))
|
||||
gotSize := MarshalProtoOrigExportMetricsServiceRequest(src, buf)
|
||||
assert.Equal(t, len(buf), gotSize)
|
||||
for name, src := range getEncodingTestValuesExportMetricsServiceRequest() {
|
||||
t.Run(name, func(t *testing.T) {
|
||||
buf := make([]byte, SizeProtoOrigExportMetricsServiceRequest(src))
|
||||
gotSize := MarshalProtoOrigExportMetricsServiceRequest(src, buf)
|
||||
assert.Equal(t, len(buf), gotSize)
|
||||
|
||||
dest := &otlpcollectormetrics.ExportMetricsServiceRequest{}
|
||||
require.NoError(t, UnmarshalProtoOrigExportMetricsServiceRequest(dest, buf))
|
||||
assert.Equal(t, src, dest)
|
||||
dest := &otlpcollectormetrics.ExportMetricsServiceRequest{}
|
||||
require.NoError(t, UnmarshalProtoOrigExportMetricsServiceRequest(dest, buf))
|
||||
assert.Equal(t, src, dest)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestMarshalAndUnmarshalProtoOrigEmptyExportMetricsServiceRequest(t *testing.T) {
|
||||
src := &otlpcollectormetrics.ExportMetricsServiceRequest{}
|
||||
buf := make([]byte, SizeProtoOrigExportMetricsServiceRequest(src))
|
||||
gotSize := MarshalProtoOrigExportMetricsServiceRequest(src, buf)
|
||||
assert.Equal(t, len(buf), gotSize)
|
||||
|
||||
dest := &otlpcollectormetrics.ExportMetricsServiceRequest{}
|
||||
require.NoError(t, UnmarshalProtoOrigExportMetricsServiceRequest(dest, buf))
|
||||
assert.Equal(t, src, dest)
|
||||
func getEncodingTestValuesExportMetricsServiceRequest() map[string]*otlpcollectormetrics.ExportMetricsServiceRequest {
|
||||
return map[string]*otlpcollectormetrics.ExportMetricsServiceRequest{
|
||||
"empty": {},
|
||||
"fill_test": func() *otlpcollectormetrics.ExportMetricsServiceRequest {
|
||||
src := &otlpcollectormetrics.ExportMetricsServiceRequest{}
|
||||
FillOrigTestExportMetricsServiceRequest(src)
|
||||
return src
|
||||
}(),
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,46 +26,55 @@ func TestCopyOrigExportMetricsServiceResponse(t *testing.T) {
|
|||
assert.Equal(t, src, dest)
|
||||
}
|
||||
|
||||
func TestMarshalAndUnmarshalJSONOrigExportMetricsServiceResponse(t *testing.T) {
|
||||
src := &otlpcollectormetrics.ExportMetricsServiceResponse{}
|
||||
FillOrigTestExportMetricsServiceResponse(src)
|
||||
stream := json.BorrowStream(nil)
|
||||
defer json.ReturnStream(stream)
|
||||
MarshalJSONOrigExportMetricsServiceResponse(src, stream)
|
||||
require.NoError(t, stream.Error())
|
||||
|
||||
// Append an unknown field at the start to ensure unknown fields are skipped
|
||||
// and the unmarshal logic continues.
|
||||
buf := stream.Buffer()
|
||||
assert.EqualValues(t, '{', buf[0])
|
||||
iter := json.BorrowIterator(append([]byte(`{"unknown": "string",`), buf[1:]...))
|
||||
func TestMarshalAndUnmarshalJSONOrigExportMetricsServiceResponseUnknown(t *testing.T) {
|
||||
iter := json.BorrowIterator([]byte(`{"unknown": "string"}`))
|
||||
defer json.ReturnIterator(iter)
|
||||
dest := &otlpcollectormetrics.ExportMetricsServiceResponse{}
|
||||
UnmarshalJSONOrigExportMetricsServiceResponse(dest, iter)
|
||||
require.NoError(t, iter.Error())
|
||||
assert.Equal(t, &otlpcollectormetrics.ExportMetricsServiceResponse{}, dest)
|
||||
}
|
||||
|
||||
assert.Equal(t, src, dest)
|
||||
func TestMarshalAndUnmarshalJSONOrigExportMetricsServiceResponse(t *testing.T) {
|
||||
for name, src := range getEncodingTestValuesExportMetricsServiceResponse() {
|
||||
t.Run(name, func(t *testing.T) {
|
||||
stream := json.BorrowStream(nil)
|
||||
defer json.ReturnStream(stream)
|
||||
MarshalJSONOrigExportMetricsServiceResponse(src, stream)
|
||||
require.NoError(t, stream.Error())
|
||||
|
||||
iter := json.BorrowIterator(stream.Buffer())
|
||||
defer json.ReturnIterator(iter)
|
||||
dest := &otlpcollectormetrics.ExportMetricsServiceResponse{}
|
||||
UnmarshalJSONOrigExportMetricsServiceResponse(dest, iter)
|
||||
require.NoError(t, iter.Error())
|
||||
|
||||
assert.Equal(t, src, dest)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestMarshalAndUnmarshalProtoOrigExportMetricsServiceResponse(t *testing.T) {
|
||||
src := &otlpcollectormetrics.ExportMetricsServiceResponse{}
|
||||
FillOrigTestExportMetricsServiceResponse(src)
|
||||
buf := make([]byte, SizeProtoOrigExportMetricsServiceResponse(src))
|
||||
gotSize := MarshalProtoOrigExportMetricsServiceResponse(src, buf)
|
||||
assert.Equal(t, len(buf), gotSize)
|
||||
for name, src := range getEncodingTestValuesExportMetricsServiceResponse() {
|
||||
t.Run(name, func(t *testing.T) {
|
||||
buf := make([]byte, SizeProtoOrigExportMetricsServiceResponse(src))
|
||||
gotSize := MarshalProtoOrigExportMetricsServiceResponse(src, buf)
|
||||
assert.Equal(t, len(buf), gotSize)
|
||||
|
||||
dest := &otlpcollectormetrics.ExportMetricsServiceResponse{}
|
||||
require.NoError(t, UnmarshalProtoOrigExportMetricsServiceResponse(dest, buf))
|
||||
assert.Equal(t, src, dest)
|
||||
dest := &otlpcollectormetrics.ExportMetricsServiceResponse{}
|
||||
require.NoError(t, UnmarshalProtoOrigExportMetricsServiceResponse(dest, buf))
|
||||
assert.Equal(t, src, dest)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestMarshalAndUnmarshalProtoOrigEmptyExportMetricsServiceResponse(t *testing.T) {
|
||||
src := &otlpcollectormetrics.ExportMetricsServiceResponse{}
|
||||
buf := make([]byte, SizeProtoOrigExportMetricsServiceResponse(src))
|
||||
gotSize := MarshalProtoOrigExportMetricsServiceResponse(src, buf)
|
||||
assert.Equal(t, len(buf), gotSize)
|
||||
|
||||
dest := &otlpcollectormetrics.ExportMetricsServiceResponse{}
|
||||
require.NoError(t, UnmarshalProtoOrigExportMetricsServiceResponse(dest, buf))
|
||||
assert.Equal(t, src, dest)
|
||||
func getEncodingTestValuesExportMetricsServiceResponse() map[string]*otlpcollectormetrics.ExportMetricsServiceResponse {
|
||||
return map[string]*otlpcollectormetrics.ExportMetricsServiceResponse{
|
||||
"empty": {},
|
||||
"fill_test": func() *otlpcollectormetrics.ExportMetricsServiceResponse {
|
||||
src := &otlpcollectormetrics.ExportMetricsServiceResponse{}
|
||||
FillOrigTestExportMetricsServiceResponse(src)
|
||||
return src
|
||||
}(),
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,46 +26,55 @@ func TestCopyOrigExportProfilesPartialSuccess(t *testing.T) {
|
|||
assert.Equal(t, src, dest)
|
||||
}
|
||||
|
||||
func TestMarshalAndUnmarshalJSONOrigExportProfilesPartialSuccess(t *testing.T) {
|
||||
src := &otlpcollectorprofile.ExportProfilesPartialSuccess{}
|
||||
FillOrigTestExportProfilesPartialSuccess(src)
|
||||
stream := json.BorrowStream(nil)
|
||||
defer json.ReturnStream(stream)
|
||||
MarshalJSONOrigExportProfilesPartialSuccess(src, stream)
|
||||
require.NoError(t, stream.Error())
|
||||
|
||||
// Append an unknown field at the start to ensure unknown fields are skipped
|
||||
// and the unmarshal logic continues.
|
||||
buf := stream.Buffer()
|
||||
assert.EqualValues(t, '{', buf[0])
|
||||
iter := json.BorrowIterator(append([]byte(`{"unknown": "string",`), buf[1:]...))
|
||||
func TestMarshalAndUnmarshalJSONOrigExportProfilesPartialSuccessUnknown(t *testing.T) {
|
||||
iter := json.BorrowIterator([]byte(`{"unknown": "string"}`))
|
||||
defer json.ReturnIterator(iter)
|
||||
dest := &otlpcollectorprofile.ExportProfilesPartialSuccess{}
|
||||
UnmarshalJSONOrigExportProfilesPartialSuccess(dest, iter)
|
||||
require.NoError(t, iter.Error())
|
||||
assert.Equal(t, &otlpcollectorprofile.ExportProfilesPartialSuccess{}, dest)
|
||||
}
|
||||
|
||||
assert.Equal(t, src, dest)
|
||||
func TestMarshalAndUnmarshalJSONOrigExportProfilesPartialSuccess(t *testing.T) {
|
||||
for name, src := range getEncodingTestValuesExportProfilesPartialSuccess() {
|
||||
t.Run(name, func(t *testing.T) {
|
||||
stream := json.BorrowStream(nil)
|
||||
defer json.ReturnStream(stream)
|
||||
MarshalJSONOrigExportProfilesPartialSuccess(src, stream)
|
||||
require.NoError(t, stream.Error())
|
||||
|
||||
iter := json.BorrowIterator(stream.Buffer())
|
||||
defer json.ReturnIterator(iter)
|
||||
dest := &otlpcollectorprofile.ExportProfilesPartialSuccess{}
|
||||
UnmarshalJSONOrigExportProfilesPartialSuccess(dest, iter)
|
||||
require.NoError(t, iter.Error())
|
||||
|
||||
assert.Equal(t, src, dest)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestMarshalAndUnmarshalProtoOrigExportProfilesPartialSuccess(t *testing.T) {
|
||||
src := &otlpcollectorprofile.ExportProfilesPartialSuccess{}
|
||||
FillOrigTestExportProfilesPartialSuccess(src)
|
||||
buf := make([]byte, SizeProtoOrigExportProfilesPartialSuccess(src))
|
||||
gotSize := MarshalProtoOrigExportProfilesPartialSuccess(src, buf)
|
||||
assert.Equal(t, len(buf), gotSize)
|
||||
for name, src := range getEncodingTestValuesExportProfilesPartialSuccess() {
|
||||
t.Run(name, func(t *testing.T) {
|
||||
buf := make([]byte, SizeProtoOrigExportProfilesPartialSuccess(src))
|
||||
gotSize := MarshalProtoOrigExportProfilesPartialSuccess(src, buf)
|
||||
assert.Equal(t, len(buf), gotSize)
|
||||
|
||||
dest := &otlpcollectorprofile.ExportProfilesPartialSuccess{}
|
||||
require.NoError(t, UnmarshalProtoOrigExportProfilesPartialSuccess(dest, buf))
|
||||
assert.Equal(t, src, dest)
|
||||
dest := &otlpcollectorprofile.ExportProfilesPartialSuccess{}
|
||||
require.NoError(t, UnmarshalProtoOrigExportProfilesPartialSuccess(dest, buf))
|
||||
assert.Equal(t, src, dest)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestMarshalAndUnmarshalProtoOrigEmptyExportProfilesPartialSuccess(t *testing.T) {
|
||||
src := &otlpcollectorprofile.ExportProfilesPartialSuccess{}
|
||||
buf := make([]byte, SizeProtoOrigExportProfilesPartialSuccess(src))
|
||||
gotSize := MarshalProtoOrigExportProfilesPartialSuccess(src, buf)
|
||||
assert.Equal(t, len(buf), gotSize)
|
||||
|
||||
dest := &otlpcollectorprofile.ExportProfilesPartialSuccess{}
|
||||
require.NoError(t, UnmarshalProtoOrigExportProfilesPartialSuccess(dest, buf))
|
||||
assert.Equal(t, src, dest)
|
||||
func getEncodingTestValuesExportProfilesPartialSuccess() map[string]*otlpcollectorprofile.ExportProfilesPartialSuccess {
|
||||
return map[string]*otlpcollectorprofile.ExportProfilesPartialSuccess{
|
||||
"empty": {},
|
||||
"fill_test": func() *otlpcollectorprofile.ExportProfilesPartialSuccess {
|
||||
src := &otlpcollectorprofile.ExportProfilesPartialSuccess{}
|
||||
FillOrigTestExportProfilesPartialSuccess(src)
|
||||
return src
|
||||
}(),
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,46 +26,55 @@ func TestCopyOrigExportProfilesServiceRequest(t *testing.T) {
|
|||
assert.Equal(t, src, dest)
|
||||
}
|
||||
|
||||
func TestMarshalAndUnmarshalJSONOrigExportProfilesServiceRequest(t *testing.T) {
|
||||
src := &otlpcollectorprofile.ExportProfilesServiceRequest{}
|
||||
FillOrigTestExportProfilesServiceRequest(src)
|
||||
stream := json.BorrowStream(nil)
|
||||
defer json.ReturnStream(stream)
|
||||
MarshalJSONOrigExportProfilesServiceRequest(src, stream)
|
||||
require.NoError(t, stream.Error())
|
||||
|
||||
// Append an unknown field at the start to ensure unknown fields are skipped
|
||||
// and the unmarshal logic continues.
|
||||
buf := stream.Buffer()
|
||||
assert.EqualValues(t, '{', buf[0])
|
||||
iter := json.BorrowIterator(append([]byte(`{"unknown": "string",`), buf[1:]...))
|
||||
func TestMarshalAndUnmarshalJSONOrigExportProfilesServiceRequestUnknown(t *testing.T) {
|
||||
iter := json.BorrowIterator([]byte(`{"unknown": "string"}`))
|
||||
defer json.ReturnIterator(iter)
|
||||
dest := &otlpcollectorprofile.ExportProfilesServiceRequest{}
|
||||
UnmarshalJSONOrigExportProfilesServiceRequest(dest, iter)
|
||||
require.NoError(t, iter.Error())
|
||||
assert.Equal(t, &otlpcollectorprofile.ExportProfilesServiceRequest{}, dest)
|
||||
}
|
||||
|
||||
assert.Equal(t, src, dest)
|
||||
func TestMarshalAndUnmarshalJSONOrigExportProfilesServiceRequest(t *testing.T) {
|
||||
for name, src := range getEncodingTestValuesExportProfilesServiceRequest() {
|
||||
t.Run(name, func(t *testing.T) {
|
||||
stream := json.BorrowStream(nil)
|
||||
defer json.ReturnStream(stream)
|
||||
MarshalJSONOrigExportProfilesServiceRequest(src, stream)
|
||||
require.NoError(t, stream.Error())
|
||||
|
||||
iter := json.BorrowIterator(stream.Buffer())
|
||||
defer json.ReturnIterator(iter)
|
||||
dest := &otlpcollectorprofile.ExportProfilesServiceRequest{}
|
||||
UnmarshalJSONOrigExportProfilesServiceRequest(dest, iter)
|
||||
require.NoError(t, iter.Error())
|
||||
|
||||
assert.Equal(t, src, dest)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestMarshalAndUnmarshalProtoOrigExportProfilesServiceRequest(t *testing.T) {
|
||||
src := &otlpcollectorprofile.ExportProfilesServiceRequest{}
|
||||
FillOrigTestExportProfilesServiceRequest(src)
|
||||
buf := make([]byte, SizeProtoOrigExportProfilesServiceRequest(src))
|
||||
gotSize := MarshalProtoOrigExportProfilesServiceRequest(src, buf)
|
||||
assert.Equal(t, len(buf), gotSize)
|
||||
for name, src := range getEncodingTestValuesExportProfilesServiceRequest() {
|
||||
t.Run(name, func(t *testing.T) {
|
||||
buf := make([]byte, SizeProtoOrigExportProfilesServiceRequest(src))
|
||||
gotSize := MarshalProtoOrigExportProfilesServiceRequest(src, buf)
|
||||
assert.Equal(t, len(buf), gotSize)
|
||||
|
||||
dest := &otlpcollectorprofile.ExportProfilesServiceRequest{}
|
||||
require.NoError(t, UnmarshalProtoOrigExportProfilesServiceRequest(dest, buf))
|
||||
assert.Equal(t, src, dest)
|
||||
dest := &otlpcollectorprofile.ExportProfilesServiceRequest{}
|
||||
require.NoError(t, UnmarshalProtoOrigExportProfilesServiceRequest(dest, buf))
|
||||
assert.Equal(t, src, dest)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestMarshalAndUnmarshalProtoOrigEmptyExportProfilesServiceRequest(t *testing.T) {
|
||||
src := &otlpcollectorprofile.ExportProfilesServiceRequest{}
|
||||
buf := make([]byte, SizeProtoOrigExportProfilesServiceRequest(src))
|
||||
gotSize := MarshalProtoOrigExportProfilesServiceRequest(src, buf)
|
||||
assert.Equal(t, len(buf), gotSize)
|
||||
|
||||
dest := &otlpcollectorprofile.ExportProfilesServiceRequest{}
|
||||
require.NoError(t, UnmarshalProtoOrigExportProfilesServiceRequest(dest, buf))
|
||||
assert.Equal(t, src, dest)
|
||||
func getEncodingTestValuesExportProfilesServiceRequest() map[string]*otlpcollectorprofile.ExportProfilesServiceRequest {
|
||||
return map[string]*otlpcollectorprofile.ExportProfilesServiceRequest{
|
||||
"empty": {},
|
||||
"fill_test": func() *otlpcollectorprofile.ExportProfilesServiceRequest {
|
||||
src := &otlpcollectorprofile.ExportProfilesServiceRequest{}
|
||||
FillOrigTestExportProfilesServiceRequest(src)
|
||||
return src
|
||||
}(),
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,46 +26,55 @@ func TestCopyOrigExportProfilesServiceResponse(t *testing.T) {
|
|||
assert.Equal(t, src, dest)
|
||||
}
|
||||
|
||||
func TestMarshalAndUnmarshalJSONOrigExportProfilesServiceResponse(t *testing.T) {
|
||||
src := &otlpcollectorprofile.ExportProfilesServiceResponse{}
|
||||
FillOrigTestExportProfilesServiceResponse(src)
|
||||
stream := json.BorrowStream(nil)
|
||||
defer json.ReturnStream(stream)
|
||||
MarshalJSONOrigExportProfilesServiceResponse(src, stream)
|
||||
require.NoError(t, stream.Error())
|
||||
|
||||
// Append an unknown field at the start to ensure unknown fields are skipped
|
||||
// and the unmarshal logic continues.
|
||||
buf := stream.Buffer()
|
||||
assert.EqualValues(t, '{', buf[0])
|
||||
iter := json.BorrowIterator(append([]byte(`{"unknown": "string",`), buf[1:]...))
|
||||
func TestMarshalAndUnmarshalJSONOrigExportProfilesServiceResponseUnknown(t *testing.T) {
|
||||
iter := json.BorrowIterator([]byte(`{"unknown": "string"}`))
|
||||
defer json.ReturnIterator(iter)
|
||||
dest := &otlpcollectorprofile.ExportProfilesServiceResponse{}
|
||||
UnmarshalJSONOrigExportProfilesServiceResponse(dest, iter)
|
||||
require.NoError(t, iter.Error())
|
||||
assert.Equal(t, &otlpcollectorprofile.ExportProfilesServiceResponse{}, dest)
|
||||
}
|
||||
|
||||
assert.Equal(t, src, dest)
|
||||
func TestMarshalAndUnmarshalJSONOrigExportProfilesServiceResponse(t *testing.T) {
|
||||
for name, src := range getEncodingTestValuesExportProfilesServiceResponse() {
|
||||
t.Run(name, func(t *testing.T) {
|
||||
stream := json.BorrowStream(nil)
|
||||
defer json.ReturnStream(stream)
|
||||
MarshalJSONOrigExportProfilesServiceResponse(src, stream)
|
||||
require.NoError(t, stream.Error())
|
||||
|
||||
iter := json.BorrowIterator(stream.Buffer())
|
||||
defer json.ReturnIterator(iter)
|
||||
dest := &otlpcollectorprofile.ExportProfilesServiceResponse{}
|
||||
UnmarshalJSONOrigExportProfilesServiceResponse(dest, iter)
|
||||
require.NoError(t, iter.Error())
|
||||
|
||||
assert.Equal(t, src, dest)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestMarshalAndUnmarshalProtoOrigExportProfilesServiceResponse(t *testing.T) {
|
||||
src := &otlpcollectorprofile.ExportProfilesServiceResponse{}
|
||||
FillOrigTestExportProfilesServiceResponse(src)
|
||||
buf := make([]byte, SizeProtoOrigExportProfilesServiceResponse(src))
|
||||
gotSize := MarshalProtoOrigExportProfilesServiceResponse(src, buf)
|
||||
assert.Equal(t, len(buf), gotSize)
|
||||
for name, src := range getEncodingTestValuesExportProfilesServiceResponse() {
|
||||
t.Run(name, func(t *testing.T) {
|
||||
buf := make([]byte, SizeProtoOrigExportProfilesServiceResponse(src))
|
||||
gotSize := MarshalProtoOrigExportProfilesServiceResponse(src, buf)
|
||||
assert.Equal(t, len(buf), gotSize)
|
||||
|
||||
dest := &otlpcollectorprofile.ExportProfilesServiceResponse{}
|
||||
require.NoError(t, UnmarshalProtoOrigExportProfilesServiceResponse(dest, buf))
|
||||
assert.Equal(t, src, dest)
|
||||
dest := &otlpcollectorprofile.ExportProfilesServiceResponse{}
|
||||
require.NoError(t, UnmarshalProtoOrigExportProfilesServiceResponse(dest, buf))
|
||||
assert.Equal(t, src, dest)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestMarshalAndUnmarshalProtoOrigEmptyExportProfilesServiceResponse(t *testing.T) {
|
||||
src := &otlpcollectorprofile.ExportProfilesServiceResponse{}
|
||||
buf := make([]byte, SizeProtoOrigExportProfilesServiceResponse(src))
|
||||
gotSize := MarshalProtoOrigExportProfilesServiceResponse(src, buf)
|
||||
assert.Equal(t, len(buf), gotSize)
|
||||
|
||||
dest := &otlpcollectorprofile.ExportProfilesServiceResponse{}
|
||||
require.NoError(t, UnmarshalProtoOrigExportProfilesServiceResponse(dest, buf))
|
||||
assert.Equal(t, src, dest)
|
||||
func getEncodingTestValuesExportProfilesServiceResponse() map[string]*otlpcollectorprofile.ExportProfilesServiceResponse {
|
||||
return map[string]*otlpcollectorprofile.ExportProfilesServiceResponse{
|
||||
"empty": {},
|
||||
"fill_test": func() *otlpcollectorprofile.ExportProfilesServiceResponse {
|
||||
src := &otlpcollectorprofile.ExportProfilesServiceResponse{}
|
||||
FillOrigTestExportProfilesServiceResponse(src)
|
||||
return src
|
||||
}(),
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,46 +26,55 @@ func TestCopyOrigExportTracePartialSuccess(t *testing.T) {
|
|||
assert.Equal(t, src, dest)
|
||||
}
|
||||
|
||||
func TestMarshalAndUnmarshalJSONOrigExportTracePartialSuccess(t *testing.T) {
|
||||
src := &otlpcollectortrace.ExportTracePartialSuccess{}
|
||||
FillOrigTestExportTracePartialSuccess(src)
|
||||
stream := json.BorrowStream(nil)
|
||||
defer json.ReturnStream(stream)
|
||||
MarshalJSONOrigExportTracePartialSuccess(src, stream)
|
||||
require.NoError(t, stream.Error())
|
||||
|
||||
// Append an unknown field at the start to ensure unknown fields are skipped
|
||||
// and the unmarshal logic continues.
|
||||
buf := stream.Buffer()
|
||||
assert.EqualValues(t, '{', buf[0])
|
||||
iter := json.BorrowIterator(append([]byte(`{"unknown": "string",`), buf[1:]...))
|
||||
func TestMarshalAndUnmarshalJSONOrigExportTracePartialSuccessUnknown(t *testing.T) {
|
||||
iter := json.BorrowIterator([]byte(`{"unknown": "string"}`))
|
||||
defer json.ReturnIterator(iter)
|
||||
dest := &otlpcollectortrace.ExportTracePartialSuccess{}
|
||||
UnmarshalJSONOrigExportTracePartialSuccess(dest, iter)
|
||||
require.NoError(t, iter.Error())
|
||||
assert.Equal(t, &otlpcollectortrace.ExportTracePartialSuccess{}, dest)
|
||||
}
|
||||
|
||||
assert.Equal(t, src, dest)
|
||||
func TestMarshalAndUnmarshalJSONOrigExportTracePartialSuccess(t *testing.T) {
|
||||
for name, src := range getEncodingTestValuesExportTracePartialSuccess() {
|
||||
t.Run(name, func(t *testing.T) {
|
||||
stream := json.BorrowStream(nil)
|
||||
defer json.ReturnStream(stream)
|
||||
MarshalJSONOrigExportTracePartialSuccess(src, stream)
|
||||
require.NoError(t, stream.Error())
|
||||
|
||||
iter := json.BorrowIterator(stream.Buffer())
|
||||
defer json.ReturnIterator(iter)
|
||||
dest := &otlpcollectortrace.ExportTracePartialSuccess{}
|
||||
UnmarshalJSONOrigExportTracePartialSuccess(dest, iter)
|
||||
require.NoError(t, iter.Error())
|
||||
|
||||
assert.Equal(t, src, dest)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestMarshalAndUnmarshalProtoOrigExportTracePartialSuccess(t *testing.T) {
|
||||
src := &otlpcollectortrace.ExportTracePartialSuccess{}
|
||||
FillOrigTestExportTracePartialSuccess(src)
|
||||
buf := make([]byte, SizeProtoOrigExportTracePartialSuccess(src))
|
||||
gotSize := MarshalProtoOrigExportTracePartialSuccess(src, buf)
|
||||
assert.Equal(t, len(buf), gotSize)
|
||||
for name, src := range getEncodingTestValuesExportTracePartialSuccess() {
|
||||
t.Run(name, func(t *testing.T) {
|
||||
buf := make([]byte, SizeProtoOrigExportTracePartialSuccess(src))
|
||||
gotSize := MarshalProtoOrigExportTracePartialSuccess(src, buf)
|
||||
assert.Equal(t, len(buf), gotSize)
|
||||
|
||||
dest := &otlpcollectortrace.ExportTracePartialSuccess{}
|
||||
require.NoError(t, UnmarshalProtoOrigExportTracePartialSuccess(dest, buf))
|
||||
assert.Equal(t, src, dest)
|
||||
dest := &otlpcollectortrace.ExportTracePartialSuccess{}
|
||||
require.NoError(t, UnmarshalProtoOrigExportTracePartialSuccess(dest, buf))
|
||||
assert.Equal(t, src, dest)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestMarshalAndUnmarshalProtoOrigEmptyExportTracePartialSuccess(t *testing.T) {
|
||||
src := &otlpcollectortrace.ExportTracePartialSuccess{}
|
||||
buf := make([]byte, SizeProtoOrigExportTracePartialSuccess(src))
|
||||
gotSize := MarshalProtoOrigExportTracePartialSuccess(src, buf)
|
||||
assert.Equal(t, len(buf), gotSize)
|
||||
|
||||
dest := &otlpcollectortrace.ExportTracePartialSuccess{}
|
||||
require.NoError(t, UnmarshalProtoOrigExportTracePartialSuccess(dest, buf))
|
||||
assert.Equal(t, src, dest)
|
||||
func getEncodingTestValuesExportTracePartialSuccess() map[string]*otlpcollectortrace.ExportTracePartialSuccess {
|
||||
return map[string]*otlpcollectortrace.ExportTracePartialSuccess{
|
||||
"empty": {},
|
||||
"fill_test": func() *otlpcollectortrace.ExportTracePartialSuccess {
|
||||
src := &otlpcollectortrace.ExportTracePartialSuccess{}
|
||||
FillOrigTestExportTracePartialSuccess(src)
|
||||
return src
|
||||
}(),
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,46 +26,55 @@ func TestCopyOrigExportTraceServiceRequest(t *testing.T) {
|
|||
assert.Equal(t, src, dest)
|
||||
}
|
||||
|
||||
func TestMarshalAndUnmarshalJSONOrigExportTraceServiceRequest(t *testing.T) {
|
||||
src := &otlpcollectortrace.ExportTraceServiceRequest{}
|
||||
FillOrigTestExportTraceServiceRequest(src)
|
||||
stream := json.BorrowStream(nil)
|
||||
defer json.ReturnStream(stream)
|
||||
MarshalJSONOrigExportTraceServiceRequest(src, stream)
|
||||
require.NoError(t, stream.Error())
|
||||
|
||||
// Append an unknown field at the start to ensure unknown fields are skipped
|
||||
// and the unmarshal logic continues.
|
||||
buf := stream.Buffer()
|
||||
assert.EqualValues(t, '{', buf[0])
|
||||
iter := json.BorrowIterator(append([]byte(`{"unknown": "string",`), buf[1:]...))
|
||||
func TestMarshalAndUnmarshalJSONOrigExportTraceServiceRequestUnknown(t *testing.T) {
|
||||
iter := json.BorrowIterator([]byte(`{"unknown": "string"}`))
|
||||
defer json.ReturnIterator(iter)
|
||||
dest := &otlpcollectortrace.ExportTraceServiceRequest{}
|
||||
UnmarshalJSONOrigExportTraceServiceRequest(dest, iter)
|
||||
require.NoError(t, iter.Error())
|
||||
assert.Equal(t, &otlpcollectortrace.ExportTraceServiceRequest{}, dest)
|
||||
}
|
||||
|
||||
assert.Equal(t, src, dest)
|
||||
func TestMarshalAndUnmarshalJSONOrigExportTraceServiceRequest(t *testing.T) {
|
||||
for name, src := range getEncodingTestValuesExportTraceServiceRequest() {
|
||||
t.Run(name, func(t *testing.T) {
|
||||
stream := json.BorrowStream(nil)
|
||||
defer json.ReturnStream(stream)
|
||||
MarshalJSONOrigExportTraceServiceRequest(src, stream)
|
||||
require.NoError(t, stream.Error())
|
||||
|
||||
iter := json.BorrowIterator(stream.Buffer())
|
||||
defer json.ReturnIterator(iter)
|
||||
dest := &otlpcollectortrace.ExportTraceServiceRequest{}
|
||||
UnmarshalJSONOrigExportTraceServiceRequest(dest, iter)
|
||||
require.NoError(t, iter.Error())
|
||||
|
||||
assert.Equal(t, src, dest)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestMarshalAndUnmarshalProtoOrigExportTraceServiceRequest(t *testing.T) {
|
||||
src := &otlpcollectortrace.ExportTraceServiceRequest{}
|
||||
FillOrigTestExportTraceServiceRequest(src)
|
||||
buf := make([]byte, SizeProtoOrigExportTraceServiceRequest(src))
|
||||
gotSize := MarshalProtoOrigExportTraceServiceRequest(src, buf)
|
||||
assert.Equal(t, len(buf), gotSize)
|
||||
for name, src := range getEncodingTestValuesExportTraceServiceRequest() {
|
||||
t.Run(name, func(t *testing.T) {
|
||||
buf := make([]byte, SizeProtoOrigExportTraceServiceRequest(src))
|
||||
gotSize := MarshalProtoOrigExportTraceServiceRequest(src, buf)
|
||||
assert.Equal(t, len(buf), gotSize)
|
||||
|
||||
dest := &otlpcollectortrace.ExportTraceServiceRequest{}
|
||||
require.NoError(t, UnmarshalProtoOrigExportTraceServiceRequest(dest, buf))
|
||||
assert.Equal(t, src, dest)
|
||||
dest := &otlpcollectortrace.ExportTraceServiceRequest{}
|
||||
require.NoError(t, UnmarshalProtoOrigExportTraceServiceRequest(dest, buf))
|
||||
assert.Equal(t, src, dest)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestMarshalAndUnmarshalProtoOrigEmptyExportTraceServiceRequest(t *testing.T) {
|
||||
src := &otlpcollectortrace.ExportTraceServiceRequest{}
|
||||
buf := make([]byte, SizeProtoOrigExportTraceServiceRequest(src))
|
||||
gotSize := MarshalProtoOrigExportTraceServiceRequest(src, buf)
|
||||
assert.Equal(t, len(buf), gotSize)
|
||||
|
||||
dest := &otlpcollectortrace.ExportTraceServiceRequest{}
|
||||
require.NoError(t, UnmarshalProtoOrigExportTraceServiceRequest(dest, buf))
|
||||
assert.Equal(t, src, dest)
|
||||
func getEncodingTestValuesExportTraceServiceRequest() map[string]*otlpcollectortrace.ExportTraceServiceRequest {
|
||||
return map[string]*otlpcollectortrace.ExportTraceServiceRequest{
|
||||
"empty": {},
|
||||
"fill_test": func() *otlpcollectortrace.ExportTraceServiceRequest {
|
||||
src := &otlpcollectortrace.ExportTraceServiceRequest{}
|
||||
FillOrigTestExportTraceServiceRequest(src)
|
||||
return src
|
||||
}(),
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,46 +26,55 @@ func TestCopyOrigExportTraceServiceResponse(t *testing.T) {
|
|||
assert.Equal(t, src, dest)
|
||||
}
|
||||
|
||||
func TestMarshalAndUnmarshalJSONOrigExportTraceServiceResponse(t *testing.T) {
|
||||
src := &otlpcollectortrace.ExportTraceServiceResponse{}
|
||||
FillOrigTestExportTraceServiceResponse(src)
|
||||
stream := json.BorrowStream(nil)
|
||||
defer json.ReturnStream(stream)
|
||||
MarshalJSONOrigExportTraceServiceResponse(src, stream)
|
||||
require.NoError(t, stream.Error())
|
||||
|
||||
// Append an unknown field at the start to ensure unknown fields are skipped
|
||||
// and the unmarshal logic continues.
|
||||
buf := stream.Buffer()
|
||||
assert.EqualValues(t, '{', buf[0])
|
||||
iter := json.BorrowIterator(append([]byte(`{"unknown": "string",`), buf[1:]...))
|
||||
func TestMarshalAndUnmarshalJSONOrigExportTraceServiceResponseUnknown(t *testing.T) {
|
||||
iter := json.BorrowIterator([]byte(`{"unknown": "string"}`))
|
||||
defer json.ReturnIterator(iter)
|
||||
dest := &otlpcollectortrace.ExportTraceServiceResponse{}
|
||||
UnmarshalJSONOrigExportTraceServiceResponse(dest, iter)
|
||||
require.NoError(t, iter.Error())
|
||||
assert.Equal(t, &otlpcollectortrace.ExportTraceServiceResponse{}, dest)
|
||||
}
|
||||
|
||||
assert.Equal(t, src, dest)
|
||||
func TestMarshalAndUnmarshalJSONOrigExportTraceServiceResponse(t *testing.T) {
|
||||
for name, src := range getEncodingTestValuesExportTraceServiceResponse() {
|
||||
t.Run(name, func(t *testing.T) {
|
||||
stream := json.BorrowStream(nil)
|
||||
defer json.ReturnStream(stream)
|
||||
MarshalJSONOrigExportTraceServiceResponse(src, stream)
|
||||
require.NoError(t, stream.Error())
|
||||
|
||||
iter := json.BorrowIterator(stream.Buffer())
|
||||
defer json.ReturnIterator(iter)
|
||||
dest := &otlpcollectortrace.ExportTraceServiceResponse{}
|
||||
UnmarshalJSONOrigExportTraceServiceResponse(dest, iter)
|
||||
require.NoError(t, iter.Error())
|
||||
|
||||
assert.Equal(t, src, dest)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestMarshalAndUnmarshalProtoOrigExportTraceServiceResponse(t *testing.T) {
|
||||
src := &otlpcollectortrace.ExportTraceServiceResponse{}
|
||||
FillOrigTestExportTraceServiceResponse(src)
|
||||
buf := make([]byte, SizeProtoOrigExportTraceServiceResponse(src))
|
||||
gotSize := MarshalProtoOrigExportTraceServiceResponse(src, buf)
|
||||
assert.Equal(t, len(buf), gotSize)
|
||||
for name, src := range getEncodingTestValuesExportTraceServiceResponse() {
|
||||
t.Run(name, func(t *testing.T) {
|
||||
buf := make([]byte, SizeProtoOrigExportTraceServiceResponse(src))
|
||||
gotSize := MarshalProtoOrigExportTraceServiceResponse(src, buf)
|
||||
assert.Equal(t, len(buf), gotSize)
|
||||
|
||||
dest := &otlpcollectortrace.ExportTraceServiceResponse{}
|
||||
require.NoError(t, UnmarshalProtoOrigExportTraceServiceResponse(dest, buf))
|
||||
assert.Equal(t, src, dest)
|
||||
dest := &otlpcollectortrace.ExportTraceServiceResponse{}
|
||||
require.NoError(t, UnmarshalProtoOrigExportTraceServiceResponse(dest, buf))
|
||||
assert.Equal(t, src, dest)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestMarshalAndUnmarshalProtoOrigEmptyExportTraceServiceResponse(t *testing.T) {
|
||||
src := &otlpcollectortrace.ExportTraceServiceResponse{}
|
||||
buf := make([]byte, SizeProtoOrigExportTraceServiceResponse(src))
|
||||
gotSize := MarshalProtoOrigExportTraceServiceResponse(src, buf)
|
||||
assert.Equal(t, len(buf), gotSize)
|
||||
|
||||
dest := &otlpcollectortrace.ExportTraceServiceResponse{}
|
||||
require.NoError(t, UnmarshalProtoOrigExportTraceServiceResponse(dest, buf))
|
||||
assert.Equal(t, src, dest)
|
||||
func getEncodingTestValuesExportTraceServiceResponse() map[string]*otlpcollectortrace.ExportTraceServiceResponse {
|
||||
return map[string]*otlpcollectortrace.ExportTraceServiceResponse{
|
||||
"empty": {},
|
||||
"fill_test": func() *otlpcollectortrace.ExportTraceServiceResponse {
|
||||
src := &otlpcollectortrace.ExportTraceServiceResponse{}
|
||||
FillOrigTestExportTraceServiceResponse(src)
|
||||
return src
|
||||
}(),
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,46 +26,55 @@ func TestCopyOrigFunction(t *testing.T) {
|
|||
assert.Equal(t, src, dest)
|
||||
}
|
||||
|
||||
func TestMarshalAndUnmarshalJSONOrigFunction(t *testing.T) {
|
||||
src := &otlpprofiles.Function{}
|
||||
FillOrigTestFunction(src)
|
||||
stream := json.BorrowStream(nil)
|
||||
defer json.ReturnStream(stream)
|
||||
MarshalJSONOrigFunction(src, stream)
|
||||
require.NoError(t, stream.Error())
|
||||
|
||||
// Append an unknown field at the start to ensure unknown fields are skipped
|
||||
// and the unmarshal logic continues.
|
||||
buf := stream.Buffer()
|
||||
assert.EqualValues(t, '{', buf[0])
|
||||
iter := json.BorrowIterator(append([]byte(`{"unknown": "string",`), buf[1:]...))
|
||||
func TestMarshalAndUnmarshalJSONOrigFunctionUnknown(t *testing.T) {
|
||||
iter := json.BorrowIterator([]byte(`{"unknown": "string"}`))
|
||||
defer json.ReturnIterator(iter)
|
||||
dest := &otlpprofiles.Function{}
|
||||
UnmarshalJSONOrigFunction(dest, iter)
|
||||
require.NoError(t, iter.Error())
|
||||
assert.Equal(t, &otlpprofiles.Function{}, dest)
|
||||
}
|
||||
|
||||
assert.Equal(t, src, dest)
|
||||
func TestMarshalAndUnmarshalJSONOrigFunction(t *testing.T) {
|
||||
for name, src := range getEncodingTestValuesFunction() {
|
||||
t.Run(name, func(t *testing.T) {
|
||||
stream := json.BorrowStream(nil)
|
||||
defer json.ReturnStream(stream)
|
||||
MarshalJSONOrigFunction(src, stream)
|
||||
require.NoError(t, stream.Error())
|
||||
|
||||
iter := json.BorrowIterator(stream.Buffer())
|
||||
defer json.ReturnIterator(iter)
|
||||
dest := &otlpprofiles.Function{}
|
||||
UnmarshalJSONOrigFunction(dest, iter)
|
||||
require.NoError(t, iter.Error())
|
||||
|
||||
assert.Equal(t, src, dest)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestMarshalAndUnmarshalProtoOrigFunction(t *testing.T) {
|
||||
src := &otlpprofiles.Function{}
|
||||
FillOrigTestFunction(src)
|
||||
buf := make([]byte, SizeProtoOrigFunction(src))
|
||||
gotSize := MarshalProtoOrigFunction(src, buf)
|
||||
assert.Equal(t, len(buf), gotSize)
|
||||
for name, src := range getEncodingTestValuesFunction() {
|
||||
t.Run(name, func(t *testing.T) {
|
||||
buf := make([]byte, SizeProtoOrigFunction(src))
|
||||
gotSize := MarshalProtoOrigFunction(src, buf)
|
||||
assert.Equal(t, len(buf), gotSize)
|
||||
|
||||
dest := &otlpprofiles.Function{}
|
||||
require.NoError(t, UnmarshalProtoOrigFunction(dest, buf))
|
||||
assert.Equal(t, src, dest)
|
||||
dest := &otlpprofiles.Function{}
|
||||
require.NoError(t, UnmarshalProtoOrigFunction(dest, buf))
|
||||
assert.Equal(t, src, dest)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestMarshalAndUnmarshalProtoOrigEmptyFunction(t *testing.T) {
|
||||
src := &otlpprofiles.Function{}
|
||||
buf := make([]byte, SizeProtoOrigFunction(src))
|
||||
gotSize := MarshalProtoOrigFunction(src, buf)
|
||||
assert.Equal(t, len(buf), gotSize)
|
||||
|
||||
dest := &otlpprofiles.Function{}
|
||||
require.NoError(t, UnmarshalProtoOrigFunction(dest, buf))
|
||||
assert.Equal(t, src, dest)
|
||||
func getEncodingTestValuesFunction() map[string]*otlpprofiles.Function {
|
||||
return map[string]*otlpprofiles.Function{
|
||||
"empty": {},
|
||||
"fill_test": func() *otlpprofiles.Function {
|
||||
src := &otlpprofiles.Function{}
|
||||
FillOrigTestFunction(src)
|
||||
return src
|
||||
}(),
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,46 +26,55 @@ func TestCopyOrigGauge(t *testing.T) {
|
|||
assert.Equal(t, src, dest)
|
||||
}
|
||||
|
||||
func TestMarshalAndUnmarshalJSONOrigGauge(t *testing.T) {
|
||||
src := &otlpmetrics.Gauge{}
|
||||
FillOrigTestGauge(src)
|
||||
stream := json.BorrowStream(nil)
|
||||
defer json.ReturnStream(stream)
|
||||
MarshalJSONOrigGauge(src, stream)
|
||||
require.NoError(t, stream.Error())
|
||||
|
||||
// Append an unknown field at the start to ensure unknown fields are skipped
|
||||
// and the unmarshal logic continues.
|
||||
buf := stream.Buffer()
|
||||
assert.EqualValues(t, '{', buf[0])
|
||||
iter := json.BorrowIterator(append([]byte(`{"unknown": "string",`), buf[1:]...))
|
||||
func TestMarshalAndUnmarshalJSONOrigGaugeUnknown(t *testing.T) {
|
||||
iter := json.BorrowIterator([]byte(`{"unknown": "string"}`))
|
||||
defer json.ReturnIterator(iter)
|
||||
dest := &otlpmetrics.Gauge{}
|
||||
UnmarshalJSONOrigGauge(dest, iter)
|
||||
require.NoError(t, iter.Error())
|
||||
assert.Equal(t, &otlpmetrics.Gauge{}, dest)
|
||||
}
|
||||
|
||||
assert.Equal(t, src, dest)
|
||||
func TestMarshalAndUnmarshalJSONOrigGauge(t *testing.T) {
|
||||
for name, src := range getEncodingTestValuesGauge() {
|
||||
t.Run(name, func(t *testing.T) {
|
||||
stream := json.BorrowStream(nil)
|
||||
defer json.ReturnStream(stream)
|
||||
MarshalJSONOrigGauge(src, stream)
|
||||
require.NoError(t, stream.Error())
|
||||
|
||||
iter := json.BorrowIterator(stream.Buffer())
|
||||
defer json.ReturnIterator(iter)
|
||||
dest := &otlpmetrics.Gauge{}
|
||||
UnmarshalJSONOrigGauge(dest, iter)
|
||||
require.NoError(t, iter.Error())
|
||||
|
||||
assert.Equal(t, src, dest)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestMarshalAndUnmarshalProtoOrigGauge(t *testing.T) {
|
||||
src := &otlpmetrics.Gauge{}
|
||||
FillOrigTestGauge(src)
|
||||
buf := make([]byte, SizeProtoOrigGauge(src))
|
||||
gotSize := MarshalProtoOrigGauge(src, buf)
|
||||
assert.Equal(t, len(buf), gotSize)
|
||||
for name, src := range getEncodingTestValuesGauge() {
|
||||
t.Run(name, func(t *testing.T) {
|
||||
buf := make([]byte, SizeProtoOrigGauge(src))
|
||||
gotSize := MarshalProtoOrigGauge(src, buf)
|
||||
assert.Equal(t, len(buf), gotSize)
|
||||
|
||||
dest := &otlpmetrics.Gauge{}
|
||||
require.NoError(t, UnmarshalProtoOrigGauge(dest, buf))
|
||||
assert.Equal(t, src, dest)
|
||||
dest := &otlpmetrics.Gauge{}
|
||||
require.NoError(t, UnmarshalProtoOrigGauge(dest, buf))
|
||||
assert.Equal(t, src, dest)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestMarshalAndUnmarshalProtoOrigEmptyGauge(t *testing.T) {
|
||||
src := &otlpmetrics.Gauge{}
|
||||
buf := make([]byte, SizeProtoOrigGauge(src))
|
||||
gotSize := MarshalProtoOrigGauge(src, buf)
|
||||
assert.Equal(t, len(buf), gotSize)
|
||||
|
||||
dest := &otlpmetrics.Gauge{}
|
||||
require.NoError(t, UnmarshalProtoOrigGauge(dest, buf))
|
||||
assert.Equal(t, src, dest)
|
||||
func getEncodingTestValuesGauge() map[string]*otlpmetrics.Gauge {
|
||||
return map[string]*otlpmetrics.Gauge{
|
||||
"empty": {},
|
||||
"fill_test": func() *otlpmetrics.Gauge {
|
||||
src := &otlpmetrics.Gauge{}
|
||||
FillOrigTestGauge(src)
|
||||
return src
|
||||
}(),
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,46 +26,55 @@ func TestCopyOrigHistogram(t *testing.T) {
|
|||
assert.Equal(t, src, dest)
|
||||
}
|
||||
|
||||
func TestMarshalAndUnmarshalJSONOrigHistogram(t *testing.T) {
|
||||
src := &otlpmetrics.Histogram{}
|
||||
FillOrigTestHistogram(src)
|
||||
stream := json.BorrowStream(nil)
|
||||
defer json.ReturnStream(stream)
|
||||
MarshalJSONOrigHistogram(src, stream)
|
||||
require.NoError(t, stream.Error())
|
||||
|
||||
// Append an unknown field at the start to ensure unknown fields are skipped
|
||||
// and the unmarshal logic continues.
|
||||
buf := stream.Buffer()
|
||||
assert.EqualValues(t, '{', buf[0])
|
||||
iter := json.BorrowIterator(append([]byte(`{"unknown": "string",`), buf[1:]...))
|
||||
func TestMarshalAndUnmarshalJSONOrigHistogramUnknown(t *testing.T) {
|
||||
iter := json.BorrowIterator([]byte(`{"unknown": "string"}`))
|
||||
defer json.ReturnIterator(iter)
|
||||
dest := &otlpmetrics.Histogram{}
|
||||
UnmarshalJSONOrigHistogram(dest, iter)
|
||||
require.NoError(t, iter.Error())
|
||||
assert.Equal(t, &otlpmetrics.Histogram{}, dest)
|
||||
}
|
||||
|
||||
assert.Equal(t, src, dest)
|
||||
func TestMarshalAndUnmarshalJSONOrigHistogram(t *testing.T) {
|
||||
for name, src := range getEncodingTestValuesHistogram() {
|
||||
t.Run(name, func(t *testing.T) {
|
||||
stream := json.BorrowStream(nil)
|
||||
defer json.ReturnStream(stream)
|
||||
MarshalJSONOrigHistogram(src, stream)
|
||||
require.NoError(t, stream.Error())
|
||||
|
||||
iter := json.BorrowIterator(stream.Buffer())
|
||||
defer json.ReturnIterator(iter)
|
||||
dest := &otlpmetrics.Histogram{}
|
||||
UnmarshalJSONOrigHistogram(dest, iter)
|
||||
require.NoError(t, iter.Error())
|
||||
|
||||
assert.Equal(t, src, dest)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestMarshalAndUnmarshalProtoOrigHistogram(t *testing.T) {
|
||||
src := &otlpmetrics.Histogram{}
|
||||
FillOrigTestHistogram(src)
|
||||
buf := make([]byte, SizeProtoOrigHistogram(src))
|
||||
gotSize := MarshalProtoOrigHistogram(src, buf)
|
||||
assert.Equal(t, len(buf), gotSize)
|
||||
for name, src := range getEncodingTestValuesHistogram() {
|
||||
t.Run(name, func(t *testing.T) {
|
||||
buf := make([]byte, SizeProtoOrigHistogram(src))
|
||||
gotSize := MarshalProtoOrigHistogram(src, buf)
|
||||
assert.Equal(t, len(buf), gotSize)
|
||||
|
||||
dest := &otlpmetrics.Histogram{}
|
||||
require.NoError(t, UnmarshalProtoOrigHistogram(dest, buf))
|
||||
assert.Equal(t, src, dest)
|
||||
dest := &otlpmetrics.Histogram{}
|
||||
require.NoError(t, UnmarshalProtoOrigHistogram(dest, buf))
|
||||
assert.Equal(t, src, dest)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestMarshalAndUnmarshalProtoOrigEmptyHistogram(t *testing.T) {
|
||||
src := &otlpmetrics.Histogram{}
|
||||
buf := make([]byte, SizeProtoOrigHistogram(src))
|
||||
gotSize := MarshalProtoOrigHistogram(src, buf)
|
||||
assert.Equal(t, len(buf), gotSize)
|
||||
|
||||
dest := &otlpmetrics.Histogram{}
|
||||
require.NoError(t, UnmarshalProtoOrigHistogram(dest, buf))
|
||||
assert.Equal(t, src, dest)
|
||||
func getEncodingTestValuesHistogram() map[string]*otlpmetrics.Histogram {
|
||||
return map[string]*otlpmetrics.Histogram{
|
||||
"empty": {},
|
||||
"fill_test": func() *otlpmetrics.Histogram {
|
||||
src := &otlpmetrics.Histogram{}
|
||||
FillOrigTestHistogram(src)
|
||||
return src
|
||||
}(),
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,46 +26,58 @@ func TestCopyOrigHistogramDataPoint(t *testing.T) {
|
|||
assert.Equal(t, src, dest)
|
||||
}
|
||||
|
||||
func TestMarshalAndUnmarshalJSONOrigHistogramDataPoint(t *testing.T) {
|
||||
src := &otlpmetrics.HistogramDataPoint{}
|
||||
FillOrigTestHistogramDataPoint(src)
|
||||
stream := json.BorrowStream(nil)
|
||||
defer json.ReturnStream(stream)
|
||||
MarshalJSONOrigHistogramDataPoint(src, stream)
|
||||
require.NoError(t, stream.Error())
|
||||
|
||||
// Append an unknown field at the start to ensure unknown fields are skipped
|
||||
// and the unmarshal logic continues.
|
||||
buf := stream.Buffer()
|
||||
assert.EqualValues(t, '{', buf[0])
|
||||
iter := json.BorrowIterator(append([]byte(`{"unknown": "string",`), buf[1:]...))
|
||||
func TestMarshalAndUnmarshalJSONOrigHistogramDataPointUnknown(t *testing.T) {
|
||||
iter := json.BorrowIterator([]byte(`{"unknown": "string"}`))
|
||||
defer json.ReturnIterator(iter)
|
||||
dest := &otlpmetrics.HistogramDataPoint{}
|
||||
UnmarshalJSONOrigHistogramDataPoint(dest, iter)
|
||||
require.NoError(t, iter.Error())
|
||||
assert.Equal(t, &otlpmetrics.HistogramDataPoint{}, dest)
|
||||
}
|
||||
|
||||
assert.Equal(t, src, dest)
|
||||
func TestMarshalAndUnmarshalJSONOrigHistogramDataPoint(t *testing.T) {
|
||||
for name, src := range getEncodingTestValuesHistogramDataPoint() {
|
||||
t.Run(name, func(t *testing.T) {
|
||||
stream := json.BorrowStream(nil)
|
||||
defer json.ReturnStream(stream)
|
||||
MarshalJSONOrigHistogramDataPoint(src, stream)
|
||||
require.NoError(t, stream.Error())
|
||||
|
||||
iter := json.BorrowIterator(stream.Buffer())
|
||||
defer json.ReturnIterator(iter)
|
||||
dest := &otlpmetrics.HistogramDataPoint{}
|
||||
UnmarshalJSONOrigHistogramDataPoint(dest, iter)
|
||||
require.NoError(t, iter.Error())
|
||||
|
||||
assert.Equal(t, src, dest)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestMarshalAndUnmarshalProtoOrigHistogramDataPoint(t *testing.T) {
|
||||
src := &otlpmetrics.HistogramDataPoint{}
|
||||
FillOrigTestHistogramDataPoint(src)
|
||||
buf := make([]byte, SizeProtoOrigHistogramDataPoint(src))
|
||||
gotSize := MarshalProtoOrigHistogramDataPoint(src, buf)
|
||||
assert.Equal(t, len(buf), gotSize)
|
||||
for name, src := range getEncodingTestValuesHistogramDataPoint() {
|
||||
t.Run(name, func(t *testing.T) {
|
||||
buf := make([]byte, SizeProtoOrigHistogramDataPoint(src))
|
||||
gotSize := MarshalProtoOrigHistogramDataPoint(src, buf)
|
||||
assert.Equal(t, len(buf), gotSize)
|
||||
|
||||
dest := &otlpmetrics.HistogramDataPoint{}
|
||||
require.NoError(t, UnmarshalProtoOrigHistogramDataPoint(dest, buf))
|
||||
assert.Equal(t, src, dest)
|
||||
dest := &otlpmetrics.HistogramDataPoint{}
|
||||
require.NoError(t, UnmarshalProtoOrigHistogramDataPoint(dest, buf))
|
||||
assert.Equal(t, src, dest)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestMarshalAndUnmarshalProtoOrigEmptyHistogramDataPoint(t *testing.T) {
|
||||
src := &otlpmetrics.HistogramDataPoint{}
|
||||
buf := make([]byte, SizeProtoOrigHistogramDataPoint(src))
|
||||
gotSize := MarshalProtoOrigHistogramDataPoint(src, buf)
|
||||
assert.Equal(t, len(buf), gotSize)
|
||||
|
||||
dest := &otlpmetrics.HistogramDataPoint{}
|
||||
require.NoError(t, UnmarshalProtoOrigHistogramDataPoint(dest, buf))
|
||||
assert.Equal(t, src, dest)
|
||||
func getEncodingTestValuesHistogramDataPoint() map[string]*otlpmetrics.HistogramDataPoint {
|
||||
return map[string]*otlpmetrics.HistogramDataPoint{
|
||||
"empty": {},
|
||||
"fill_test": func() *otlpmetrics.HistogramDataPoint {
|
||||
src := &otlpmetrics.HistogramDataPoint{}
|
||||
FillOrigTestHistogramDataPoint(src)
|
||||
return src
|
||||
}(),
|
||||
"default_sum": {Sum_: &otlpmetrics.HistogramDataPoint_Sum{Sum: float64(0)}},
|
||||
"default_min": {Min_: &otlpmetrics.HistogramDataPoint_Min{Min: float64(0)}},
|
||||
"default_max": {Max_: &otlpmetrics.HistogramDataPoint_Max{Max: float64(0)}},
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,46 +26,55 @@ func TestCopyOrigInstrumentationScope(t *testing.T) {
|
|||
assert.Equal(t, src, dest)
|
||||
}
|
||||
|
||||
func TestMarshalAndUnmarshalJSONOrigInstrumentationScope(t *testing.T) {
|
||||
src := &otlpcommon.InstrumentationScope{}
|
||||
FillOrigTestInstrumentationScope(src)
|
||||
stream := json.BorrowStream(nil)
|
||||
defer json.ReturnStream(stream)
|
||||
MarshalJSONOrigInstrumentationScope(src, stream)
|
||||
require.NoError(t, stream.Error())
|
||||
|
||||
// Append an unknown field at the start to ensure unknown fields are skipped
|
||||
// and the unmarshal logic continues.
|
||||
buf := stream.Buffer()
|
||||
assert.EqualValues(t, '{', buf[0])
|
||||
iter := json.BorrowIterator(append([]byte(`{"unknown": "string",`), buf[1:]...))
|
||||
func TestMarshalAndUnmarshalJSONOrigInstrumentationScopeUnknown(t *testing.T) {
|
||||
iter := json.BorrowIterator([]byte(`{"unknown": "string"}`))
|
||||
defer json.ReturnIterator(iter)
|
||||
dest := &otlpcommon.InstrumentationScope{}
|
||||
UnmarshalJSONOrigInstrumentationScope(dest, iter)
|
||||
require.NoError(t, iter.Error())
|
||||
assert.Equal(t, &otlpcommon.InstrumentationScope{}, dest)
|
||||
}
|
||||
|
||||
assert.Equal(t, src, dest)
|
||||
func TestMarshalAndUnmarshalJSONOrigInstrumentationScope(t *testing.T) {
|
||||
for name, src := range getEncodingTestValuesInstrumentationScope() {
|
||||
t.Run(name, func(t *testing.T) {
|
||||
stream := json.BorrowStream(nil)
|
||||
defer json.ReturnStream(stream)
|
||||
MarshalJSONOrigInstrumentationScope(src, stream)
|
||||
require.NoError(t, stream.Error())
|
||||
|
||||
iter := json.BorrowIterator(stream.Buffer())
|
||||
defer json.ReturnIterator(iter)
|
||||
dest := &otlpcommon.InstrumentationScope{}
|
||||
UnmarshalJSONOrigInstrumentationScope(dest, iter)
|
||||
require.NoError(t, iter.Error())
|
||||
|
||||
assert.Equal(t, src, dest)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestMarshalAndUnmarshalProtoOrigInstrumentationScope(t *testing.T) {
|
||||
src := &otlpcommon.InstrumentationScope{}
|
||||
FillOrigTestInstrumentationScope(src)
|
||||
buf := make([]byte, SizeProtoOrigInstrumentationScope(src))
|
||||
gotSize := MarshalProtoOrigInstrumentationScope(src, buf)
|
||||
assert.Equal(t, len(buf), gotSize)
|
||||
for name, src := range getEncodingTestValuesInstrumentationScope() {
|
||||
t.Run(name, func(t *testing.T) {
|
||||
buf := make([]byte, SizeProtoOrigInstrumentationScope(src))
|
||||
gotSize := MarshalProtoOrigInstrumentationScope(src, buf)
|
||||
assert.Equal(t, len(buf), gotSize)
|
||||
|
||||
dest := &otlpcommon.InstrumentationScope{}
|
||||
require.NoError(t, UnmarshalProtoOrigInstrumentationScope(dest, buf))
|
||||
assert.Equal(t, src, dest)
|
||||
dest := &otlpcommon.InstrumentationScope{}
|
||||
require.NoError(t, UnmarshalProtoOrigInstrumentationScope(dest, buf))
|
||||
assert.Equal(t, src, dest)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestMarshalAndUnmarshalProtoOrigEmptyInstrumentationScope(t *testing.T) {
|
||||
src := &otlpcommon.InstrumentationScope{}
|
||||
buf := make([]byte, SizeProtoOrigInstrumentationScope(src))
|
||||
gotSize := MarshalProtoOrigInstrumentationScope(src, buf)
|
||||
assert.Equal(t, len(buf), gotSize)
|
||||
|
||||
dest := &otlpcommon.InstrumentationScope{}
|
||||
require.NoError(t, UnmarshalProtoOrigInstrumentationScope(dest, buf))
|
||||
assert.Equal(t, src, dest)
|
||||
func getEncodingTestValuesInstrumentationScope() map[string]*otlpcommon.InstrumentationScope {
|
||||
return map[string]*otlpcommon.InstrumentationScope{
|
||||
"empty": {},
|
||||
"fill_test": func() *otlpcommon.InstrumentationScope {
|
||||
src := &otlpcommon.InstrumentationScope{}
|
||||
FillOrigTestInstrumentationScope(src)
|
||||
return src
|
||||
}(),
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,46 +26,55 @@ func TestCopyOrigKeyValue(t *testing.T) {
|
|||
assert.Equal(t, src, dest)
|
||||
}
|
||||
|
||||
func TestMarshalAndUnmarshalJSONOrigKeyValue(t *testing.T) {
|
||||
src := &v1.KeyValue{}
|
||||
FillOrigTestKeyValue(src)
|
||||
stream := json.BorrowStream(nil)
|
||||
defer json.ReturnStream(stream)
|
||||
MarshalJSONOrigKeyValue(src, stream)
|
||||
require.NoError(t, stream.Error())
|
||||
|
||||
// Append an unknown field at the start to ensure unknown fields are skipped
|
||||
// and the unmarshal logic continues.
|
||||
buf := stream.Buffer()
|
||||
assert.EqualValues(t, '{', buf[0])
|
||||
iter := json.BorrowIterator(append([]byte(`{"unknown": "string",`), buf[1:]...))
|
||||
func TestMarshalAndUnmarshalJSONOrigKeyValueUnknown(t *testing.T) {
|
||||
iter := json.BorrowIterator([]byte(`{"unknown": "string"}`))
|
||||
defer json.ReturnIterator(iter)
|
||||
dest := &v1.KeyValue{}
|
||||
UnmarshalJSONOrigKeyValue(dest, iter)
|
||||
require.NoError(t, iter.Error())
|
||||
assert.Equal(t, &v1.KeyValue{}, dest)
|
||||
}
|
||||
|
||||
assert.Equal(t, src, dest)
|
||||
func TestMarshalAndUnmarshalJSONOrigKeyValue(t *testing.T) {
|
||||
for name, src := range getEncodingTestValuesKeyValue() {
|
||||
t.Run(name, func(t *testing.T) {
|
||||
stream := json.BorrowStream(nil)
|
||||
defer json.ReturnStream(stream)
|
||||
MarshalJSONOrigKeyValue(src, stream)
|
||||
require.NoError(t, stream.Error())
|
||||
|
||||
iter := json.BorrowIterator(stream.Buffer())
|
||||
defer json.ReturnIterator(iter)
|
||||
dest := &v1.KeyValue{}
|
||||
UnmarshalJSONOrigKeyValue(dest, iter)
|
||||
require.NoError(t, iter.Error())
|
||||
|
||||
assert.Equal(t, src, dest)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestMarshalAndUnmarshalProtoOrigKeyValue(t *testing.T) {
|
||||
src := &v1.KeyValue{}
|
||||
FillOrigTestKeyValue(src)
|
||||
buf := make([]byte, SizeProtoOrigKeyValue(src))
|
||||
gotSize := MarshalProtoOrigKeyValue(src, buf)
|
||||
assert.Equal(t, len(buf), gotSize)
|
||||
for name, src := range getEncodingTestValuesKeyValue() {
|
||||
t.Run(name, func(t *testing.T) {
|
||||
buf := make([]byte, SizeProtoOrigKeyValue(src))
|
||||
gotSize := MarshalProtoOrigKeyValue(src, buf)
|
||||
assert.Equal(t, len(buf), gotSize)
|
||||
|
||||
dest := &v1.KeyValue{}
|
||||
require.NoError(t, UnmarshalProtoOrigKeyValue(dest, buf))
|
||||
assert.Equal(t, src, dest)
|
||||
dest := &v1.KeyValue{}
|
||||
require.NoError(t, UnmarshalProtoOrigKeyValue(dest, buf))
|
||||
assert.Equal(t, src, dest)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestMarshalAndUnmarshalProtoOrigEmptyKeyValue(t *testing.T) {
|
||||
src := &v1.KeyValue{}
|
||||
buf := make([]byte, SizeProtoOrigKeyValue(src))
|
||||
gotSize := MarshalProtoOrigKeyValue(src, buf)
|
||||
assert.Equal(t, len(buf), gotSize)
|
||||
|
||||
dest := &v1.KeyValue{}
|
||||
require.NoError(t, UnmarshalProtoOrigKeyValue(dest, buf))
|
||||
assert.Equal(t, src, dest)
|
||||
func getEncodingTestValuesKeyValue() map[string]*v1.KeyValue {
|
||||
return map[string]*v1.KeyValue{
|
||||
"empty": {},
|
||||
"fill_test": func() *v1.KeyValue {
|
||||
src := &v1.KeyValue{}
|
||||
FillOrigTestKeyValue(src)
|
||||
return src
|
||||
}(),
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,46 +26,55 @@ func TestCopyOrigLine(t *testing.T) {
|
|||
assert.Equal(t, src, dest)
|
||||
}
|
||||
|
||||
func TestMarshalAndUnmarshalJSONOrigLine(t *testing.T) {
|
||||
src := &otlpprofiles.Line{}
|
||||
FillOrigTestLine(src)
|
||||
stream := json.BorrowStream(nil)
|
||||
defer json.ReturnStream(stream)
|
||||
MarshalJSONOrigLine(src, stream)
|
||||
require.NoError(t, stream.Error())
|
||||
|
||||
// Append an unknown field at the start to ensure unknown fields are skipped
|
||||
// and the unmarshal logic continues.
|
||||
buf := stream.Buffer()
|
||||
assert.EqualValues(t, '{', buf[0])
|
||||
iter := json.BorrowIterator(append([]byte(`{"unknown": "string",`), buf[1:]...))
|
||||
func TestMarshalAndUnmarshalJSONOrigLineUnknown(t *testing.T) {
|
||||
iter := json.BorrowIterator([]byte(`{"unknown": "string"}`))
|
||||
defer json.ReturnIterator(iter)
|
||||
dest := &otlpprofiles.Line{}
|
||||
UnmarshalJSONOrigLine(dest, iter)
|
||||
require.NoError(t, iter.Error())
|
||||
assert.Equal(t, &otlpprofiles.Line{}, dest)
|
||||
}
|
||||
|
||||
assert.Equal(t, src, dest)
|
||||
func TestMarshalAndUnmarshalJSONOrigLine(t *testing.T) {
|
||||
for name, src := range getEncodingTestValuesLine() {
|
||||
t.Run(name, func(t *testing.T) {
|
||||
stream := json.BorrowStream(nil)
|
||||
defer json.ReturnStream(stream)
|
||||
MarshalJSONOrigLine(src, stream)
|
||||
require.NoError(t, stream.Error())
|
||||
|
||||
iter := json.BorrowIterator(stream.Buffer())
|
||||
defer json.ReturnIterator(iter)
|
||||
dest := &otlpprofiles.Line{}
|
||||
UnmarshalJSONOrigLine(dest, iter)
|
||||
require.NoError(t, iter.Error())
|
||||
|
||||
assert.Equal(t, src, dest)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestMarshalAndUnmarshalProtoOrigLine(t *testing.T) {
|
||||
src := &otlpprofiles.Line{}
|
||||
FillOrigTestLine(src)
|
||||
buf := make([]byte, SizeProtoOrigLine(src))
|
||||
gotSize := MarshalProtoOrigLine(src, buf)
|
||||
assert.Equal(t, len(buf), gotSize)
|
||||
for name, src := range getEncodingTestValuesLine() {
|
||||
t.Run(name, func(t *testing.T) {
|
||||
buf := make([]byte, SizeProtoOrigLine(src))
|
||||
gotSize := MarshalProtoOrigLine(src, buf)
|
||||
assert.Equal(t, len(buf), gotSize)
|
||||
|
||||
dest := &otlpprofiles.Line{}
|
||||
require.NoError(t, UnmarshalProtoOrigLine(dest, buf))
|
||||
assert.Equal(t, src, dest)
|
||||
dest := &otlpprofiles.Line{}
|
||||
require.NoError(t, UnmarshalProtoOrigLine(dest, buf))
|
||||
assert.Equal(t, src, dest)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestMarshalAndUnmarshalProtoOrigEmptyLine(t *testing.T) {
|
||||
src := &otlpprofiles.Line{}
|
||||
buf := make([]byte, SizeProtoOrigLine(src))
|
||||
gotSize := MarshalProtoOrigLine(src, buf)
|
||||
assert.Equal(t, len(buf), gotSize)
|
||||
|
||||
dest := &otlpprofiles.Line{}
|
||||
require.NoError(t, UnmarshalProtoOrigLine(dest, buf))
|
||||
assert.Equal(t, src, dest)
|
||||
func getEncodingTestValuesLine() map[string]*otlpprofiles.Line {
|
||||
return map[string]*otlpprofiles.Line{
|
||||
"empty": {},
|
||||
"fill_test": func() *otlpprofiles.Line {
|
||||
src := &otlpprofiles.Line{}
|
||||
FillOrigTestLine(src)
|
||||
return src
|
||||
}(),
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,46 +26,55 @@ func TestCopyOrigLink(t *testing.T) {
|
|||
assert.Equal(t, src, dest)
|
||||
}
|
||||
|
||||
func TestMarshalAndUnmarshalJSONOrigLink(t *testing.T) {
|
||||
src := &otlpprofiles.Link{}
|
||||
FillOrigTestLink(src)
|
||||
stream := json.BorrowStream(nil)
|
||||
defer json.ReturnStream(stream)
|
||||
MarshalJSONOrigLink(src, stream)
|
||||
require.NoError(t, stream.Error())
|
||||
|
||||
// Append an unknown field at the start to ensure unknown fields are skipped
|
||||
// and the unmarshal logic continues.
|
||||
buf := stream.Buffer()
|
||||
assert.EqualValues(t, '{', buf[0])
|
||||
iter := json.BorrowIterator(append([]byte(`{"unknown": "string",`), buf[1:]...))
|
||||
func TestMarshalAndUnmarshalJSONOrigLinkUnknown(t *testing.T) {
|
||||
iter := json.BorrowIterator([]byte(`{"unknown": "string"}`))
|
||||
defer json.ReturnIterator(iter)
|
||||
dest := &otlpprofiles.Link{}
|
||||
UnmarshalJSONOrigLink(dest, iter)
|
||||
require.NoError(t, iter.Error())
|
||||
assert.Equal(t, &otlpprofiles.Link{}, dest)
|
||||
}
|
||||
|
||||
assert.Equal(t, src, dest)
|
||||
func TestMarshalAndUnmarshalJSONOrigLink(t *testing.T) {
|
||||
for name, src := range getEncodingTestValuesLink() {
|
||||
t.Run(name, func(t *testing.T) {
|
||||
stream := json.BorrowStream(nil)
|
||||
defer json.ReturnStream(stream)
|
||||
MarshalJSONOrigLink(src, stream)
|
||||
require.NoError(t, stream.Error())
|
||||
|
||||
iter := json.BorrowIterator(stream.Buffer())
|
||||
defer json.ReturnIterator(iter)
|
||||
dest := &otlpprofiles.Link{}
|
||||
UnmarshalJSONOrigLink(dest, iter)
|
||||
require.NoError(t, iter.Error())
|
||||
|
||||
assert.Equal(t, src, dest)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestMarshalAndUnmarshalProtoOrigLink(t *testing.T) {
|
||||
src := &otlpprofiles.Link{}
|
||||
FillOrigTestLink(src)
|
||||
buf := make([]byte, SizeProtoOrigLink(src))
|
||||
gotSize := MarshalProtoOrigLink(src, buf)
|
||||
assert.Equal(t, len(buf), gotSize)
|
||||
for name, src := range getEncodingTestValuesLink() {
|
||||
t.Run(name, func(t *testing.T) {
|
||||
buf := make([]byte, SizeProtoOrigLink(src))
|
||||
gotSize := MarshalProtoOrigLink(src, buf)
|
||||
assert.Equal(t, len(buf), gotSize)
|
||||
|
||||
dest := &otlpprofiles.Link{}
|
||||
require.NoError(t, UnmarshalProtoOrigLink(dest, buf))
|
||||
assert.Equal(t, src, dest)
|
||||
dest := &otlpprofiles.Link{}
|
||||
require.NoError(t, UnmarshalProtoOrigLink(dest, buf))
|
||||
assert.Equal(t, src, dest)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestMarshalAndUnmarshalProtoOrigEmptyLink(t *testing.T) {
|
||||
src := &otlpprofiles.Link{}
|
||||
buf := make([]byte, SizeProtoOrigLink(src))
|
||||
gotSize := MarshalProtoOrigLink(src, buf)
|
||||
assert.Equal(t, len(buf), gotSize)
|
||||
|
||||
dest := &otlpprofiles.Link{}
|
||||
require.NoError(t, UnmarshalProtoOrigLink(dest, buf))
|
||||
assert.Equal(t, src, dest)
|
||||
func getEncodingTestValuesLink() map[string]*otlpprofiles.Link {
|
||||
return map[string]*otlpprofiles.Link{
|
||||
"empty": {},
|
||||
"fill_test": func() *otlpprofiles.Link {
|
||||
src := &otlpprofiles.Link{}
|
||||
FillOrigTestLink(src)
|
||||
return src
|
||||
}(),
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,46 +26,56 @@ func TestCopyOrigLocation(t *testing.T) {
|
|||
assert.Equal(t, src, dest)
|
||||
}
|
||||
|
||||
func TestMarshalAndUnmarshalJSONOrigLocation(t *testing.T) {
|
||||
src := &otlpprofiles.Location{}
|
||||
FillOrigTestLocation(src)
|
||||
stream := json.BorrowStream(nil)
|
||||
defer json.ReturnStream(stream)
|
||||
MarshalJSONOrigLocation(src, stream)
|
||||
require.NoError(t, stream.Error())
|
||||
|
||||
// Append an unknown field at the start to ensure unknown fields are skipped
|
||||
// and the unmarshal logic continues.
|
||||
buf := stream.Buffer()
|
||||
assert.EqualValues(t, '{', buf[0])
|
||||
iter := json.BorrowIterator(append([]byte(`{"unknown": "string",`), buf[1:]...))
|
||||
func TestMarshalAndUnmarshalJSONOrigLocationUnknown(t *testing.T) {
|
||||
iter := json.BorrowIterator([]byte(`{"unknown": "string"}`))
|
||||
defer json.ReturnIterator(iter)
|
||||
dest := &otlpprofiles.Location{}
|
||||
UnmarshalJSONOrigLocation(dest, iter)
|
||||
require.NoError(t, iter.Error())
|
||||
assert.Equal(t, &otlpprofiles.Location{}, dest)
|
||||
}
|
||||
|
||||
assert.Equal(t, src, dest)
|
||||
func TestMarshalAndUnmarshalJSONOrigLocation(t *testing.T) {
|
||||
for name, src := range getEncodingTestValuesLocation() {
|
||||
t.Run(name, func(t *testing.T) {
|
||||
stream := json.BorrowStream(nil)
|
||||
defer json.ReturnStream(stream)
|
||||
MarshalJSONOrigLocation(src, stream)
|
||||
require.NoError(t, stream.Error())
|
||||
|
||||
iter := json.BorrowIterator(stream.Buffer())
|
||||
defer json.ReturnIterator(iter)
|
||||
dest := &otlpprofiles.Location{}
|
||||
UnmarshalJSONOrigLocation(dest, iter)
|
||||
require.NoError(t, iter.Error())
|
||||
|
||||
assert.Equal(t, src, dest)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestMarshalAndUnmarshalProtoOrigLocation(t *testing.T) {
|
||||
src := &otlpprofiles.Location{}
|
||||
FillOrigTestLocation(src)
|
||||
buf := make([]byte, SizeProtoOrigLocation(src))
|
||||
gotSize := MarshalProtoOrigLocation(src, buf)
|
||||
assert.Equal(t, len(buf), gotSize)
|
||||
for name, src := range getEncodingTestValuesLocation() {
|
||||
t.Run(name, func(t *testing.T) {
|
||||
buf := make([]byte, SizeProtoOrigLocation(src))
|
||||
gotSize := MarshalProtoOrigLocation(src, buf)
|
||||
assert.Equal(t, len(buf), gotSize)
|
||||
|
||||
dest := &otlpprofiles.Location{}
|
||||
require.NoError(t, UnmarshalProtoOrigLocation(dest, buf))
|
||||
assert.Equal(t, src, dest)
|
||||
dest := &otlpprofiles.Location{}
|
||||
require.NoError(t, UnmarshalProtoOrigLocation(dest, buf))
|
||||
assert.Equal(t, src, dest)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestMarshalAndUnmarshalProtoOrigEmptyLocation(t *testing.T) {
|
||||
src := &otlpprofiles.Location{}
|
||||
buf := make([]byte, SizeProtoOrigLocation(src))
|
||||
gotSize := MarshalProtoOrigLocation(src, buf)
|
||||
assert.Equal(t, len(buf), gotSize)
|
||||
|
||||
dest := &otlpprofiles.Location{}
|
||||
require.NoError(t, UnmarshalProtoOrigLocation(dest, buf))
|
||||
assert.Equal(t, src, dest)
|
||||
func getEncodingTestValuesLocation() map[string]*otlpprofiles.Location {
|
||||
return map[string]*otlpprofiles.Location{
|
||||
"empty": {},
|
||||
"fill_test": func() *otlpprofiles.Location {
|
||||
src := &otlpprofiles.Location{}
|
||||
FillOrigTestLocation(src)
|
||||
return src
|
||||
}(),
|
||||
"default_mappingindex": {MappingIndex_: &otlpprofiles.Location_MappingIndex{MappingIndex: int32(0)}},
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,46 +26,55 @@ func TestCopyOrigLogRecord(t *testing.T) {
|
|||
assert.Equal(t, src, dest)
|
||||
}
|
||||
|
||||
func TestMarshalAndUnmarshalJSONOrigLogRecord(t *testing.T) {
|
||||
src := &otlplogs.LogRecord{}
|
||||
FillOrigTestLogRecord(src)
|
||||
stream := json.BorrowStream(nil)
|
||||
defer json.ReturnStream(stream)
|
||||
MarshalJSONOrigLogRecord(src, stream)
|
||||
require.NoError(t, stream.Error())
|
||||
|
||||
// Append an unknown field at the start to ensure unknown fields are skipped
|
||||
// and the unmarshal logic continues.
|
||||
buf := stream.Buffer()
|
||||
assert.EqualValues(t, '{', buf[0])
|
||||
iter := json.BorrowIterator(append([]byte(`{"unknown": "string",`), buf[1:]...))
|
||||
func TestMarshalAndUnmarshalJSONOrigLogRecordUnknown(t *testing.T) {
|
||||
iter := json.BorrowIterator([]byte(`{"unknown": "string"}`))
|
||||
defer json.ReturnIterator(iter)
|
||||
dest := &otlplogs.LogRecord{}
|
||||
UnmarshalJSONOrigLogRecord(dest, iter)
|
||||
require.NoError(t, iter.Error())
|
||||
assert.Equal(t, &otlplogs.LogRecord{}, dest)
|
||||
}
|
||||
|
||||
assert.Equal(t, src, dest)
|
||||
func TestMarshalAndUnmarshalJSONOrigLogRecord(t *testing.T) {
|
||||
for name, src := range getEncodingTestValuesLogRecord() {
|
||||
t.Run(name, func(t *testing.T) {
|
||||
stream := json.BorrowStream(nil)
|
||||
defer json.ReturnStream(stream)
|
||||
MarshalJSONOrigLogRecord(src, stream)
|
||||
require.NoError(t, stream.Error())
|
||||
|
||||
iter := json.BorrowIterator(stream.Buffer())
|
||||
defer json.ReturnIterator(iter)
|
||||
dest := &otlplogs.LogRecord{}
|
||||
UnmarshalJSONOrigLogRecord(dest, iter)
|
||||
require.NoError(t, iter.Error())
|
||||
|
||||
assert.Equal(t, src, dest)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestMarshalAndUnmarshalProtoOrigLogRecord(t *testing.T) {
|
||||
src := &otlplogs.LogRecord{}
|
||||
FillOrigTestLogRecord(src)
|
||||
buf := make([]byte, SizeProtoOrigLogRecord(src))
|
||||
gotSize := MarshalProtoOrigLogRecord(src, buf)
|
||||
assert.Equal(t, len(buf), gotSize)
|
||||
for name, src := range getEncodingTestValuesLogRecord() {
|
||||
t.Run(name, func(t *testing.T) {
|
||||
buf := make([]byte, SizeProtoOrigLogRecord(src))
|
||||
gotSize := MarshalProtoOrigLogRecord(src, buf)
|
||||
assert.Equal(t, len(buf), gotSize)
|
||||
|
||||
dest := &otlplogs.LogRecord{}
|
||||
require.NoError(t, UnmarshalProtoOrigLogRecord(dest, buf))
|
||||
assert.Equal(t, src, dest)
|
||||
dest := &otlplogs.LogRecord{}
|
||||
require.NoError(t, UnmarshalProtoOrigLogRecord(dest, buf))
|
||||
assert.Equal(t, src, dest)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestMarshalAndUnmarshalProtoOrigEmptyLogRecord(t *testing.T) {
|
||||
src := &otlplogs.LogRecord{}
|
||||
buf := make([]byte, SizeProtoOrigLogRecord(src))
|
||||
gotSize := MarshalProtoOrigLogRecord(src, buf)
|
||||
assert.Equal(t, len(buf), gotSize)
|
||||
|
||||
dest := &otlplogs.LogRecord{}
|
||||
require.NoError(t, UnmarshalProtoOrigLogRecord(dest, buf))
|
||||
assert.Equal(t, src, dest)
|
||||
func getEncodingTestValuesLogRecord() map[string]*otlplogs.LogRecord {
|
||||
return map[string]*otlplogs.LogRecord{
|
||||
"empty": {},
|
||||
"fill_test": func() *otlplogs.LogRecord {
|
||||
src := &otlplogs.LogRecord{}
|
||||
FillOrigTestLogRecord(src)
|
||||
return src
|
||||
}(),
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,46 +26,55 @@ func TestCopyOrigMapping(t *testing.T) {
|
|||
assert.Equal(t, src, dest)
|
||||
}
|
||||
|
||||
func TestMarshalAndUnmarshalJSONOrigMapping(t *testing.T) {
|
||||
src := &otlpprofiles.Mapping{}
|
||||
FillOrigTestMapping(src)
|
||||
stream := json.BorrowStream(nil)
|
||||
defer json.ReturnStream(stream)
|
||||
MarshalJSONOrigMapping(src, stream)
|
||||
require.NoError(t, stream.Error())
|
||||
|
||||
// Append an unknown field at the start to ensure unknown fields are skipped
|
||||
// and the unmarshal logic continues.
|
||||
buf := stream.Buffer()
|
||||
assert.EqualValues(t, '{', buf[0])
|
||||
iter := json.BorrowIterator(append([]byte(`{"unknown": "string",`), buf[1:]...))
|
||||
func TestMarshalAndUnmarshalJSONOrigMappingUnknown(t *testing.T) {
|
||||
iter := json.BorrowIterator([]byte(`{"unknown": "string"}`))
|
||||
defer json.ReturnIterator(iter)
|
||||
dest := &otlpprofiles.Mapping{}
|
||||
UnmarshalJSONOrigMapping(dest, iter)
|
||||
require.NoError(t, iter.Error())
|
||||
assert.Equal(t, &otlpprofiles.Mapping{}, dest)
|
||||
}
|
||||
|
||||
assert.Equal(t, src, dest)
|
||||
func TestMarshalAndUnmarshalJSONOrigMapping(t *testing.T) {
|
||||
for name, src := range getEncodingTestValuesMapping() {
|
||||
t.Run(name, func(t *testing.T) {
|
||||
stream := json.BorrowStream(nil)
|
||||
defer json.ReturnStream(stream)
|
||||
MarshalJSONOrigMapping(src, stream)
|
||||
require.NoError(t, stream.Error())
|
||||
|
||||
iter := json.BorrowIterator(stream.Buffer())
|
||||
defer json.ReturnIterator(iter)
|
||||
dest := &otlpprofiles.Mapping{}
|
||||
UnmarshalJSONOrigMapping(dest, iter)
|
||||
require.NoError(t, iter.Error())
|
||||
|
||||
assert.Equal(t, src, dest)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestMarshalAndUnmarshalProtoOrigMapping(t *testing.T) {
|
||||
src := &otlpprofiles.Mapping{}
|
||||
FillOrigTestMapping(src)
|
||||
buf := make([]byte, SizeProtoOrigMapping(src))
|
||||
gotSize := MarshalProtoOrigMapping(src, buf)
|
||||
assert.Equal(t, len(buf), gotSize)
|
||||
for name, src := range getEncodingTestValuesMapping() {
|
||||
t.Run(name, func(t *testing.T) {
|
||||
buf := make([]byte, SizeProtoOrigMapping(src))
|
||||
gotSize := MarshalProtoOrigMapping(src, buf)
|
||||
assert.Equal(t, len(buf), gotSize)
|
||||
|
||||
dest := &otlpprofiles.Mapping{}
|
||||
require.NoError(t, UnmarshalProtoOrigMapping(dest, buf))
|
||||
assert.Equal(t, src, dest)
|
||||
dest := &otlpprofiles.Mapping{}
|
||||
require.NoError(t, UnmarshalProtoOrigMapping(dest, buf))
|
||||
assert.Equal(t, src, dest)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestMarshalAndUnmarshalProtoOrigEmptyMapping(t *testing.T) {
|
||||
src := &otlpprofiles.Mapping{}
|
||||
buf := make([]byte, SizeProtoOrigMapping(src))
|
||||
gotSize := MarshalProtoOrigMapping(src, buf)
|
||||
assert.Equal(t, len(buf), gotSize)
|
||||
|
||||
dest := &otlpprofiles.Mapping{}
|
||||
require.NoError(t, UnmarshalProtoOrigMapping(dest, buf))
|
||||
assert.Equal(t, src, dest)
|
||||
func getEncodingTestValuesMapping() map[string]*otlpprofiles.Mapping {
|
||||
return map[string]*otlpprofiles.Mapping{
|
||||
"empty": {},
|
||||
"fill_test": func() *otlpprofiles.Mapping {
|
||||
src := &otlpprofiles.Mapping{}
|
||||
FillOrigTestMapping(src)
|
||||
return src
|
||||
}(),
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,46 +26,80 @@ func TestCopyOrigMetric(t *testing.T) {
|
|||
assert.Equal(t, src, dest)
|
||||
}
|
||||
|
||||
func TestMarshalAndUnmarshalJSONOrigMetric(t *testing.T) {
|
||||
src := &otlpmetrics.Metric{}
|
||||
FillOrigTestMetric(src)
|
||||
stream := json.BorrowStream(nil)
|
||||
defer json.ReturnStream(stream)
|
||||
MarshalJSONOrigMetric(src, stream)
|
||||
require.NoError(t, stream.Error())
|
||||
|
||||
// Append an unknown field at the start to ensure unknown fields are skipped
|
||||
// and the unmarshal logic continues.
|
||||
buf := stream.Buffer()
|
||||
assert.EqualValues(t, '{', buf[0])
|
||||
iter := json.BorrowIterator(append([]byte(`{"unknown": "string",`), buf[1:]...))
|
||||
func TestMarshalAndUnmarshalJSONOrigMetricUnknown(t *testing.T) {
|
||||
iter := json.BorrowIterator([]byte(`{"unknown": "string"}`))
|
||||
defer json.ReturnIterator(iter)
|
||||
dest := &otlpmetrics.Metric{}
|
||||
UnmarshalJSONOrigMetric(dest, iter)
|
||||
require.NoError(t, iter.Error())
|
||||
assert.Equal(t, &otlpmetrics.Metric{}, dest)
|
||||
}
|
||||
|
||||
assert.Equal(t, src, dest)
|
||||
func TestMarshalAndUnmarshalJSONOrigMetric(t *testing.T) {
|
||||
for name, src := range getEncodingTestValuesMetric() {
|
||||
t.Run(name, func(t *testing.T) {
|
||||
stream := json.BorrowStream(nil)
|
||||
defer json.ReturnStream(stream)
|
||||
MarshalJSONOrigMetric(src, stream)
|
||||
require.NoError(t, stream.Error())
|
||||
|
||||
iter := json.BorrowIterator(stream.Buffer())
|
||||
defer json.ReturnIterator(iter)
|
||||
dest := &otlpmetrics.Metric{}
|
||||
UnmarshalJSONOrigMetric(dest, iter)
|
||||
require.NoError(t, iter.Error())
|
||||
|
||||
assert.Equal(t, src, dest)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestMarshalAndUnmarshalProtoOrigMetric(t *testing.T) {
|
||||
src := &otlpmetrics.Metric{}
|
||||
FillOrigTestMetric(src)
|
||||
buf := make([]byte, SizeProtoOrigMetric(src))
|
||||
gotSize := MarshalProtoOrigMetric(src, buf)
|
||||
assert.Equal(t, len(buf), gotSize)
|
||||
for name, src := range getEncodingTestValuesMetric() {
|
||||
t.Run(name, func(t *testing.T) {
|
||||
buf := make([]byte, SizeProtoOrigMetric(src))
|
||||
gotSize := MarshalProtoOrigMetric(src, buf)
|
||||
assert.Equal(t, len(buf), gotSize)
|
||||
|
||||
dest := &otlpmetrics.Metric{}
|
||||
require.NoError(t, UnmarshalProtoOrigMetric(dest, buf))
|
||||
assert.Equal(t, src, dest)
|
||||
dest := &otlpmetrics.Metric{}
|
||||
require.NoError(t, UnmarshalProtoOrigMetric(dest, buf))
|
||||
assert.Equal(t, src, dest)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestMarshalAndUnmarshalProtoOrigEmptyMetric(t *testing.T) {
|
||||
src := &otlpmetrics.Metric{}
|
||||
buf := make([]byte, SizeProtoOrigMetric(src))
|
||||
gotSize := MarshalProtoOrigMetric(src, buf)
|
||||
assert.Equal(t, len(buf), gotSize)
|
||||
|
||||
dest := &otlpmetrics.Metric{}
|
||||
require.NoError(t, UnmarshalProtoOrigMetric(dest, buf))
|
||||
assert.Equal(t, src, dest)
|
||||
func getEncodingTestValuesMetric() map[string]*otlpmetrics.Metric {
|
||||
return map[string]*otlpmetrics.Metric{
|
||||
"empty": {},
|
||||
"fill_test": func() *otlpmetrics.Metric {
|
||||
src := &otlpmetrics.Metric{}
|
||||
FillOrigTestMetric(src)
|
||||
return src
|
||||
}(),
|
||||
"oneof_gauge": {Data: func() *otlpmetrics.Metric_Gauge {
|
||||
val := &otlpmetrics.Gauge{}
|
||||
FillOrigTestGauge(val)
|
||||
return &otlpmetrics.Metric_Gauge{Gauge: val}
|
||||
}()},
|
||||
"oneof_sum": {Data: func() *otlpmetrics.Metric_Sum {
|
||||
val := &otlpmetrics.Sum{}
|
||||
FillOrigTestSum(val)
|
||||
return &otlpmetrics.Metric_Sum{Sum: val}
|
||||
}()},
|
||||
"oneof_histogram": {Data: func() *otlpmetrics.Metric_Histogram {
|
||||
val := &otlpmetrics.Histogram{}
|
||||
FillOrigTestHistogram(val)
|
||||
return &otlpmetrics.Metric_Histogram{Histogram: val}
|
||||
}()},
|
||||
"oneof_exponentialhistogram": {Data: func() *otlpmetrics.Metric_ExponentialHistogram {
|
||||
val := &otlpmetrics.ExponentialHistogram{}
|
||||
FillOrigTestExponentialHistogram(val)
|
||||
return &otlpmetrics.Metric_ExponentialHistogram{ExponentialHistogram: val}
|
||||
}()},
|
||||
"oneof_summary": {Data: func() *otlpmetrics.Metric_Summary {
|
||||
val := &otlpmetrics.Summary{}
|
||||
FillOrigTestSummary(val)
|
||||
return &otlpmetrics.Metric_Summary{Summary: val}
|
||||
}()},
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,46 +26,57 @@ func TestCopyOrigNumberDataPoint(t *testing.T) {
|
|||
assert.Equal(t, src, dest)
|
||||
}
|
||||
|
||||
func TestMarshalAndUnmarshalJSONOrigNumberDataPoint(t *testing.T) {
|
||||
src := &otlpmetrics.NumberDataPoint{}
|
||||
FillOrigTestNumberDataPoint(src)
|
||||
stream := json.BorrowStream(nil)
|
||||
defer json.ReturnStream(stream)
|
||||
MarshalJSONOrigNumberDataPoint(src, stream)
|
||||
require.NoError(t, stream.Error())
|
||||
|
||||
// Append an unknown field at the start to ensure unknown fields are skipped
|
||||
// and the unmarshal logic continues.
|
||||
buf := stream.Buffer()
|
||||
assert.EqualValues(t, '{', buf[0])
|
||||
iter := json.BorrowIterator(append([]byte(`{"unknown": "string",`), buf[1:]...))
|
||||
func TestMarshalAndUnmarshalJSONOrigNumberDataPointUnknown(t *testing.T) {
|
||||
iter := json.BorrowIterator([]byte(`{"unknown": "string"}`))
|
||||
defer json.ReturnIterator(iter)
|
||||
dest := &otlpmetrics.NumberDataPoint{}
|
||||
UnmarshalJSONOrigNumberDataPoint(dest, iter)
|
||||
require.NoError(t, iter.Error())
|
||||
assert.Equal(t, &otlpmetrics.NumberDataPoint{}, dest)
|
||||
}
|
||||
|
||||
assert.Equal(t, src, dest)
|
||||
func TestMarshalAndUnmarshalJSONOrigNumberDataPoint(t *testing.T) {
|
||||
for name, src := range getEncodingTestValuesNumberDataPoint() {
|
||||
t.Run(name, func(t *testing.T) {
|
||||
stream := json.BorrowStream(nil)
|
||||
defer json.ReturnStream(stream)
|
||||
MarshalJSONOrigNumberDataPoint(src, stream)
|
||||
require.NoError(t, stream.Error())
|
||||
|
||||
iter := json.BorrowIterator(stream.Buffer())
|
||||
defer json.ReturnIterator(iter)
|
||||
dest := &otlpmetrics.NumberDataPoint{}
|
||||
UnmarshalJSONOrigNumberDataPoint(dest, iter)
|
||||
require.NoError(t, iter.Error())
|
||||
|
||||
assert.Equal(t, src, dest)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestMarshalAndUnmarshalProtoOrigNumberDataPoint(t *testing.T) {
|
||||
src := &otlpmetrics.NumberDataPoint{}
|
||||
FillOrigTestNumberDataPoint(src)
|
||||
buf := make([]byte, SizeProtoOrigNumberDataPoint(src))
|
||||
gotSize := MarshalProtoOrigNumberDataPoint(src, buf)
|
||||
assert.Equal(t, len(buf), gotSize)
|
||||
for name, src := range getEncodingTestValuesNumberDataPoint() {
|
||||
t.Run(name, func(t *testing.T) {
|
||||
buf := make([]byte, SizeProtoOrigNumberDataPoint(src))
|
||||
gotSize := MarshalProtoOrigNumberDataPoint(src, buf)
|
||||
assert.Equal(t, len(buf), gotSize)
|
||||
|
||||
dest := &otlpmetrics.NumberDataPoint{}
|
||||
require.NoError(t, UnmarshalProtoOrigNumberDataPoint(dest, buf))
|
||||
assert.Equal(t, src, dest)
|
||||
dest := &otlpmetrics.NumberDataPoint{}
|
||||
require.NoError(t, UnmarshalProtoOrigNumberDataPoint(dest, buf))
|
||||
assert.Equal(t, src, dest)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestMarshalAndUnmarshalProtoOrigEmptyNumberDataPoint(t *testing.T) {
|
||||
src := &otlpmetrics.NumberDataPoint{}
|
||||
buf := make([]byte, SizeProtoOrigNumberDataPoint(src))
|
||||
gotSize := MarshalProtoOrigNumberDataPoint(src, buf)
|
||||
assert.Equal(t, len(buf), gotSize)
|
||||
|
||||
dest := &otlpmetrics.NumberDataPoint{}
|
||||
require.NoError(t, UnmarshalProtoOrigNumberDataPoint(dest, buf))
|
||||
assert.Equal(t, src, dest)
|
||||
func getEncodingTestValuesNumberDataPoint() map[string]*otlpmetrics.NumberDataPoint {
|
||||
return map[string]*otlpmetrics.NumberDataPoint{
|
||||
"empty": {},
|
||||
"fill_test": func() *otlpmetrics.NumberDataPoint {
|
||||
src := &otlpmetrics.NumberDataPoint{}
|
||||
FillOrigTestNumberDataPoint(src)
|
||||
return src
|
||||
}(),
|
||||
"oneof_double": {Value: &otlpmetrics.NumberDataPoint_AsDouble{AsDouble: float64(0)}},
|
||||
"oneof_int": {Value: &otlpmetrics.NumberDataPoint_AsInt{AsInt: int64(0)}},
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,46 +26,55 @@ func TestCopyOrigProfile(t *testing.T) {
|
|||
assert.Equal(t, src, dest)
|
||||
}
|
||||
|
||||
func TestMarshalAndUnmarshalJSONOrigProfile(t *testing.T) {
|
||||
src := &otlpprofiles.Profile{}
|
||||
FillOrigTestProfile(src)
|
||||
stream := json.BorrowStream(nil)
|
||||
defer json.ReturnStream(stream)
|
||||
MarshalJSONOrigProfile(src, stream)
|
||||
require.NoError(t, stream.Error())
|
||||
|
||||
// Append an unknown field at the start to ensure unknown fields are skipped
|
||||
// and the unmarshal logic continues.
|
||||
buf := stream.Buffer()
|
||||
assert.EqualValues(t, '{', buf[0])
|
||||
iter := json.BorrowIterator(append([]byte(`{"unknown": "string",`), buf[1:]...))
|
||||
func TestMarshalAndUnmarshalJSONOrigProfileUnknown(t *testing.T) {
|
||||
iter := json.BorrowIterator([]byte(`{"unknown": "string"}`))
|
||||
defer json.ReturnIterator(iter)
|
||||
dest := &otlpprofiles.Profile{}
|
||||
UnmarshalJSONOrigProfile(dest, iter)
|
||||
require.NoError(t, iter.Error())
|
||||
assert.Equal(t, &otlpprofiles.Profile{}, dest)
|
||||
}
|
||||
|
||||
assert.Equal(t, src, dest)
|
||||
func TestMarshalAndUnmarshalJSONOrigProfile(t *testing.T) {
|
||||
for name, src := range getEncodingTestValuesProfile() {
|
||||
t.Run(name, func(t *testing.T) {
|
||||
stream := json.BorrowStream(nil)
|
||||
defer json.ReturnStream(stream)
|
||||
MarshalJSONOrigProfile(src, stream)
|
||||
require.NoError(t, stream.Error())
|
||||
|
||||
iter := json.BorrowIterator(stream.Buffer())
|
||||
defer json.ReturnIterator(iter)
|
||||
dest := &otlpprofiles.Profile{}
|
||||
UnmarshalJSONOrigProfile(dest, iter)
|
||||
require.NoError(t, iter.Error())
|
||||
|
||||
assert.Equal(t, src, dest)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestMarshalAndUnmarshalProtoOrigProfile(t *testing.T) {
|
||||
src := &otlpprofiles.Profile{}
|
||||
FillOrigTestProfile(src)
|
||||
buf := make([]byte, SizeProtoOrigProfile(src))
|
||||
gotSize := MarshalProtoOrigProfile(src, buf)
|
||||
assert.Equal(t, len(buf), gotSize)
|
||||
for name, src := range getEncodingTestValuesProfile() {
|
||||
t.Run(name, func(t *testing.T) {
|
||||
buf := make([]byte, SizeProtoOrigProfile(src))
|
||||
gotSize := MarshalProtoOrigProfile(src, buf)
|
||||
assert.Equal(t, len(buf), gotSize)
|
||||
|
||||
dest := &otlpprofiles.Profile{}
|
||||
require.NoError(t, UnmarshalProtoOrigProfile(dest, buf))
|
||||
assert.Equal(t, src, dest)
|
||||
dest := &otlpprofiles.Profile{}
|
||||
require.NoError(t, UnmarshalProtoOrigProfile(dest, buf))
|
||||
assert.Equal(t, src, dest)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestMarshalAndUnmarshalProtoOrigEmptyProfile(t *testing.T) {
|
||||
src := &otlpprofiles.Profile{}
|
||||
buf := make([]byte, SizeProtoOrigProfile(src))
|
||||
gotSize := MarshalProtoOrigProfile(src, buf)
|
||||
assert.Equal(t, len(buf), gotSize)
|
||||
|
||||
dest := &otlpprofiles.Profile{}
|
||||
require.NoError(t, UnmarshalProtoOrigProfile(dest, buf))
|
||||
assert.Equal(t, src, dest)
|
||||
func getEncodingTestValuesProfile() map[string]*otlpprofiles.Profile {
|
||||
return map[string]*otlpprofiles.Profile{
|
||||
"empty": {},
|
||||
"fill_test": func() *otlpprofiles.Profile {
|
||||
src := &otlpprofiles.Profile{}
|
||||
FillOrigTestProfile(src)
|
||||
return src
|
||||
}(),
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,46 +26,55 @@ func TestCopyOrigProfilesDictionary(t *testing.T) {
|
|||
assert.Equal(t, src, dest)
|
||||
}
|
||||
|
||||
func TestMarshalAndUnmarshalJSONOrigProfilesDictionary(t *testing.T) {
|
||||
src := &otlpprofiles.ProfilesDictionary{}
|
||||
FillOrigTestProfilesDictionary(src)
|
||||
stream := json.BorrowStream(nil)
|
||||
defer json.ReturnStream(stream)
|
||||
MarshalJSONOrigProfilesDictionary(src, stream)
|
||||
require.NoError(t, stream.Error())
|
||||
|
||||
// Append an unknown field at the start to ensure unknown fields are skipped
|
||||
// and the unmarshal logic continues.
|
||||
buf := stream.Buffer()
|
||||
assert.EqualValues(t, '{', buf[0])
|
||||
iter := json.BorrowIterator(append([]byte(`{"unknown": "string",`), buf[1:]...))
|
||||
func TestMarshalAndUnmarshalJSONOrigProfilesDictionaryUnknown(t *testing.T) {
|
||||
iter := json.BorrowIterator([]byte(`{"unknown": "string"}`))
|
||||
defer json.ReturnIterator(iter)
|
||||
dest := &otlpprofiles.ProfilesDictionary{}
|
||||
UnmarshalJSONOrigProfilesDictionary(dest, iter)
|
||||
require.NoError(t, iter.Error())
|
||||
assert.Equal(t, &otlpprofiles.ProfilesDictionary{}, dest)
|
||||
}
|
||||
|
||||
assert.Equal(t, src, dest)
|
||||
func TestMarshalAndUnmarshalJSONOrigProfilesDictionary(t *testing.T) {
|
||||
for name, src := range getEncodingTestValuesProfilesDictionary() {
|
||||
t.Run(name, func(t *testing.T) {
|
||||
stream := json.BorrowStream(nil)
|
||||
defer json.ReturnStream(stream)
|
||||
MarshalJSONOrigProfilesDictionary(src, stream)
|
||||
require.NoError(t, stream.Error())
|
||||
|
||||
iter := json.BorrowIterator(stream.Buffer())
|
||||
defer json.ReturnIterator(iter)
|
||||
dest := &otlpprofiles.ProfilesDictionary{}
|
||||
UnmarshalJSONOrigProfilesDictionary(dest, iter)
|
||||
require.NoError(t, iter.Error())
|
||||
|
||||
assert.Equal(t, src, dest)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestMarshalAndUnmarshalProtoOrigProfilesDictionary(t *testing.T) {
|
||||
src := &otlpprofiles.ProfilesDictionary{}
|
||||
FillOrigTestProfilesDictionary(src)
|
||||
buf := make([]byte, SizeProtoOrigProfilesDictionary(src))
|
||||
gotSize := MarshalProtoOrigProfilesDictionary(src, buf)
|
||||
assert.Equal(t, len(buf), gotSize)
|
||||
for name, src := range getEncodingTestValuesProfilesDictionary() {
|
||||
t.Run(name, func(t *testing.T) {
|
||||
buf := make([]byte, SizeProtoOrigProfilesDictionary(src))
|
||||
gotSize := MarshalProtoOrigProfilesDictionary(src, buf)
|
||||
assert.Equal(t, len(buf), gotSize)
|
||||
|
||||
dest := &otlpprofiles.ProfilesDictionary{}
|
||||
require.NoError(t, UnmarshalProtoOrigProfilesDictionary(dest, buf))
|
||||
assert.Equal(t, src, dest)
|
||||
dest := &otlpprofiles.ProfilesDictionary{}
|
||||
require.NoError(t, UnmarshalProtoOrigProfilesDictionary(dest, buf))
|
||||
assert.Equal(t, src, dest)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestMarshalAndUnmarshalProtoOrigEmptyProfilesDictionary(t *testing.T) {
|
||||
src := &otlpprofiles.ProfilesDictionary{}
|
||||
buf := make([]byte, SizeProtoOrigProfilesDictionary(src))
|
||||
gotSize := MarshalProtoOrigProfilesDictionary(src, buf)
|
||||
assert.Equal(t, len(buf), gotSize)
|
||||
|
||||
dest := &otlpprofiles.ProfilesDictionary{}
|
||||
require.NoError(t, UnmarshalProtoOrigProfilesDictionary(dest, buf))
|
||||
assert.Equal(t, src, dest)
|
||||
func getEncodingTestValuesProfilesDictionary() map[string]*otlpprofiles.ProfilesDictionary {
|
||||
return map[string]*otlpprofiles.ProfilesDictionary{
|
||||
"empty": {},
|
||||
"fill_test": func() *otlpprofiles.ProfilesDictionary {
|
||||
src := &otlpprofiles.ProfilesDictionary{}
|
||||
FillOrigTestProfilesDictionary(src)
|
||||
return src
|
||||
}(),
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,46 +26,55 @@ func TestCopyOrigResource(t *testing.T) {
|
|||
assert.Equal(t, src, dest)
|
||||
}
|
||||
|
||||
func TestMarshalAndUnmarshalJSONOrigResource(t *testing.T) {
|
||||
src := &otlpresource.Resource{}
|
||||
FillOrigTestResource(src)
|
||||
stream := json.BorrowStream(nil)
|
||||
defer json.ReturnStream(stream)
|
||||
MarshalJSONOrigResource(src, stream)
|
||||
require.NoError(t, stream.Error())
|
||||
|
||||
// Append an unknown field at the start to ensure unknown fields are skipped
|
||||
// and the unmarshal logic continues.
|
||||
buf := stream.Buffer()
|
||||
assert.EqualValues(t, '{', buf[0])
|
||||
iter := json.BorrowIterator(append([]byte(`{"unknown": "string",`), buf[1:]...))
|
||||
func TestMarshalAndUnmarshalJSONOrigResourceUnknown(t *testing.T) {
|
||||
iter := json.BorrowIterator([]byte(`{"unknown": "string"}`))
|
||||
defer json.ReturnIterator(iter)
|
||||
dest := &otlpresource.Resource{}
|
||||
UnmarshalJSONOrigResource(dest, iter)
|
||||
require.NoError(t, iter.Error())
|
||||
assert.Equal(t, &otlpresource.Resource{}, dest)
|
||||
}
|
||||
|
||||
assert.Equal(t, src, dest)
|
||||
func TestMarshalAndUnmarshalJSONOrigResource(t *testing.T) {
|
||||
for name, src := range getEncodingTestValuesResource() {
|
||||
t.Run(name, func(t *testing.T) {
|
||||
stream := json.BorrowStream(nil)
|
||||
defer json.ReturnStream(stream)
|
||||
MarshalJSONOrigResource(src, stream)
|
||||
require.NoError(t, stream.Error())
|
||||
|
||||
iter := json.BorrowIterator(stream.Buffer())
|
||||
defer json.ReturnIterator(iter)
|
||||
dest := &otlpresource.Resource{}
|
||||
UnmarshalJSONOrigResource(dest, iter)
|
||||
require.NoError(t, iter.Error())
|
||||
|
||||
assert.Equal(t, src, dest)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestMarshalAndUnmarshalProtoOrigResource(t *testing.T) {
|
||||
src := &otlpresource.Resource{}
|
||||
FillOrigTestResource(src)
|
||||
buf := make([]byte, SizeProtoOrigResource(src))
|
||||
gotSize := MarshalProtoOrigResource(src, buf)
|
||||
assert.Equal(t, len(buf), gotSize)
|
||||
for name, src := range getEncodingTestValuesResource() {
|
||||
t.Run(name, func(t *testing.T) {
|
||||
buf := make([]byte, SizeProtoOrigResource(src))
|
||||
gotSize := MarshalProtoOrigResource(src, buf)
|
||||
assert.Equal(t, len(buf), gotSize)
|
||||
|
||||
dest := &otlpresource.Resource{}
|
||||
require.NoError(t, UnmarshalProtoOrigResource(dest, buf))
|
||||
assert.Equal(t, src, dest)
|
||||
dest := &otlpresource.Resource{}
|
||||
require.NoError(t, UnmarshalProtoOrigResource(dest, buf))
|
||||
assert.Equal(t, src, dest)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestMarshalAndUnmarshalProtoOrigEmptyResource(t *testing.T) {
|
||||
src := &otlpresource.Resource{}
|
||||
buf := make([]byte, SizeProtoOrigResource(src))
|
||||
gotSize := MarshalProtoOrigResource(src, buf)
|
||||
assert.Equal(t, len(buf), gotSize)
|
||||
|
||||
dest := &otlpresource.Resource{}
|
||||
require.NoError(t, UnmarshalProtoOrigResource(dest, buf))
|
||||
assert.Equal(t, src, dest)
|
||||
func getEncodingTestValuesResource() map[string]*otlpresource.Resource {
|
||||
return map[string]*otlpresource.Resource{
|
||||
"empty": {},
|
||||
"fill_test": func() *otlpresource.Resource {
|
||||
src := &otlpresource.Resource{}
|
||||
FillOrigTestResource(src)
|
||||
return src
|
||||
}(),
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,46 +26,55 @@ func TestCopyOrigResourceLogs(t *testing.T) {
|
|||
assert.Equal(t, src, dest)
|
||||
}
|
||||
|
||||
func TestMarshalAndUnmarshalJSONOrigResourceLogs(t *testing.T) {
|
||||
src := &otlplogs.ResourceLogs{}
|
||||
FillOrigTestResourceLogs(src)
|
||||
stream := json.BorrowStream(nil)
|
||||
defer json.ReturnStream(stream)
|
||||
MarshalJSONOrigResourceLogs(src, stream)
|
||||
require.NoError(t, stream.Error())
|
||||
|
||||
// Append an unknown field at the start to ensure unknown fields are skipped
|
||||
// and the unmarshal logic continues.
|
||||
buf := stream.Buffer()
|
||||
assert.EqualValues(t, '{', buf[0])
|
||||
iter := json.BorrowIterator(append([]byte(`{"unknown": "string",`), buf[1:]...))
|
||||
func TestMarshalAndUnmarshalJSONOrigResourceLogsUnknown(t *testing.T) {
|
||||
iter := json.BorrowIterator([]byte(`{"unknown": "string"}`))
|
||||
defer json.ReturnIterator(iter)
|
||||
dest := &otlplogs.ResourceLogs{}
|
||||
UnmarshalJSONOrigResourceLogs(dest, iter)
|
||||
require.NoError(t, iter.Error())
|
||||
assert.Equal(t, &otlplogs.ResourceLogs{}, dest)
|
||||
}
|
||||
|
||||
assert.Equal(t, src, dest)
|
||||
func TestMarshalAndUnmarshalJSONOrigResourceLogs(t *testing.T) {
|
||||
for name, src := range getEncodingTestValuesResourceLogs() {
|
||||
t.Run(name, func(t *testing.T) {
|
||||
stream := json.BorrowStream(nil)
|
||||
defer json.ReturnStream(stream)
|
||||
MarshalJSONOrigResourceLogs(src, stream)
|
||||
require.NoError(t, stream.Error())
|
||||
|
||||
iter := json.BorrowIterator(stream.Buffer())
|
||||
defer json.ReturnIterator(iter)
|
||||
dest := &otlplogs.ResourceLogs{}
|
||||
UnmarshalJSONOrigResourceLogs(dest, iter)
|
||||
require.NoError(t, iter.Error())
|
||||
|
||||
assert.Equal(t, src, dest)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestMarshalAndUnmarshalProtoOrigResourceLogs(t *testing.T) {
|
||||
src := &otlplogs.ResourceLogs{}
|
||||
FillOrigTestResourceLogs(src)
|
||||
buf := make([]byte, SizeProtoOrigResourceLogs(src))
|
||||
gotSize := MarshalProtoOrigResourceLogs(src, buf)
|
||||
assert.Equal(t, len(buf), gotSize)
|
||||
for name, src := range getEncodingTestValuesResourceLogs() {
|
||||
t.Run(name, func(t *testing.T) {
|
||||
buf := make([]byte, SizeProtoOrigResourceLogs(src))
|
||||
gotSize := MarshalProtoOrigResourceLogs(src, buf)
|
||||
assert.Equal(t, len(buf), gotSize)
|
||||
|
||||
dest := &otlplogs.ResourceLogs{}
|
||||
require.NoError(t, UnmarshalProtoOrigResourceLogs(dest, buf))
|
||||
assert.Equal(t, src, dest)
|
||||
dest := &otlplogs.ResourceLogs{}
|
||||
require.NoError(t, UnmarshalProtoOrigResourceLogs(dest, buf))
|
||||
assert.Equal(t, src, dest)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestMarshalAndUnmarshalProtoOrigEmptyResourceLogs(t *testing.T) {
|
||||
src := &otlplogs.ResourceLogs{}
|
||||
buf := make([]byte, SizeProtoOrigResourceLogs(src))
|
||||
gotSize := MarshalProtoOrigResourceLogs(src, buf)
|
||||
assert.Equal(t, len(buf), gotSize)
|
||||
|
||||
dest := &otlplogs.ResourceLogs{}
|
||||
require.NoError(t, UnmarshalProtoOrigResourceLogs(dest, buf))
|
||||
assert.Equal(t, src, dest)
|
||||
func getEncodingTestValuesResourceLogs() map[string]*otlplogs.ResourceLogs {
|
||||
return map[string]*otlplogs.ResourceLogs{
|
||||
"empty": {},
|
||||
"fill_test": func() *otlplogs.ResourceLogs {
|
||||
src := &otlplogs.ResourceLogs{}
|
||||
FillOrigTestResourceLogs(src)
|
||||
return src
|
||||
}(),
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,46 +26,55 @@ func TestCopyOrigResourceMetrics(t *testing.T) {
|
|||
assert.Equal(t, src, dest)
|
||||
}
|
||||
|
||||
func TestMarshalAndUnmarshalJSONOrigResourceMetrics(t *testing.T) {
|
||||
src := &otlpmetrics.ResourceMetrics{}
|
||||
FillOrigTestResourceMetrics(src)
|
||||
stream := json.BorrowStream(nil)
|
||||
defer json.ReturnStream(stream)
|
||||
MarshalJSONOrigResourceMetrics(src, stream)
|
||||
require.NoError(t, stream.Error())
|
||||
|
||||
// Append an unknown field at the start to ensure unknown fields are skipped
|
||||
// and the unmarshal logic continues.
|
||||
buf := stream.Buffer()
|
||||
assert.EqualValues(t, '{', buf[0])
|
||||
iter := json.BorrowIterator(append([]byte(`{"unknown": "string",`), buf[1:]...))
|
||||
func TestMarshalAndUnmarshalJSONOrigResourceMetricsUnknown(t *testing.T) {
|
||||
iter := json.BorrowIterator([]byte(`{"unknown": "string"}`))
|
||||
defer json.ReturnIterator(iter)
|
||||
dest := &otlpmetrics.ResourceMetrics{}
|
||||
UnmarshalJSONOrigResourceMetrics(dest, iter)
|
||||
require.NoError(t, iter.Error())
|
||||
assert.Equal(t, &otlpmetrics.ResourceMetrics{}, dest)
|
||||
}
|
||||
|
||||
assert.Equal(t, src, dest)
|
||||
func TestMarshalAndUnmarshalJSONOrigResourceMetrics(t *testing.T) {
|
||||
for name, src := range getEncodingTestValuesResourceMetrics() {
|
||||
t.Run(name, func(t *testing.T) {
|
||||
stream := json.BorrowStream(nil)
|
||||
defer json.ReturnStream(stream)
|
||||
MarshalJSONOrigResourceMetrics(src, stream)
|
||||
require.NoError(t, stream.Error())
|
||||
|
||||
iter := json.BorrowIterator(stream.Buffer())
|
||||
defer json.ReturnIterator(iter)
|
||||
dest := &otlpmetrics.ResourceMetrics{}
|
||||
UnmarshalJSONOrigResourceMetrics(dest, iter)
|
||||
require.NoError(t, iter.Error())
|
||||
|
||||
assert.Equal(t, src, dest)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestMarshalAndUnmarshalProtoOrigResourceMetrics(t *testing.T) {
|
||||
src := &otlpmetrics.ResourceMetrics{}
|
||||
FillOrigTestResourceMetrics(src)
|
||||
buf := make([]byte, SizeProtoOrigResourceMetrics(src))
|
||||
gotSize := MarshalProtoOrigResourceMetrics(src, buf)
|
||||
assert.Equal(t, len(buf), gotSize)
|
||||
for name, src := range getEncodingTestValuesResourceMetrics() {
|
||||
t.Run(name, func(t *testing.T) {
|
||||
buf := make([]byte, SizeProtoOrigResourceMetrics(src))
|
||||
gotSize := MarshalProtoOrigResourceMetrics(src, buf)
|
||||
assert.Equal(t, len(buf), gotSize)
|
||||
|
||||
dest := &otlpmetrics.ResourceMetrics{}
|
||||
require.NoError(t, UnmarshalProtoOrigResourceMetrics(dest, buf))
|
||||
assert.Equal(t, src, dest)
|
||||
dest := &otlpmetrics.ResourceMetrics{}
|
||||
require.NoError(t, UnmarshalProtoOrigResourceMetrics(dest, buf))
|
||||
assert.Equal(t, src, dest)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestMarshalAndUnmarshalProtoOrigEmptyResourceMetrics(t *testing.T) {
|
||||
src := &otlpmetrics.ResourceMetrics{}
|
||||
buf := make([]byte, SizeProtoOrigResourceMetrics(src))
|
||||
gotSize := MarshalProtoOrigResourceMetrics(src, buf)
|
||||
assert.Equal(t, len(buf), gotSize)
|
||||
|
||||
dest := &otlpmetrics.ResourceMetrics{}
|
||||
require.NoError(t, UnmarshalProtoOrigResourceMetrics(dest, buf))
|
||||
assert.Equal(t, src, dest)
|
||||
func getEncodingTestValuesResourceMetrics() map[string]*otlpmetrics.ResourceMetrics {
|
||||
return map[string]*otlpmetrics.ResourceMetrics{
|
||||
"empty": {},
|
||||
"fill_test": func() *otlpmetrics.ResourceMetrics {
|
||||
src := &otlpmetrics.ResourceMetrics{}
|
||||
FillOrigTestResourceMetrics(src)
|
||||
return src
|
||||
}(),
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,46 +26,55 @@ func TestCopyOrigResourceProfiles(t *testing.T) {
|
|||
assert.Equal(t, src, dest)
|
||||
}
|
||||
|
||||
func TestMarshalAndUnmarshalJSONOrigResourceProfiles(t *testing.T) {
|
||||
src := &otlpprofiles.ResourceProfiles{}
|
||||
FillOrigTestResourceProfiles(src)
|
||||
stream := json.BorrowStream(nil)
|
||||
defer json.ReturnStream(stream)
|
||||
MarshalJSONOrigResourceProfiles(src, stream)
|
||||
require.NoError(t, stream.Error())
|
||||
|
||||
// Append an unknown field at the start to ensure unknown fields are skipped
|
||||
// and the unmarshal logic continues.
|
||||
buf := stream.Buffer()
|
||||
assert.EqualValues(t, '{', buf[0])
|
||||
iter := json.BorrowIterator(append([]byte(`{"unknown": "string",`), buf[1:]...))
|
||||
func TestMarshalAndUnmarshalJSONOrigResourceProfilesUnknown(t *testing.T) {
|
||||
iter := json.BorrowIterator([]byte(`{"unknown": "string"}`))
|
||||
defer json.ReturnIterator(iter)
|
||||
dest := &otlpprofiles.ResourceProfiles{}
|
||||
UnmarshalJSONOrigResourceProfiles(dest, iter)
|
||||
require.NoError(t, iter.Error())
|
||||
assert.Equal(t, &otlpprofiles.ResourceProfiles{}, dest)
|
||||
}
|
||||
|
||||
assert.Equal(t, src, dest)
|
||||
func TestMarshalAndUnmarshalJSONOrigResourceProfiles(t *testing.T) {
|
||||
for name, src := range getEncodingTestValuesResourceProfiles() {
|
||||
t.Run(name, func(t *testing.T) {
|
||||
stream := json.BorrowStream(nil)
|
||||
defer json.ReturnStream(stream)
|
||||
MarshalJSONOrigResourceProfiles(src, stream)
|
||||
require.NoError(t, stream.Error())
|
||||
|
||||
iter := json.BorrowIterator(stream.Buffer())
|
||||
defer json.ReturnIterator(iter)
|
||||
dest := &otlpprofiles.ResourceProfiles{}
|
||||
UnmarshalJSONOrigResourceProfiles(dest, iter)
|
||||
require.NoError(t, iter.Error())
|
||||
|
||||
assert.Equal(t, src, dest)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestMarshalAndUnmarshalProtoOrigResourceProfiles(t *testing.T) {
|
||||
src := &otlpprofiles.ResourceProfiles{}
|
||||
FillOrigTestResourceProfiles(src)
|
||||
buf := make([]byte, SizeProtoOrigResourceProfiles(src))
|
||||
gotSize := MarshalProtoOrigResourceProfiles(src, buf)
|
||||
assert.Equal(t, len(buf), gotSize)
|
||||
for name, src := range getEncodingTestValuesResourceProfiles() {
|
||||
t.Run(name, func(t *testing.T) {
|
||||
buf := make([]byte, SizeProtoOrigResourceProfiles(src))
|
||||
gotSize := MarshalProtoOrigResourceProfiles(src, buf)
|
||||
assert.Equal(t, len(buf), gotSize)
|
||||
|
||||
dest := &otlpprofiles.ResourceProfiles{}
|
||||
require.NoError(t, UnmarshalProtoOrigResourceProfiles(dest, buf))
|
||||
assert.Equal(t, src, dest)
|
||||
dest := &otlpprofiles.ResourceProfiles{}
|
||||
require.NoError(t, UnmarshalProtoOrigResourceProfiles(dest, buf))
|
||||
assert.Equal(t, src, dest)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestMarshalAndUnmarshalProtoOrigEmptyResourceProfiles(t *testing.T) {
|
||||
src := &otlpprofiles.ResourceProfiles{}
|
||||
buf := make([]byte, SizeProtoOrigResourceProfiles(src))
|
||||
gotSize := MarshalProtoOrigResourceProfiles(src, buf)
|
||||
assert.Equal(t, len(buf), gotSize)
|
||||
|
||||
dest := &otlpprofiles.ResourceProfiles{}
|
||||
require.NoError(t, UnmarshalProtoOrigResourceProfiles(dest, buf))
|
||||
assert.Equal(t, src, dest)
|
||||
func getEncodingTestValuesResourceProfiles() map[string]*otlpprofiles.ResourceProfiles {
|
||||
return map[string]*otlpprofiles.ResourceProfiles{
|
||||
"empty": {},
|
||||
"fill_test": func() *otlpprofiles.ResourceProfiles {
|
||||
src := &otlpprofiles.ResourceProfiles{}
|
||||
FillOrigTestResourceProfiles(src)
|
||||
return src
|
||||
}(),
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,46 +26,55 @@ func TestCopyOrigResourceSpans(t *testing.T) {
|
|||
assert.Equal(t, src, dest)
|
||||
}
|
||||
|
||||
func TestMarshalAndUnmarshalJSONOrigResourceSpans(t *testing.T) {
|
||||
src := &otlptrace.ResourceSpans{}
|
||||
FillOrigTestResourceSpans(src)
|
||||
stream := json.BorrowStream(nil)
|
||||
defer json.ReturnStream(stream)
|
||||
MarshalJSONOrigResourceSpans(src, stream)
|
||||
require.NoError(t, stream.Error())
|
||||
|
||||
// Append an unknown field at the start to ensure unknown fields are skipped
|
||||
// and the unmarshal logic continues.
|
||||
buf := stream.Buffer()
|
||||
assert.EqualValues(t, '{', buf[0])
|
||||
iter := json.BorrowIterator(append([]byte(`{"unknown": "string",`), buf[1:]...))
|
||||
func TestMarshalAndUnmarshalJSONOrigResourceSpansUnknown(t *testing.T) {
|
||||
iter := json.BorrowIterator([]byte(`{"unknown": "string"}`))
|
||||
defer json.ReturnIterator(iter)
|
||||
dest := &otlptrace.ResourceSpans{}
|
||||
UnmarshalJSONOrigResourceSpans(dest, iter)
|
||||
require.NoError(t, iter.Error())
|
||||
assert.Equal(t, &otlptrace.ResourceSpans{}, dest)
|
||||
}
|
||||
|
||||
assert.Equal(t, src, dest)
|
||||
func TestMarshalAndUnmarshalJSONOrigResourceSpans(t *testing.T) {
|
||||
for name, src := range getEncodingTestValuesResourceSpans() {
|
||||
t.Run(name, func(t *testing.T) {
|
||||
stream := json.BorrowStream(nil)
|
||||
defer json.ReturnStream(stream)
|
||||
MarshalJSONOrigResourceSpans(src, stream)
|
||||
require.NoError(t, stream.Error())
|
||||
|
||||
iter := json.BorrowIterator(stream.Buffer())
|
||||
defer json.ReturnIterator(iter)
|
||||
dest := &otlptrace.ResourceSpans{}
|
||||
UnmarshalJSONOrigResourceSpans(dest, iter)
|
||||
require.NoError(t, iter.Error())
|
||||
|
||||
assert.Equal(t, src, dest)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestMarshalAndUnmarshalProtoOrigResourceSpans(t *testing.T) {
|
||||
src := &otlptrace.ResourceSpans{}
|
||||
FillOrigTestResourceSpans(src)
|
||||
buf := make([]byte, SizeProtoOrigResourceSpans(src))
|
||||
gotSize := MarshalProtoOrigResourceSpans(src, buf)
|
||||
assert.Equal(t, len(buf), gotSize)
|
||||
for name, src := range getEncodingTestValuesResourceSpans() {
|
||||
t.Run(name, func(t *testing.T) {
|
||||
buf := make([]byte, SizeProtoOrigResourceSpans(src))
|
||||
gotSize := MarshalProtoOrigResourceSpans(src, buf)
|
||||
assert.Equal(t, len(buf), gotSize)
|
||||
|
||||
dest := &otlptrace.ResourceSpans{}
|
||||
require.NoError(t, UnmarshalProtoOrigResourceSpans(dest, buf))
|
||||
assert.Equal(t, src, dest)
|
||||
dest := &otlptrace.ResourceSpans{}
|
||||
require.NoError(t, UnmarshalProtoOrigResourceSpans(dest, buf))
|
||||
assert.Equal(t, src, dest)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestMarshalAndUnmarshalProtoOrigEmptyResourceSpans(t *testing.T) {
|
||||
src := &otlptrace.ResourceSpans{}
|
||||
buf := make([]byte, SizeProtoOrigResourceSpans(src))
|
||||
gotSize := MarshalProtoOrigResourceSpans(src, buf)
|
||||
assert.Equal(t, len(buf), gotSize)
|
||||
|
||||
dest := &otlptrace.ResourceSpans{}
|
||||
require.NoError(t, UnmarshalProtoOrigResourceSpans(dest, buf))
|
||||
assert.Equal(t, src, dest)
|
||||
func getEncodingTestValuesResourceSpans() map[string]*otlptrace.ResourceSpans {
|
||||
return map[string]*otlptrace.ResourceSpans{
|
||||
"empty": {},
|
||||
"fill_test": func() *otlptrace.ResourceSpans {
|
||||
src := &otlptrace.ResourceSpans{}
|
||||
FillOrigTestResourceSpans(src)
|
||||
return src
|
||||
}(),
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,46 +26,56 @@ func TestCopyOrigSample(t *testing.T) {
|
|||
assert.Equal(t, src, dest)
|
||||
}
|
||||
|
||||
func TestMarshalAndUnmarshalJSONOrigSample(t *testing.T) {
|
||||
src := &otlpprofiles.Sample{}
|
||||
FillOrigTestSample(src)
|
||||
stream := json.BorrowStream(nil)
|
||||
defer json.ReturnStream(stream)
|
||||
MarshalJSONOrigSample(src, stream)
|
||||
require.NoError(t, stream.Error())
|
||||
|
||||
// Append an unknown field at the start to ensure unknown fields are skipped
|
||||
// and the unmarshal logic continues.
|
||||
buf := stream.Buffer()
|
||||
assert.EqualValues(t, '{', buf[0])
|
||||
iter := json.BorrowIterator(append([]byte(`{"unknown": "string",`), buf[1:]...))
|
||||
func TestMarshalAndUnmarshalJSONOrigSampleUnknown(t *testing.T) {
|
||||
iter := json.BorrowIterator([]byte(`{"unknown": "string"}`))
|
||||
defer json.ReturnIterator(iter)
|
||||
dest := &otlpprofiles.Sample{}
|
||||
UnmarshalJSONOrigSample(dest, iter)
|
||||
require.NoError(t, iter.Error())
|
||||
assert.Equal(t, &otlpprofiles.Sample{}, dest)
|
||||
}
|
||||
|
||||
assert.Equal(t, src, dest)
|
||||
func TestMarshalAndUnmarshalJSONOrigSample(t *testing.T) {
|
||||
for name, src := range getEncodingTestValuesSample() {
|
||||
t.Run(name, func(t *testing.T) {
|
||||
stream := json.BorrowStream(nil)
|
||||
defer json.ReturnStream(stream)
|
||||
MarshalJSONOrigSample(src, stream)
|
||||
require.NoError(t, stream.Error())
|
||||
|
||||
iter := json.BorrowIterator(stream.Buffer())
|
||||
defer json.ReturnIterator(iter)
|
||||
dest := &otlpprofiles.Sample{}
|
||||
UnmarshalJSONOrigSample(dest, iter)
|
||||
require.NoError(t, iter.Error())
|
||||
|
||||
assert.Equal(t, src, dest)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestMarshalAndUnmarshalProtoOrigSample(t *testing.T) {
|
||||
src := &otlpprofiles.Sample{}
|
||||
FillOrigTestSample(src)
|
||||
buf := make([]byte, SizeProtoOrigSample(src))
|
||||
gotSize := MarshalProtoOrigSample(src, buf)
|
||||
assert.Equal(t, len(buf), gotSize)
|
||||
for name, src := range getEncodingTestValuesSample() {
|
||||
t.Run(name, func(t *testing.T) {
|
||||
buf := make([]byte, SizeProtoOrigSample(src))
|
||||
gotSize := MarshalProtoOrigSample(src, buf)
|
||||
assert.Equal(t, len(buf), gotSize)
|
||||
|
||||
dest := &otlpprofiles.Sample{}
|
||||
require.NoError(t, UnmarshalProtoOrigSample(dest, buf))
|
||||
assert.Equal(t, src, dest)
|
||||
dest := &otlpprofiles.Sample{}
|
||||
require.NoError(t, UnmarshalProtoOrigSample(dest, buf))
|
||||
assert.Equal(t, src, dest)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestMarshalAndUnmarshalProtoOrigEmptySample(t *testing.T) {
|
||||
src := &otlpprofiles.Sample{}
|
||||
buf := make([]byte, SizeProtoOrigSample(src))
|
||||
gotSize := MarshalProtoOrigSample(src, buf)
|
||||
assert.Equal(t, len(buf), gotSize)
|
||||
|
||||
dest := &otlpprofiles.Sample{}
|
||||
require.NoError(t, UnmarshalProtoOrigSample(dest, buf))
|
||||
assert.Equal(t, src, dest)
|
||||
func getEncodingTestValuesSample() map[string]*otlpprofiles.Sample {
|
||||
return map[string]*otlpprofiles.Sample{
|
||||
"empty": {},
|
||||
"fill_test": func() *otlpprofiles.Sample {
|
||||
src := &otlpprofiles.Sample{}
|
||||
FillOrigTestSample(src)
|
||||
return src
|
||||
}(),
|
||||
"default_linkindex": {LinkIndex_: &otlpprofiles.Sample_LinkIndex{LinkIndex: int32(0)}},
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,46 +26,55 @@ func TestCopyOrigScopeLogs(t *testing.T) {
|
|||
assert.Equal(t, src, dest)
|
||||
}
|
||||
|
||||
func TestMarshalAndUnmarshalJSONOrigScopeLogs(t *testing.T) {
|
||||
src := &otlplogs.ScopeLogs{}
|
||||
FillOrigTestScopeLogs(src)
|
||||
stream := json.BorrowStream(nil)
|
||||
defer json.ReturnStream(stream)
|
||||
MarshalJSONOrigScopeLogs(src, stream)
|
||||
require.NoError(t, stream.Error())
|
||||
|
||||
// Append an unknown field at the start to ensure unknown fields are skipped
|
||||
// and the unmarshal logic continues.
|
||||
buf := stream.Buffer()
|
||||
assert.EqualValues(t, '{', buf[0])
|
||||
iter := json.BorrowIterator(append([]byte(`{"unknown": "string",`), buf[1:]...))
|
||||
func TestMarshalAndUnmarshalJSONOrigScopeLogsUnknown(t *testing.T) {
|
||||
iter := json.BorrowIterator([]byte(`{"unknown": "string"}`))
|
||||
defer json.ReturnIterator(iter)
|
||||
dest := &otlplogs.ScopeLogs{}
|
||||
UnmarshalJSONOrigScopeLogs(dest, iter)
|
||||
require.NoError(t, iter.Error())
|
||||
assert.Equal(t, &otlplogs.ScopeLogs{}, dest)
|
||||
}
|
||||
|
||||
assert.Equal(t, src, dest)
|
||||
func TestMarshalAndUnmarshalJSONOrigScopeLogs(t *testing.T) {
|
||||
for name, src := range getEncodingTestValuesScopeLogs() {
|
||||
t.Run(name, func(t *testing.T) {
|
||||
stream := json.BorrowStream(nil)
|
||||
defer json.ReturnStream(stream)
|
||||
MarshalJSONOrigScopeLogs(src, stream)
|
||||
require.NoError(t, stream.Error())
|
||||
|
||||
iter := json.BorrowIterator(stream.Buffer())
|
||||
defer json.ReturnIterator(iter)
|
||||
dest := &otlplogs.ScopeLogs{}
|
||||
UnmarshalJSONOrigScopeLogs(dest, iter)
|
||||
require.NoError(t, iter.Error())
|
||||
|
||||
assert.Equal(t, src, dest)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestMarshalAndUnmarshalProtoOrigScopeLogs(t *testing.T) {
|
||||
src := &otlplogs.ScopeLogs{}
|
||||
FillOrigTestScopeLogs(src)
|
||||
buf := make([]byte, SizeProtoOrigScopeLogs(src))
|
||||
gotSize := MarshalProtoOrigScopeLogs(src, buf)
|
||||
assert.Equal(t, len(buf), gotSize)
|
||||
for name, src := range getEncodingTestValuesScopeLogs() {
|
||||
t.Run(name, func(t *testing.T) {
|
||||
buf := make([]byte, SizeProtoOrigScopeLogs(src))
|
||||
gotSize := MarshalProtoOrigScopeLogs(src, buf)
|
||||
assert.Equal(t, len(buf), gotSize)
|
||||
|
||||
dest := &otlplogs.ScopeLogs{}
|
||||
require.NoError(t, UnmarshalProtoOrigScopeLogs(dest, buf))
|
||||
assert.Equal(t, src, dest)
|
||||
dest := &otlplogs.ScopeLogs{}
|
||||
require.NoError(t, UnmarshalProtoOrigScopeLogs(dest, buf))
|
||||
assert.Equal(t, src, dest)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestMarshalAndUnmarshalProtoOrigEmptyScopeLogs(t *testing.T) {
|
||||
src := &otlplogs.ScopeLogs{}
|
||||
buf := make([]byte, SizeProtoOrigScopeLogs(src))
|
||||
gotSize := MarshalProtoOrigScopeLogs(src, buf)
|
||||
assert.Equal(t, len(buf), gotSize)
|
||||
|
||||
dest := &otlplogs.ScopeLogs{}
|
||||
require.NoError(t, UnmarshalProtoOrigScopeLogs(dest, buf))
|
||||
assert.Equal(t, src, dest)
|
||||
func getEncodingTestValuesScopeLogs() map[string]*otlplogs.ScopeLogs {
|
||||
return map[string]*otlplogs.ScopeLogs{
|
||||
"empty": {},
|
||||
"fill_test": func() *otlplogs.ScopeLogs {
|
||||
src := &otlplogs.ScopeLogs{}
|
||||
FillOrigTestScopeLogs(src)
|
||||
return src
|
||||
}(),
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,46 +26,55 @@ func TestCopyOrigScopeMetrics(t *testing.T) {
|
|||
assert.Equal(t, src, dest)
|
||||
}
|
||||
|
||||
func TestMarshalAndUnmarshalJSONOrigScopeMetrics(t *testing.T) {
|
||||
src := &otlpmetrics.ScopeMetrics{}
|
||||
FillOrigTestScopeMetrics(src)
|
||||
stream := json.BorrowStream(nil)
|
||||
defer json.ReturnStream(stream)
|
||||
MarshalJSONOrigScopeMetrics(src, stream)
|
||||
require.NoError(t, stream.Error())
|
||||
|
||||
// Append an unknown field at the start to ensure unknown fields are skipped
|
||||
// and the unmarshal logic continues.
|
||||
buf := stream.Buffer()
|
||||
assert.EqualValues(t, '{', buf[0])
|
||||
iter := json.BorrowIterator(append([]byte(`{"unknown": "string",`), buf[1:]...))
|
||||
func TestMarshalAndUnmarshalJSONOrigScopeMetricsUnknown(t *testing.T) {
|
||||
iter := json.BorrowIterator([]byte(`{"unknown": "string"}`))
|
||||
defer json.ReturnIterator(iter)
|
||||
dest := &otlpmetrics.ScopeMetrics{}
|
||||
UnmarshalJSONOrigScopeMetrics(dest, iter)
|
||||
require.NoError(t, iter.Error())
|
||||
assert.Equal(t, &otlpmetrics.ScopeMetrics{}, dest)
|
||||
}
|
||||
|
||||
assert.Equal(t, src, dest)
|
||||
func TestMarshalAndUnmarshalJSONOrigScopeMetrics(t *testing.T) {
|
||||
for name, src := range getEncodingTestValuesScopeMetrics() {
|
||||
t.Run(name, func(t *testing.T) {
|
||||
stream := json.BorrowStream(nil)
|
||||
defer json.ReturnStream(stream)
|
||||
MarshalJSONOrigScopeMetrics(src, stream)
|
||||
require.NoError(t, stream.Error())
|
||||
|
||||
iter := json.BorrowIterator(stream.Buffer())
|
||||
defer json.ReturnIterator(iter)
|
||||
dest := &otlpmetrics.ScopeMetrics{}
|
||||
UnmarshalJSONOrigScopeMetrics(dest, iter)
|
||||
require.NoError(t, iter.Error())
|
||||
|
||||
assert.Equal(t, src, dest)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestMarshalAndUnmarshalProtoOrigScopeMetrics(t *testing.T) {
|
||||
src := &otlpmetrics.ScopeMetrics{}
|
||||
FillOrigTestScopeMetrics(src)
|
||||
buf := make([]byte, SizeProtoOrigScopeMetrics(src))
|
||||
gotSize := MarshalProtoOrigScopeMetrics(src, buf)
|
||||
assert.Equal(t, len(buf), gotSize)
|
||||
for name, src := range getEncodingTestValuesScopeMetrics() {
|
||||
t.Run(name, func(t *testing.T) {
|
||||
buf := make([]byte, SizeProtoOrigScopeMetrics(src))
|
||||
gotSize := MarshalProtoOrigScopeMetrics(src, buf)
|
||||
assert.Equal(t, len(buf), gotSize)
|
||||
|
||||
dest := &otlpmetrics.ScopeMetrics{}
|
||||
require.NoError(t, UnmarshalProtoOrigScopeMetrics(dest, buf))
|
||||
assert.Equal(t, src, dest)
|
||||
dest := &otlpmetrics.ScopeMetrics{}
|
||||
require.NoError(t, UnmarshalProtoOrigScopeMetrics(dest, buf))
|
||||
assert.Equal(t, src, dest)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestMarshalAndUnmarshalProtoOrigEmptyScopeMetrics(t *testing.T) {
|
||||
src := &otlpmetrics.ScopeMetrics{}
|
||||
buf := make([]byte, SizeProtoOrigScopeMetrics(src))
|
||||
gotSize := MarshalProtoOrigScopeMetrics(src, buf)
|
||||
assert.Equal(t, len(buf), gotSize)
|
||||
|
||||
dest := &otlpmetrics.ScopeMetrics{}
|
||||
require.NoError(t, UnmarshalProtoOrigScopeMetrics(dest, buf))
|
||||
assert.Equal(t, src, dest)
|
||||
func getEncodingTestValuesScopeMetrics() map[string]*otlpmetrics.ScopeMetrics {
|
||||
return map[string]*otlpmetrics.ScopeMetrics{
|
||||
"empty": {},
|
||||
"fill_test": func() *otlpmetrics.ScopeMetrics {
|
||||
src := &otlpmetrics.ScopeMetrics{}
|
||||
FillOrigTestScopeMetrics(src)
|
||||
return src
|
||||
}(),
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,46 +26,55 @@ func TestCopyOrigScopeProfiles(t *testing.T) {
|
|||
assert.Equal(t, src, dest)
|
||||
}
|
||||
|
||||
func TestMarshalAndUnmarshalJSONOrigScopeProfiles(t *testing.T) {
|
||||
src := &otlpprofiles.ScopeProfiles{}
|
||||
FillOrigTestScopeProfiles(src)
|
||||
stream := json.BorrowStream(nil)
|
||||
defer json.ReturnStream(stream)
|
||||
MarshalJSONOrigScopeProfiles(src, stream)
|
||||
require.NoError(t, stream.Error())
|
||||
|
||||
// Append an unknown field at the start to ensure unknown fields are skipped
|
||||
// and the unmarshal logic continues.
|
||||
buf := stream.Buffer()
|
||||
assert.EqualValues(t, '{', buf[0])
|
||||
iter := json.BorrowIterator(append([]byte(`{"unknown": "string",`), buf[1:]...))
|
||||
func TestMarshalAndUnmarshalJSONOrigScopeProfilesUnknown(t *testing.T) {
|
||||
iter := json.BorrowIterator([]byte(`{"unknown": "string"}`))
|
||||
defer json.ReturnIterator(iter)
|
||||
dest := &otlpprofiles.ScopeProfiles{}
|
||||
UnmarshalJSONOrigScopeProfiles(dest, iter)
|
||||
require.NoError(t, iter.Error())
|
||||
assert.Equal(t, &otlpprofiles.ScopeProfiles{}, dest)
|
||||
}
|
||||
|
||||
assert.Equal(t, src, dest)
|
||||
func TestMarshalAndUnmarshalJSONOrigScopeProfiles(t *testing.T) {
|
||||
for name, src := range getEncodingTestValuesScopeProfiles() {
|
||||
t.Run(name, func(t *testing.T) {
|
||||
stream := json.BorrowStream(nil)
|
||||
defer json.ReturnStream(stream)
|
||||
MarshalJSONOrigScopeProfiles(src, stream)
|
||||
require.NoError(t, stream.Error())
|
||||
|
||||
iter := json.BorrowIterator(stream.Buffer())
|
||||
defer json.ReturnIterator(iter)
|
||||
dest := &otlpprofiles.ScopeProfiles{}
|
||||
UnmarshalJSONOrigScopeProfiles(dest, iter)
|
||||
require.NoError(t, iter.Error())
|
||||
|
||||
assert.Equal(t, src, dest)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestMarshalAndUnmarshalProtoOrigScopeProfiles(t *testing.T) {
|
||||
src := &otlpprofiles.ScopeProfiles{}
|
||||
FillOrigTestScopeProfiles(src)
|
||||
buf := make([]byte, SizeProtoOrigScopeProfiles(src))
|
||||
gotSize := MarshalProtoOrigScopeProfiles(src, buf)
|
||||
assert.Equal(t, len(buf), gotSize)
|
||||
for name, src := range getEncodingTestValuesScopeProfiles() {
|
||||
t.Run(name, func(t *testing.T) {
|
||||
buf := make([]byte, SizeProtoOrigScopeProfiles(src))
|
||||
gotSize := MarshalProtoOrigScopeProfiles(src, buf)
|
||||
assert.Equal(t, len(buf), gotSize)
|
||||
|
||||
dest := &otlpprofiles.ScopeProfiles{}
|
||||
require.NoError(t, UnmarshalProtoOrigScopeProfiles(dest, buf))
|
||||
assert.Equal(t, src, dest)
|
||||
dest := &otlpprofiles.ScopeProfiles{}
|
||||
require.NoError(t, UnmarshalProtoOrigScopeProfiles(dest, buf))
|
||||
assert.Equal(t, src, dest)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestMarshalAndUnmarshalProtoOrigEmptyScopeProfiles(t *testing.T) {
|
||||
src := &otlpprofiles.ScopeProfiles{}
|
||||
buf := make([]byte, SizeProtoOrigScopeProfiles(src))
|
||||
gotSize := MarshalProtoOrigScopeProfiles(src, buf)
|
||||
assert.Equal(t, len(buf), gotSize)
|
||||
|
||||
dest := &otlpprofiles.ScopeProfiles{}
|
||||
require.NoError(t, UnmarshalProtoOrigScopeProfiles(dest, buf))
|
||||
assert.Equal(t, src, dest)
|
||||
func getEncodingTestValuesScopeProfiles() map[string]*otlpprofiles.ScopeProfiles {
|
||||
return map[string]*otlpprofiles.ScopeProfiles{
|
||||
"empty": {},
|
||||
"fill_test": func() *otlpprofiles.ScopeProfiles {
|
||||
src := &otlpprofiles.ScopeProfiles{}
|
||||
FillOrigTestScopeProfiles(src)
|
||||
return src
|
||||
}(),
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,46 +26,55 @@ func TestCopyOrigScopeSpans(t *testing.T) {
|
|||
assert.Equal(t, src, dest)
|
||||
}
|
||||
|
||||
func TestMarshalAndUnmarshalJSONOrigScopeSpans(t *testing.T) {
|
||||
src := &otlptrace.ScopeSpans{}
|
||||
FillOrigTestScopeSpans(src)
|
||||
stream := json.BorrowStream(nil)
|
||||
defer json.ReturnStream(stream)
|
||||
MarshalJSONOrigScopeSpans(src, stream)
|
||||
require.NoError(t, stream.Error())
|
||||
|
||||
// Append an unknown field at the start to ensure unknown fields are skipped
|
||||
// and the unmarshal logic continues.
|
||||
buf := stream.Buffer()
|
||||
assert.EqualValues(t, '{', buf[0])
|
||||
iter := json.BorrowIterator(append([]byte(`{"unknown": "string",`), buf[1:]...))
|
||||
func TestMarshalAndUnmarshalJSONOrigScopeSpansUnknown(t *testing.T) {
|
||||
iter := json.BorrowIterator([]byte(`{"unknown": "string"}`))
|
||||
defer json.ReturnIterator(iter)
|
||||
dest := &otlptrace.ScopeSpans{}
|
||||
UnmarshalJSONOrigScopeSpans(dest, iter)
|
||||
require.NoError(t, iter.Error())
|
||||
assert.Equal(t, &otlptrace.ScopeSpans{}, dest)
|
||||
}
|
||||
|
||||
assert.Equal(t, src, dest)
|
||||
func TestMarshalAndUnmarshalJSONOrigScopeSpans(t *testing.T) {
|
||||
for name, src := range getEncodingTestValuesScopeSpans() {
|
||||
t.Run(name, func(t *testing.T) {
|
||||
stream := json.BorrowStream(nil)
|
||||
defer json.ReturnStream(stream)
|
||||
MarshalJSONOrigScopeSpans(src, stream)
|
||||
require.NoError(t, stream.Error())
|
||||
|
||||
iter := json.BorrowIterator(stream.Buffer())
|
||||
defer json.ReturnIterator(iter)
|
||||
dest := &otlptrace.ScopeSpans{}
|
||||
UnmarshalJSONOrigScopeSpans(dest, iter)
|
||||
require.NoError(t, iter.Error())
|
||||
|
||||
assert.Equal(t, src, dest)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestMarshalAndUnmarshalProtoOrigScopeSpans(t *testing.T) {
|
||||
src := &otlptrace.ScopeSpans{}
|
||||
FillOrigTestScopeSpans(src)
|
||||
buf := make([]byte, SizeProtoOrigScopeSpans(src))
|
||||
gotSize := MarshalProtoOrigScopeSpans(src, buf)
|
||||
assert.Equal(t, len(buf), gotSize)
|
||||
for name, src := range getEncodingTestValuesScopeSpans() {
|
||||
t.Run(name, func(t *testing.T) {
|
||||
buf := make([]byte, SizeProtoOrigScopeSpans(src))
|
||||
gotSize := MarshalProtoOrigScopeSpans(src, buf)
|
||||
assert.Equal(t, len(buf), gotSize)
|
||||
|
||||
dest := &otlptrace.ScopeSpans{}
|
||||
require.NoError(t, UnmarshalProtoOrigScopeSpans(dest, buf))
|
||||
assert.Equal(t, src, dest)
|
||||
dest := &otlptrace.ScopeSpans{}
|
||||
require.NoError(t, UnmarshalProtoOrigScopeSpans(dest, buf))
|
||||
assert.Equal(t, src, dest)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestMarshalAndUnmarshalProtoOrigEmptyScopeSpans(t *testing.T) {
|
||||
src := &otlptrace.ScopeSpans{}
|
||||
buf := make([]byte, SizeProtoOrigScopeSpans(src))
|
||||
gotSize := MarshalProtoOrigScopeSpans(src, buf)
|
||||
assert.Equal(t, len(buf), gotSize)
|
||||
|
||||
dest := &otlptrace.ScopeSpans{}
|
||||
require.NoError(t, UnmarshalProtoOrigScopeSpans(dest, buf))
|
||||
assert.Equal(t, src, dest)
|
||||
func getEncodingTestValuesScopeSpans() map[string]*otlptrace.ScopeSpans {
|
||||
return map[string]*otlptrace.ScopeSpans{
|
||||
"empty": {},
|
||||
"fill_test": func() *otlptrace.ScopeSpans {
|
||||
src := &otlptrace.ScopeSpans{}
|
||||
FillOrigTestScopeSpans(src)
|
||||
return src
|
||||
}(),
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,46 +26,55 @@ func TestCopyOrigSpan_Event(t *testing.T) {
|
|||
assert.Equal(t, src, dest)
|
||||
}
|
||||
|
||||
func TestMarshalAndUnmarshalJSONOrigSpan_Event(t *testing.T) {
|
||||
src := &otlptrace.Span_Event{}
|
||||
FillOrigTestSpan_Event(src)
|
||||
stream := json.BorrowStream(nil)
|
||||
defer json.ReturnStream(stream)
|
||||
MarshalJSONOrigSpan_Event(src, stream)
|
||||
require.NoError(t, stream.Error())
|
||||
|
||||
// Append an unknown field at the start to ensure unknown fields are skipped
|
||||
// and the unmarshal logic continues.
|
||||
buf := stream.Buffer()
|
||||
assert.EqualValues(t, '{', buf[0])
|
||||
iter := json.BorrowIterator(append([]byte(`{"unknown": "string",`), buf[1:]...))
|
||||
func TestMarshalAndUnmarshalJSONOrigSpan_EventUnknown(t *testing.T) {
|
||||
iter := json.BorrowIterator([]byte(`{"unknown": "string"}`))
|
||||
defer json.ReturnIterator(iter)
|
||||
dest := &otlptrace.Span_Event{}
|
||||
UnmarshalJSONOrigSpan_Event(dest, iter)
|
||||
require.NoError(t, iter.Error())
|
||||
assert.Equal(t, &otlptrace.Span_Event{}, dest)
|
||||
}
|
||||
|
||||
assert.Equal(t, src, dest)
|
||||
func TestMarshalAndUnmarshalJSONOrigSpan_Event(t *testing.T) {
|
||||
for name, src := range getEncodingTestValuesSpan_Event() {
|
||||
t.Run(name, func(t *testing.T) {
|
||||
stream := json.BorrowStream(nil)
|
||||
defer json.ReturnStream(stream)
|
||||
MarshalJSONOrigSpan_Event(src, stream)
|
||||
require.NoError(t, stream.Error())
|
||||
|
||||
iter := json.BorrowIterator(stream.Buffer())
|
||||
defer json.ReturnIterator(iter)
|
||||
dest := &otlptrace.Span_Event{}
|
||||
UnmarshalJSONOrigSpan_Event(dest, iter)
|
||||
require.NoError(t, iter.Error())
|
||||
|
||||
assert.Equal(t, src, dest)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestMarshalAndUnmarshalProtoOrigSpan_Event(t *testing.T) {
|
||||
src := &otlptrace.Span_Event{}
|
||||
FillOrigTestSpan_Event(src)
|
||||
buf := make([]byte, SizeProtoOrigSpan_Event(src))
|
||||
gotSize := MarshalProtoOrigSpan_Event(src, buf)
|
||||
assert.Equal(t, len(buf), gotSize)
|
||||
for name, src := range getEncodingTestValuesSpan_Event() {
|
||||
t.Run(name, func(t *testing.T) {
|
||||
buf := make([]byte, SizeProtoOrigSpan_Event(src))
|
||||
gotSize := MarshalProtoOrigSpan_Event(src, buf)
|
||||
assert.Equal(t, len(buf), gotSize)
|
||||
|
||||
dest := &otlptrace.Span_Event{}
|
||||
require.NoError(t, UnmarshalProtoOrigSpan_Event(dest, buf))
|
||||
assert.Equal(t, src, dest)
|
||||
dest := &otlptrace.Span_Event{}
|
||||
require.NoError(t, UnmarshalProtoOrigSpan_Event(dest, buf))
|
||||
assert.Equal(t, src, dest)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestMarshalAndUnmarshalProtoOrigEmptySpan_Event(t *testing.T) {
|
||||
src := &otlptrace.Span_Event{}
|
||||
buf := make([]byte, SizeProtoOrigSpan_Event(src))
|
||||
gotSize := MarshalProtoOrigSpan_Event(src, buf)
|
||||
assert.Equal(t, len(buf), gotSize)
|
||||
|
||||
dest := &otlptrace.Span_Event{}
|
||||
require.NoError(t, UnmarshalProtoOrigSpan_Event(dest, buf))
|
||||
assert.Equal(t, src, dest)
|
||||
func getEncodingTestValuesSpan_Event() map[string]*otlptrace.Span_Event {
|
||||
return map[string]*otlptrace.Span_Event{
|
||||
"empty": {},
|
||||
"fill_test": func() *otlptrace.Span_Event {
|
||||
src := &otlptrace.Span_Event{}
|
||||
FillOrigTestSpan_Event(src)
|
||||
return src
|
||||
}(),
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,46 +26,55 @@ func TestCopyOrigSpan_Link(t *testing.T) {
|
|||
assert.Equal(t, src, dest)
|
||||
}
|
||||
|
||||
func TestMarshalAndUnmarshalJSONOrigSpan_Link(t *testing.T) {
|
||||
src := &otlptrace.Span_Link{}
|
||||
FillOrigTestSpan_Link(src)
|
||||
stream := json.BorrowStream(nil)
|
||||
defer json.ReturnStream(stream)
|
||||
MarshalJSONOrigSpan_Link(src, stream)
|
||||
require.NoError(t, stream.Error())
|
||||
|
||||
// Append an unknown field at the start to ensure unknown fields are skipped
|
||||
// and the unmarshal logic continues.
|
||||
buf := stream.Buffer()
|
||||
assert.EqualValues(t, '{', buf[0])
|
||||
iter := json.BorrowIterator(append([]byte(`{"unknown": "string",`), buf[1:]...))
|
||||
func TestMarshalAndUnmarshalJSONOrigSpan_LinkUnknown(t *testing.T) {
|
||||
iter := json.BorrowIterator([]byte(`{"unknown": "string"}`))
|
||||
defer json.ReturnIterator(iter)
|
||||
dest := &otlptrace.Span_Link{}
|
||||
UnmarshalJSONOrigSpan_Link(dest, iter)
|
||||
require.NoError(t, iter.Error())
|
||||
assert.Equal(t, &otlptrace.Span_Link{}, dest)
|
||||
}
|
||||
|
||||
assert.Equal(t, src, dest)
|
||||
func TestMarshalAndUnmarshalJSONOrigSpan_Link(t *testing.T) {
|
||||
for name, src := range getEncodingTestValuesSpan_Link() {
|
||||
t.Run(name, func(t *testing.T) {
|
||||
stream := json.BorrowStream(nil)
|
||||
defer json.ReturnStream(stream)
|
||||
MarshalJSONOrigSpan_Link(src, stream)
|
||||
require.NoError(t, stream.Error())
|
||||
|
||||
iter := json.BorrowIterator(stream.Buffer())
|
||||
defer json.ReturnIterator(iter)
|
||||
dest := &otlptrace.Span_Link{}
|
||||
UnmarshalJSONOrigSpan_Link(dest, iter)
|
||||
require.NoError(t, iter.Error())
|
||||
|
||||
assert.Equal(t, src, dest)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestMarshalAndUnmarshalProtoOrigSpan_Link(t *testing.T) {
|
||||
src := &otlptrace.Span_Link{}
|
||||
FillOrigTestSpan_Link(src)
|
||||
buf := make([]byte, SizeProtoOrigSpan_Link(src))
|
||||
gotSize := MarshalProtoOrigSpan_Link(src, buf)
|
||||
assert.Equal(t, len(buf), gotSize)
|
||||
for name, src := range getEncodingTestValuesSpan_Link() {
|
||||
t.Run(name, func(t *testing.T) {
|
||||
buf := make([]byte, SizeProtoOrigSpan_Link(src))
|
||||
gotSize := MarshalProtoOrigSpan_Link(src, buf)
|
||||
assert.Equal(t, len(buf), gotSize)
|
||||
|
||||
dest := &otlptrace.Span_Link{}
|
||||
require.NoError(t, UnmarshalProtoOrigSpan_Link(dest, buf))
|
||||
assert.Equal(t, src, dest)
|
||||
dest := &otlptrace.Span_Link{}
|
||||
require.NoError(t, UnmarshalProtoOrigSpan_Link(dest, buf))
|
||||
assert.Equal(t, src, dest)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestMarshalAndUnmarshalProtoOrigEmptySpan_Link(t *testing.T) {
|
||||
src := &otlptrace.Span_Link{}
|
||||
buf := make([]byte, SizeProtoOrigSpan_Link(src))
|
||||
gotSize := MarshalProtoOrigSpan_Link(src, buf)
|
||||
assert.Equal(t, len(buf), gotSize)
|
||||
|
||||
dest := &otlptrace.Span_Link{}
|
||||
require.NoError(t, UnmarshalProtoOrigSpan_Link(dest, buf))
|
||||
assert.Equal(t, src, dest)
|
||||
func getEncodingTestValuesSpan_Link() map[string]*otlptrace.Span_Link {
|
||||
return map[string]*otlptrace.Span_Link{
|
||||
"empty": {},
|
||||
"fill_test": func() *otlptrace.Span_Link {
|
||||
src := &otlptrace.Span_Link{}
|
||||
FillOrigTestSpan_Link(src)
|
||||
return src
|
||||
}(),
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,46 +26,55 @@ func TestCopyOrigSpan(t *testing.T) {
|
|||
assert.Equal(t, src, dest)
|
||||
}
|
||||
|
||||
func TestMarshalAndUnmarshalJSONOrigSpan(t *testing.T) {
|
||||
src := &otlptrace.Span{}
|
||||
FillOrigTestSpan(src)
|
||||
stream := json.BorrowStream(nil)
|
||||
defer json.ReturnStream(stream)
|
||||
MarshalJSONOrigSpan(src, stream)
|
||||
require.NoError(t, stream.Error())
|
||||
|
||||
// Append an unknown field at the start to ensure unknown fields are skipped
|
||||
// and the unmarshal logic continues.
|
||||
buf := stream.Buffer()
|
||||
assert.EqualValues(t, '{', buf[0])
|
||||
iter := json.BorrowIterator(append([]byte(`{"unknown": "string",`), buf[1:]...))
|
||||
func TestMarshalAndUnmarshalJSONOrigSpanUnknown(t *testing.T) {
|
||||
iter := json.BorrowIterator([]byte(`{"unknown": "string"}`))
|
||||
defer json.ReturnIterator(iter)
|
||||
dest := &otlptrace.Span{}
|
||||
UnmarshalJSONOrigSpan(dest, iter)
|
||||
require.NoError(t, iter.Error())
|
||||
assert.Equal(t, &otlptrace.Span{}, dest)
|
||||
}
|
||||
|
||||
assert.Equal(t, src, dest)
|
||||
func TestMarshalAndUnmarshalJSONOrigSpan(t *testing.T) {
|
||||
for name, src := range getEncodingTestValuesSpan() {
|
||||
t.Run(name, func(t *testing.T) {
|
||||
stream := json.BorrowStream(nil)
|
||||
defer json.ReturnStream(stream)
|
||||
MarshalJSONOrigSpan(src, stream)
|
||||
require.NoError(t, stream.Error())
|
||||
|
||||
iter := json.BorrowIterator(stream.Buffer())
|
||||
defer json.ReturnIterator(iter)
|
||||
dest := &otlptrace.Span{}
|
||||
UnmarshalJSONOrigSpan(dest, iter)
|
||||
require.NoError(t, iter.Error())
|
||||
|
||||
assert.Equal(t, src, dest)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestMarshalAndUnmarshalProtoOrigSpan(t *testing.T) {
|
||||
src := &otlptrace.Span{}
|
||||
FillOrigTestSpan(src)
|
||||
buf := make([]byte, SizeProtoOrigSpan(src))
|
||||
gotSize := MarshalProtoOrigSpan(src, buf)
|
||||
assert.Equal(t, len(buf), gotSize)
|
||||
for name, src := range getEncodingTestValuesSpan() {
|
||||
t.Run(name, func(t *testing.T) {
|
||||
buf := make([]byte, SizeProtoOrigSpan(src))
|
||||
gotSize := MarshalProtoOrigSpan(src, buf)
|
||||
assert.Equal(t, len(buf), gotSize)
|
||||
|
||||
dest := &otlptrace.Span{}
|
||||
require.NoError(t, UnmarshalProtoOrigSpan(dest, buf))
|
||||
assert.Equal(t, src, dest)
|
||||
dest := &otlptrace.Span{}
|
||||
require.NoError(t, UnmarshalProtoOrigSpan(dest, buf))
|
||||
assert.Equal(t, src, dest)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestMarshalAndUnmarshalProtoOrigEmptySpan(t *testing.T) {
|
||||
src := &otlptrace.Span{}
|
||||
buf := make([]byte, SizeProtoOrigSpan(src))
|
||||
gotSize := MarshalProtoOrigSpan(src, buf)
|
||||
assert.Equal(t, len(buf), gotSize)
|
||||
|
||||
dest := &otlptrace.Span{}
|
||||
require.NoError(t, UnmarshalProtoOrigSpan(dest, buf))
|
||||
assert.Equal(t, src, dest)
|
||||
func getEncodingTestValuesSpan() map[string]*otlptrace.Span {
|
||||
return map[string]*otlptrace.Span{
|
||||
"empty": {},
|
||||
"fill_test": func() *otlptrace.Span {
|
||||
src := &otlptrace.Span{}
|
||||
FillOrigTestSpan(src)
|
||||
return src
|
||||
}(),
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,46 +26,55 @@ func TestCopyOrigStatus(t *testing.T) {
|
|||
assert.Equal(t, src, dest)
|
||||
}
|
||||
|
||||
func TestMarshalAndUnmarshalJSONOrigStatus(t *testing.T) {
|
||||
src := &otlptrace.Status{}
|
||||
FillOrigTestStatus(src)
|
||||
stream := json.BorrowStream(nil)
|
||||
defer json.ReturnStream(stream)
|
||||
MarshalJSONOrigStatus(src, stream)
|
||||
require.NoError(t, stream.Error())
|
||||
|
||||
// Append an unknown field at the start to ensure unknown fields are skipped
|
||||
// and the unmarshal logic continues.
|
||||
buf := stream.Buffer()
|
||||
assert.EqualValues(t, '{', buf[0])
|
||||
iter := json.BorrowIterator(append([]byte(`{"unknown": "string",`), buf[1:]...))
|
||||
func TestMarshalAndUnmarshalJSONOrigStatusUnknown(t *testing.T) {
|
||||
iter := json.BorrowIterator([]byte(`{"unknown": "string"}`))
|
||||
defer json.ReturnIterator(iter)
|
||||
dest := &otlptrace.Status{}
|
||||
UnmarshalJSONOrigStatus(dest, iter)
|
||||
require.NoError(t, iter.Error())
|
||||
assert.Equal(t, &otlptrace.Status{}, dest)
|
||||
}
|
||||
|
||||
assert.Equal(t, src, dest)
|
||||
func TestMarshalAndUnmarshalJSONOrigStatus(t *testing.T) {
|
||||
for name, src := range getEncodingTestValuesStatus() {
|
||||
t.Run(name, func(t *testing.T) {
|
||||
stream := json.BorrowStream(nil)
|
||||
defer json.ReturnStream(stream)
|
||||
MarshalJSONOrigStatus(src, stream)
|
||||
require.NoError(t, stream.Error())
|
||||
|
||||
iter := json.BorrowIterator(stream.Buffer())
|
||||
defer json.ReturnIterator(iter)
|
||||
dest := &otlptrace.Status{}
|
||||
UnmarshalJSONOrigStatus(dest, iter)
|
||||
require.NoError(t, iter.Error())
|
||||
|
||||
assert.Equal(t, src, dest)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestMarshalAndUnmarshalProtoOrigStatus(t *testing.T) {
|
||||
src := &otlptrace.Status{}
|
||||
FillOrigTestStatus(src)
|
||||
buf := make([]byte, SizeProtoOrigStatus(src))
|
||||
gotSize := MarshalProtoOrigStatus(src, buf)
|
||||
assert.Equal(t, len(buf), gotSize)
|
||||
for name, src := range getEncodingTestValuesStatus() {
|
||||
t.Run(name, func(t *testing.T) {
|
||||
buf := make([]byte, SizeProtoOrigStatus(src))
|
||||
gotSize := MarshalProtoOrigStatus(src, buf)
|
||||
assert.Equal(t, len(buf), gotSize)
|
||||
|
||||
dest := &otlptrace.Status{}
|
||||
require.NoError(t, UnmarshalProtoOrigStatus(dest, buf))
|
||||
assert.Equal(t, src, dest)
|
||||
dest := &otlptrace.Status{}
|
||||
require.NoError(t, UnmarshalProtoOrigStatus(dest, buf))
|
||||
assert.Equal(t, src, dest)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestMarshalAndUnmarshalProtoOrigEmptyStatus(t *testing.T) {
|
||||
src := &otlptrace.Status{}
|
||||
buf := make([]byte, SizeProtoOrigStatus(src))
|
||||
gotSize := MarshalProtoOrigStatus(src, buf)
|
||||
assert.Equal(t, len(buf), gotSize)
|
||||
|
||||
dest := &otlptrace.Status{}
|
||||
require.NoError(t, UnmarshalProtoOrigStatus(dest, buf))
|
||||
assert.Equal(t, src, dest)
|
||||
func getEncodingTestValuesStatus() map[string]*otlptrace.Status {
|
||||
return map[string]*otlptrace.Status{
|
||||
"empty": {},
|
||||
"fill_test": func() *otlptrace.Status {
|
||||
src := &otlptrace.Status{}
|
||||
FillOrigTestStatus(src)
|
||||
return src
|
||||
}(),
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,46 +26,55 @@ func TestCopyOrigSum(t *testing.T) {
|
|||
assert.Equal(t, src, dest)
|
||||
}
|
||||
|
||||
func TestMarshalAndUnmarshalJSONOrigSum(t *testing.T) {
|
||||
src := &otlpmetrics.Sum{}
|
||||
FillOrigTestSum(src)
|
||||
stream := json.BorrowStream(nil)
|
||||
defer json.ReturnStream(stream)
|
||||
MarshalJSONOrigSum(src, stream)
|
||||
require.NoError(t, stream.Error())
|
||||
|
||||
// Append an unknown field at the start to ensure unknown fields are skipped
|
||||
// and the unmarshal logic continues.
|
||||
buf := stream.Buffer()
|
||||
assert.EqualValues(t, '{', buf[0])
|
||||
iter := json.BorrowIterator(append([]byte(`{"unknown": "string",`), buf[1:]...))
|
||||
func TestMarshalAndUnmarshalJSONOrigSumUnknown(t *testing.T) {
|
||||
iter := json.BorrowIterator([]byte(`{"unknown": "string"}`))
|
||||
defer json.ReturnIterator(iter)
|
||||
dest := &otlpmetrics.Sum{}
|
||||
UnmarshalJSONOrigSum(dest, iter)
|
||||
require.NoError(t, iter.Error())
|
||||
assert.Equal(t, &otlpmetrics.Sum{}, dest)
|
||||
}
|
||||
|
||||
assert.Equal(t, src, dest)
|
||||
func TestMarshalAndUnmarshalJSONOrigSum(t *testing.T) {
|
||||
for name, src := range getEncodingTestValuesSum() {
|
||||
t.Run(name, func(t *testing.T) {
|
||||
stream := json.BorrowStream(nil)
|
||||
defer json.ReturnStream(stream)
|
||||
MarshalJSONOrigSum(src, stream)
|
||||
require.NoError(t, stream.Error())
|
||||
|
||||
iter := json.BorrowIterator(stream.Buffer())
|
||||
defer json.ReturnIterator(iter)
|
||||
dest := &otlpmetrics.Sum{}
|
||||
UnmarshalJSONOrigSum(dest, iter)
|
||||
require.NoError(t, iter.Error())
|
||||
|
||||
assert.Equal(t, src, dest)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestMarshalAndUnmarshalProtoOrigSum(t *testing.T) {
|
||||
src := &otlpmetrics.Sum{}
|
||||
FillOrigTestSum(src)
|
||||
buf := make([]byte, SizeProtoOrigSum(src))
|
||||
gotSize := MarshalProtoOrigSum(src, buf)
|
||||
assert.Equal(t, len(buf), gotSize)
|
||||
for name, src := range getEncodingTestValuesSum() {
|
||||
t.Run(name, func(t *testing.T) {
|
||||
buf := make([]byte, SizeProtoOrigSum(src))
|
||||
gotSize := MarshalProtoOrigSum(src, buf)
|
||||
assert.Equal(t, len(buf), gotSize)
|
||||
|
||||
dest := &otlpmetrics.Sum{}
|
||||
require.NoError(t, UnmarshalProtoOrigSum(dest, buf))
|
||||
assert.Equal(t, src, dest)
|
||||
dest := &otlpmetrics.Sum{}
|
||||
require.NoError(t, UnmarshalProtoOrigSum(dest, buf))
|
||||
assert.Equal(t, src, dest)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestMarshalAndUnmarshalProtoOrigEmptySum(t *testing.T) {
|
||||
src := &otlpmetrics.Sum{}
|
||||
buf := make([]byte, SizeProtoOrigSum(src))
|
||||
gotSize := MarshalProtoOrigSum(src, buf)
|
||||
assert.Equal(t, len(buf), gotSize)
|
||||
|
||||
dest := &otlpmetrics.Sum{}
|
||||
require.NoError(t, UnmarshalProtoOrigSum(dest, buf))
|
||||
assert.Equal(t, src, dest)
|
||||
func getEncodingTestValuesSum() map[string]*otlpmetrics.Sum {
|
||||
return map[string]*otlpmetrics.Sum{
|
||||
"empty": {},
|
||||
"fill_test": func() *otlpmetrics.Sum {
|
||||
src := &otlpmetrics.Sum{}
|
||||
FillOrigTestSum(src)
|
||||
return src
|
||||
}(),
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,46 +26,55 @@ func TestCopyOrigSummary(t *testing.T) {
|
|||
assert.Equal(t, src, dest)
|
||||
}
|
||||
|
||||
func TestMarshalAndUnmarshalJSONOrigSummary(t *testing.T) {
|
||||
src := &otlpmetrics.Summary{}
|
||||
FillOrigTestSummary(src)
|
||||
stream := json.BorrowStream(nil)
|
||||
defer json.ReturnStream(stream)
|
||||
MarshalJSONOrigSummary(src, stream)
|
||||
require.NoError(t, stream.Error())
|
||||
|
||||
// Append an unknown field at the start to ensure unknown fields are skipped
|
||||
// and the unmarshal logic continues.
|
||||
buf := stream.Buffer()
|
||||
assert.EqualValues(t, '{', buf[0])
|
||||
iter := json.BorrowIterator(append([]byte(`{"unknown": "string",`), buf[1:]...))
|
||||
func TestMarshalAndUnmarshalJSONOrigSummaryUnknown(t *testing.T) {
|
||||
iter := json.BorrowIterator([]byte(`{"unknown": "string"}`))
|
||||
defer json.ReturnIterator(iter)
|
||||
dest := &otlpmetrics.Summary{}
|
||||
UnmarshalJSONOrigSummary(dest, iter)
|
||||
require.NoError(t, iter.Error())
|
||||
assert.Equal(t, &otlpmetrics.Summary{}, dest)
|
||||
}
|
||||
|
||||
assert.Equal(t, src, dest)
|
||||
func TestMarshalAndUnmarshalJSONOrigSummary(t *testing.T) {
|
||||
for name, src := range getEncodingTestValuesSummary() {
|
||||
t.Run(name, func(t *testing.T) {
|
||||
stream := json.BorrowStream(nil)
|
||||
defer json.ReturnStream(stream)
|
||||
MarshalJSONOrigSummary(src, stream)
|
||||
require.NoError(t, stream.Error())
|
||||
|
||||
iter := json.BorrowIterator(stream.Buffer())
|
||||
defer json.ReturnIterator(iter)
|
||||
dest := &otlpmetrics.Summary{}
|
||||
UnmarshalJSONOrigSummary(dest, iter)
|
||||
require.NoError(t, iter.Error())
|
||||
|
||||
assert.Equal(t, src, dest)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestMarshalAndUnmarshalProtoOrigSummary(t *testing.T) {
|
||||
src := &otlpmetrics.Summary{}
|
||||
FillOrigTestSummary(src)
|
||||
buf := make([]byte, SizeProtoOrigSummary(src))
|
||||
gotSize := MarshalProtoOrigSummary(src, buf)
|
||||
assert.Equal(t, len(buf), gotSize)
|
||||
for name, src := range getEncodingTestValuesSummary() {
|
||||
t.Run(name, func(t *testing.T) {
|
||||
buf := make([]byte, SizeProtoOrigSummary(src))
|
||||
gotSize := MarshalProtoOrigSummary(src, buf)
|
||||
assert.Equal(t, len(buf), gotSize)
|
||||
|
||||
dest := &otlpmetrics.Summary{}
|
||||
require.NoError(t, UnmarshalProtoOrigSummary(dest, buf))
|
||||
assert.Equal(t, src, dest)
|
||||
dest := &otlpmetrics.Summary{}
|
||||
require.NoError(t, UnmarshalProtoOrigSummary(dest, buf))
|
||||
assert.Equal(t, src, dest)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestMarshalAndUnmarshalProtoOrigEmptySummary(t *testing.T) {
|
||||
src := &otlpmetrics.Summary{}
|
||||
buf := make([]byte, SizeProtoOrigSummary(src))
|
||||
gotSize := MarshalProtoOrigSummary(src, buf)
|
||||
assert.Equal(t, len(buf), gotSize)
|
||||
|
||||
dest := &otlpmetrics.Summary{}
|
||||
require.NoError(t, UnmarshalProtoOrigSummary(dest, buf))
|
||||
assert.Equal(t, src, dest)
|
||||
func getEncodingTestValuesSummary() map[string]*otlpmetrics.Summary {
|
||||
return map[string]*otlpmetrics.Summary{
|
||||
"empty": {},
|
||||
"fill_test": func() *otlpmetrics.Summary {
|
||||
src := &otlpmetrics.Summary{}
|
||||
FillOrigTestSummary(src)
|
||||
return src
|
||||
}(),
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,46 +26,55 @@ func TestCopyOrigSummaryDataPoint(t *testing.T) {
|
|||
assert.Equal(t, src, dest)
|
||||
}
|
||||
|
||||
func TestMarshalAndUnmarshalJSONOrigSummaryDataPoint(t *testing.T) {
|
||||
src := &otlpmetrics.SummaryDataPoint{}
|
||||
FillOrigTestSummaryDataPoint(src)
|
||||
stream := json.BorrowStream(nil)
|
||||
defer json.ReturnStream(stream)
|
||||
MarshalJSONOrigSummaryDataPoint(src, stream)
|
||||
require.NoError(t, stream.Error())
|
||||
|
||||
// Append an unknown field at the start to ensure unknown fields are skipped
|
||||
// and the unmarshal logic continues.
|
||||
buf := stream.Buffer()
|
||||
assert.EqualValues(t, '{', buf[0])
|
||||
iter := json.BorrowIterator(append([]byte(`{"unknown": "string",`), buf[1:]...))
|
||||
func TestMarshalAndUnmarshalJSONOrigSummaryDataPointUnknown(t *testing.T) {
|
||||
iter := json.BorrowIterator([]byte(`{"unknown": "string"}`))
|
||||
defer json.ReturnIterator(iter)
|
||||
dest := &otlpmetrics.SummaryDataPoint{}
|
||||
UnmarshalJSONOrigSummaryDataPoint(dest, iter)
|
||||
require.NoError(t, iter.Error())
|
||||
assert.Equal(t, &otlpmetrics.SummaryDataPoint{}, dest)
|
||||
}
|
||||
|
||||
assert.Equal(t, src, dest)
|
||||
func TestMarshalAndUnmarshalJSONOrigSummaryDataPoint(t *testing.T) {
|
||||
for name, src := range getEncodingTestValuesSummaryDataPoint() {
|
||||
t.Run(name, func(t *testing.T) {
|
||||
stream := json.BorrowStream(nil)
|
||||
defer json.ReturnStream(stream)
|
||||
MarshalJSONOrigSummaryDataPoint(src, stream)
|
||||
require.NoError(t, stream.Error())
|
||||
|
||||
iter := json.BorrowIterator(stream.Buffer())
|
||||
defer json.ReturnIterator(iter)
|
||||
dest := &otlpmetrics.SummaryDataPoint{}
|
||||
UnmarshalJSONOrigSummaryDataPoint(dest, iter)
|
||||
require.NoError(t, iter.Error())
|
||||
|
||||
assert.Equal(t, src, dest)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestMarshalAndUnmarshalProtoOrigSummaryDataPoint(t *testing.T) {
|
||||
src := &otlpmetrics.SummaryDataPoint{}
|
||||
FillOrigTestSummaryDataPoint(src)
|
||||
buf := make([]byte, SizeProtoOrigSummaryDataPoint(src))
|
||||
gotSize := MarshalProtoOrigSummaryDataPoint(src, buf)
|
||||
assert.Equal(t, len(buf), gotSize)
|
||||
for name, src := range getEncodingTestValuesSummaryDataPoint() {
|
||||
t.Run(name, func(t *testing.T) {
|
||||
buf := make([]byte, SizeProtoOrigSummaryDataPoint(src))
|
||||
gotSize := MarshalProtoOrigSummaryDataPoint(src, buf)
|
||||
assert.Equal(t, len(buf), gotSize)
|
||||
|
||||
dest := &otlpmetrics.SummaryDataPoint{}
|
||||
require.NoError(t, UnmarshalProtoOrigSummaryDataPoint(dest, buf))
|
||||
assert.Equal(t, src, dest)
|
||||
dest := &otlpmetrics.SummaryDataPoint{}
|
||||
require.NoError(t, UnmarshalProtoOrigSummaryDataPoint(dest, buf))
|
||||
assert.Equal(t, src, dest)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestMarshalAndUnmarshalProtoOrigEmptySummaryDataPoint(t *testing.T) {
|
||||
src := &otlpmetrics.SummaryDataPoint{}
|
||||
buf := make([]byte, SizeProtoOrigSummaryDataPoint(src))
|
||||
gotSize := MarshalProtoOrigSummaryDataPoint(src, buf)
|
||||
assert.Equal(t, len(buf), gotSize)
|
||||
|
||||
dest := &otlpmetrics.SummaryDataPoint{}
|
||||
require.NoError(t, UnmarshalProtoOrigSummaryDataPoint(dest, buf))
|
||||
assert.Equal(t, src, dest)
|
||||
func getEncodingTestValuesSummaryDataPoint() map[string]*otlpmetrics.SummaryDataPoint {
|
||||
return map[string]*otlpmetrics.SummaryDataPoint{
|
||||
"empty": {},
|
||||
"fill_test": func() *otlpmetrics.SummaryDataPoint {
|
||||
src := &otlpmetrics.SummaryDataPoint{}
|
||||
FillOrigTestSummaryDataPoint(src)
|
||||
return src
|
||||
}(),
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,46 +26,55 @@ func TestCopyOrigSummaryDataPoint_ValueAtQuantile(t *testing.T) {
|
|||
assert.Equal(t, src, dest)
|
||||
}
|
||||
|
||||
func TestMarshalAndUnmarshalJSONOrigSummaryDataPoint_ValueAtQuantile(t *testing.T) {
|
||||
src := &otlpmetrics.SummaryDataPoint_ValueAtQuantile{}
|
||||
FillOrigTestSummaryDataPoint_ValueAtQuantile(src)
|
||||
stream := json.BorrowStream(nil)
|
||||
defer json.ReturnStream(stream)
|
||||
MarshalJSONOrigSummaryDataPoint_ValueAtQuantile(src, stream)
|
||||
require.NoError(t, stream.Error())
|
||||
|
||||
// Append an unknown field at the start to ensure unknown fields are skipped
|
||||
// and the unmarshal logic continues.
|
||||
buf := stream.Buffer()
|
||||
assert.EqualValues(t, '{', buf[0])
|
||||
iter := json.BorrowIterator(append([]byte(`{"unknown": "string",`), buf[1:]...))
|
||||
func TestMarshalAndUnmarshalJSONOrigSummaryDataPoint_ValueAtQuantileUnknown(t *testing.T) {
|
||||
iter := json.BorrowIterator([]byte(`{"unknown": "string"}`))
|
||||
defer json.ReturnIterator(iter)
|
||||
dest := &otlpmetrics.SummaryDataPoint_ValueAtQuantile{}
|
||||
UnmarshalJSONOrigSummaryDataPoint_ValueAtQuantile(dest, iter)
|
||||
require.NoError(t, iter.Error())
|
||||
assert.Equal(t, &otlpmetrics.SummaryDataPoint_ValueAtQuantile{}, dest)
|
||||
}
|
||||
|
||||
assert.Equal(t, src, dest)
|
||||
func TestMarshalAndUnmarshalJSONOrigSummaryDataPoint_ValueAtQuantile(t *testing.T) {
|
||||
for name, src := range getEncodingTestValuesSummaryDataPoint_ValueAtQuantile() {
|
||||
t.Run(name, func(t *testing.T) {
|
||||
stream := json.BorrowStream(nil)
|
||||
defer json.ReturnStream(stream)
|
||||
MarshalJSONOrigSummaryDataPoint_ValueAtQuantile(src, stream)
|
||||
require.NoError(t, stream.Error())
|
||||
|
||||
iter := json.BorrowIterator(stream.Buffer())
|
||||
defer json.ReturnIterator(iter)
|
||||
dest := &otlpmetrics.SummaryDataPoint_ValueAtQuantile{}
|
||||
UnmarshalJSONOrigSummaryDataPoint_ValueAtQuantile(dest, iter)
|
||||
require.NoError(t, iter.Error())
|
||||
|
||||
assert.Equal(t, src, dest)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestMarshalAndUnmarshalProtoOrigSummaryDataPoint_ValueAtQuantile(t *testing.T) {
|
||||
src := &otlpmetrics.SummaryDataPoint_ValueAtQuantile{}
|
||||
FillOrigTestSummaryDataPoint_ValueAtQuantile(src)
|
||||
buf := make([]byte, SizeProtoOrigSummaryDataPoint_ValueAtQuantile(src))
|
||||
gotSize := MarshalProtoOrigSummaryDataPoint_ValueAtQuantile(src, buf)
|
||||
assert.Equal(t, len(buf), gotSize)
|
||||
for name, src := range getEncodingTestValuesSummaryDataPoint_ValueAtQuantile() {
|
||||
t.Run(name, func(t *testing.T) {
|
||||
buf := make([]byte, SizeProtoOrigSummaryDataPoint_ValueAtQuantile(src))
|
||||
gotSize := MarshalProtoOrigSummaryDataPoint_ValueAtQuantile(src, buf)
|
||||
assert.Equal(t, len(buf), gotSize)
|
||||
|
||||
dest := &otlpmetrics.SummaryDataPoint_ValueAtQuantile{}
|
||||
require.NoError(t, UnmarshalProtoOrigSummaryDataPoint_ValueAtQuantile(dest, buf))
|
||||
assert.Equal(t, src, dest)
|
||||
dest := &otlpmetrics.SummaryDataPoint_ValueAtQuantile{}
|
||||
require.NoError(t, UnmarshalProtoOrigSummaryDataPoint_ValueAtQuantile(dest, buf))
|
||||
assert.Equal(t, src, dest)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestMarshalAndUnmarshalProtoOrigEmptySummaryDataPoint_ValueAtQuantile(t *testing.T) {
|
||||
src := &otlpmetrics.SummaryDataPoint_ValueAtQuantile{}
|
||||
buf := make([]byte, SizeProtoOrigSummaryDataPoint_ValueAtQuantile(src))
|
||||
gotSize := MarshalProtoOrigSummaryDataPoint_ValueAtQuantile(src, buf)
|
||||
assert.Equal(t, len(buf), gotSize)
|
||||
|
||||
dest := &otlpmetrics.SummaryDataPoint_ValueAtQuantile{}
|
||||
require.NoError(t, UnmarshalProtoOrigSummaryDataPoint_ValueAtQuantile(dest, buf))
|
||||
assert.Equal(t, src, dest)
|
||||
func getEncodingTestValuesSummaryDataPoint_ValueAtQuantile() map[string]*otlpmetrics.SummaryDataPoint_ValueAtQuantile {
|
||||
return map[string]*otlpmetrics.SummaryDataPoint_ValueAtQuantile{
|
||||
"empty": {},
|
||||
"fill_test": func() *otlpmetrics.SummaryDataPoint_ValueAtQuantile {
|
||||
src := &otlpmetrics.SummaryDataPoint_ValueAtQuantile{}
|
||||
FillOrigTestSummaryDataPoint_ValueAtQuantile(src)
|
||||
return src
|
||||
}(),
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,46 +26,55 @@ func TestCopyOrigValueType(t *testing.T) {
|
|||
assert.Equal(t, src, dest)
|
||||
}
|
||||
|
||||
func TestMarshalAndUnmarshalJSONOrigValueType(t *testing.T) {
|
||||
src := &otlpprofiles.ValueType{}
|
||||
FillOrigTestValueType(src)
|
||||
stream := json.BorrowStream(nil)
|
||||
defer json.ReturnStream(stream)
|
||||
MarshalJSONOrigValueType(src, stream)
|
||||
require.NoError(t, stream.Error())
|
||||
|
||||
// Append an unknown field at the start to ensure unknown fields are skipped
|
||||
// and the unmarshal logic continues.
|
||||
buf := stream.Buffer()
|
||||
assert.EqualValues(t, '{', buf[0])
|
||||
iter := json.BorrowIterator(append([]byte(`{"unknown": "string",`), buf[1:]...))
|
||||
func TestMarshalAndUnmarshalJSONOrigValueTypeUnknown(t *testing.T) {
|
||||
iter := json.BorrowIterator([]byte(`{"unknown": "string"}`))
|
||||
defer json.ReturnIterator(iter)
|
||||
dest := &otlpprofiles.ValueType{}
|
||||
UnmarshalJSONOrigValueType(dest, iter)
|
||||
require.NoError(t, iter.Error())
|
||||
assert.Equal(t, &otlpprofiles.ValueType{}, dest)
|
||||
}
|
||||
|
||||
assert.Equal(t, src, dest)
|
||||
func TestMarshalAndUnmarshalJSONOrigValueType(t *testing.T) {
|
||||
for name, src := range getEncodingTestValuesValueType() {
|
||||
t.Run(name, func(t *testing.T) {
|
||||
stream := json.BorrowStream(nil)
|
||||
defer json.ReturnStream(stream)
|
||||
MarshalJSONOrigValueType(src, stream)
|
||||
require.NoError(t, stream.Error())
|
||||
|
||||
iter := json.BorrowIterator(stream.Buffer())
|
||||
defer json.ReturnIterator(iter)
|
||||
dest := &otlpprofiles.ValueType{}
|
||||
UnmarshalJSONOrigValueType(dest, iter)
|
||||
require.NoError(t, iter.Error())
|
||||
|
||||
assert.Equal(t, src, dest)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestMarshalAndUnmarshalProtoOrigValueType(t *testing.T) {
|
||||
src := &otlpprofiles.ValueType{}
|
||||
FillOrigTestValueType(src)
|
||||
buf := make([]byte, SizeProtoOrigValueType(src))
|
||||
gotSize := MarshalProtoOrigValueType(src, buf)
|
||||
assert.Equal(t, len(buf), gotSize)
|
||||
for name, src := range getEncodingTestValuesValueType() {
|
||||
t.Run(name, func(t *testing.T) {
|
||||
buf := make([]byte, SizeProtoOrigValueType(src))
|
||||
gotSize := MarshalProtoOrigValueType(src, buf)
|
||||
assert.Equal(t, len(buf), gotSize)
|
||||
|
||||
dest := &otlpprofiles.ValueType{}
|
||||
require.NoError(t, UnmarshalProtoOrigValueType(dest, buf))
|
||||
assert.Equal(t, src, dest)
|
||||
dest := &otlpprofiles.ValueType{}
|
||||
require.NoError(t, UnmarshalProtoOrigValueType(dest, buf))
|
||||
assert.Equal(t, src, dest)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestMarshalAndUnmarshalProtoOrigEmptyValueType(t *testing.T) {
|
||||
src := &otlpprofiles.ValueType{}
|
||||
buf := make([]byte, SizeProtoOrigValueType(src))
|
||||
gotSize := MarshalProtoOrigValueType(src, buf)
|
||||
assert.Equal(t, len(buf), gotSize)
|
||||
|
||||
dest := &otlpprofiles.ValueType{}
|
||||
require.NoError(t, UnmarshalProtoOrigValueType(dest, buf))
|
||||
assert.Equal(t, src, dest)
|
||||
func getEncodingTestValuesValueType() map[string]*otlpprofiles.ValueType {
|
||||
return map[string]*otlpprofiles.ValueType{
|
||||
"empty": {},
|
||||
"fill_test": func() *otlpprofiles.ValueType {
|
||||
src := &otlpprofiles.ValueType{}
|
||||
FillOrigTestValueType(src)
|
||||
return src
|
||||
}(),
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue