You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@plc4x.apache.org by sr...@apache.org on 2023/05/22 12:39:57 UTC
[plc4x] 03/03: test(plc4go/spi): add initial tests for write buffers
This is an automated email from the ASF dual-hosted git repository.
sruehl pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/plc4x.git
commit 9d6f632b804ead3bfa04fb01065ed19a8d04aabf
Author: Sebastian Rühl <sr...@apache.org>
AuthorDate: Mon May 22 14:39:23 2023 +0200
test(plc4go/spi): add initial tests for write buffers
---
plc4go/spi/utils/WriteBufferBoxBased_test.go | 1267 +++++++++++++++++++++++++
plc4go/spi/utils/WriteBufferJsonBased_test.go | 1156 ++++++++++++++++++++++
plc4go/spi/utils/WriteBufferXmlBased_test.go | 1251 ++++++++++++++++++++++++
3 files changed, 3674 insertions(+)
diff --git a/plc4go/spi/utils/WriteBufferBoxBased_test.go b/plc4go/spi/utils/WriteBufferBoxBased_test.go
new file mode 100644
index 0000000000..29bcaee3c6
--- /dev/null
+++ b/plc4go/spi/utils/WriteBufferBoxBased_test.go
@@ -0,0 +1,1267 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package utils
+
+import (
+ "container/list"
+ "context"
+ "fmt"
+ "github.com/stretchr/testify/assert"
+ "math/big"
+ "testing"
+)
+
+func TestNewWriteBufferBoxBased(t *testing.T) {
+ tests := []struct {
+ name string
+ want WriteBufferBoxBased
+ }{
+ {
+ name: "create it",
+ want: &boxedWriteBuffer{
+ List: list.New(),
+ desiredWidth: 120,
+ currentWidth: 118,
+ mergeSingleBoxes: false,
+ omitEmptyBoxes: false,
+ asciiBoxWriter: AsciiBoxWriterDefault,
+ asciiBoxWriterLight: AsciiBoxWriterLight,
+ },
+ },
+ }
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ assert.Equalf(t, tt.want, NewWriteBufferBoxBased(), "NewWriteBufferBoxBased()")
+ })
+ }
+}
+
+func TestNewWriteBufferBoxBasedWithOptions(t *testing.T) {
+ type args struct {
+ mergeSingleBoxes bool
+ omitEmptyBoxes bool
+ }
+ tests := []struct {
+ name string
+ args args
+ want WriteBufferBoxBased
+ }{
+ {
+ name: "create it",
+ args: args{
+ mergeSingleBoxes: true,
+ omitEmptyBoxes: true,
+ },
+ want: &boxedWriteBuffer{
+ List: list.New(),
+ desiredWidth: 120,
+ currentWidth: 118,
+ mergeSingleBoxes: true,
+ omitEmptyBoxes: true,
+ asciiBoxWriter: AsciiBoxWriterDefault,
+ asciiBoxWriterLight: AsciiBoxWriterLight,
+ },
+ },
+ }
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ assert.Equalf(t, tt.want, NewWriteBufferBoxBasedWithOptions(tt.args.mergeSingleBoxes, tt.args.omitEmptyBoxes), "NewWriteBufferBoxBasedWithOptions(%v, %v)", tt.args.mergeSingleBoxes, tt.args.omitEmptyBoxes)
+ })
+ }
+}
+
+func Test_boxedWriteBuffer_GetBox(t *testing.T) {
+ type fields struct {
+ BufferCommons BufferCommons
+ List *list.List
+ desiredWidth int
+ currentWidth int
+ mergeSingleBoxes bool
+ omitEmptyBoxes bool
+ asciiBoxWriter AsciiBoxWriter
+ asciiBoxWriterLight AsciiBoxWriter
+ pos uint
+ }
+ tests := []struct {
+ name string
+ fields fields
+ want AsciiBox
+ }{
+ {
+ name: "get it",
+ fields: fields{
+ List: list.New(),
+ },
+ want: AsciiBox{data: "<nil>"},
+ },
+ }
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ b := &boxedWriteBuffer{
+ BufferCommons: tt.fields.BufferCommons,
+ List: tt.fields.List,
+ desiredWidth: tt.fields.desiredWidth,
+ currentWidth: tt.fields.currentWidth,
+ mergeSingleBoxes: tt.fields.mergeSingleBoxes,
+ omitEmptyBoxes: tt.fields.omitEmptyBoxes,
+ asciiBoxWriter: tt.fields.asciiBoxWriter,
+ asciiBoxWriterLight: tt.fields.asciiBoxWriterLight,
+ pos: tt.fields.pos,
+ }
+ assert.Equalf(t, tt.want, b.GetBox(), "GetBox()")
+ })
+ }
+}
+
+func Test_boxedWriteBuffer_GetPos(t *testing.T) {
+ type fields struct {
+ BufferCommons BufferCommons
+ List *list.List
+ desiredWidth int
+ currentWidth int
+ mergeSingleBoxes bool
+ omitEmptyBoxes bool
+ asciiBoxWriter AsciiBoxWriter
+ asciiBoxWriterLight AsciiBoxWriter
+ pos uint
+ }
+ tests := []struct {
+ name string
+ fields fields
+ want uint16
+ }{
+ {
+ name: "get it",
+ },
+ }
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ b := &boxedWriteBuffer{
+ BufferCommons: tt.fields.BufferCommons,
+ List: tt.fields.List,
+ desiredWidth: tt.fields.desiredWidth,
+ currentWidth: tt.fields.currentWidth,
+ mergeSingleBoxes: tt.fields.mergeSingleBoxes,
+ omitEmptyBoxes: tt.fields.omitEmptyBoxes,
+ asciiBoxWriter: tt.fields.asciiBoxWriter,
+ asciiBoxWriterLight: tt.fields.asciiBoxWriterLight,
+ pos: tt.fields.pos,
+ }
+ assert.Equalf(t, tt.want, b.GetPos(), "GetPos()")
+ })
+ }
+}
+
+func Test_boxedWriteBuffer_PopContext(t *testing.T) {
+ type fields struct {
+ BufferCommons BufferCommons
+ List *list.List
+ desiredWidth int
+ currentWidth int
+ mergeSingleBoxes bool
+ omitEmptyBoxes bool
+ asciiBoxWriter AsciiBoxWriter
+ asciiBoxWriterLight AsciiBoxWriter
+ pos uint
+ }
+ type args struct {
+ logicalName string
+ in1 []WithWriterArgs
+ }
+ tests := []struct {
+ name string
+ fields fields
+ args args
+ wantErr assert.ErrorAssertionFunc
+ }{
+ {
+ name: "pop it",
+ fields: fields{
+ List: list.New(),
+ asciiBoxWriter: NewAsciiBoxWriter(),
+ },
+ wantErr: assert.NoError,
+ },
+ }
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ b := &boxedWriteBuffer{
+ BufferCommons: tt.fields.BufferCommons,
+ List: tt.fields.List,
+ desiredWidth: tt.fields.desiredWidth,
+ currentWidth: tt.fields.currentWidth,
+ mergeSingleBoxes: tt.fields.mergeSingleBoxes,
+ omitEmptyBoxes: tt.fields.omitEmptyBoxes,
+ asciiBoxWriter: tt.fields.asciiBoxWriter,
+ asciiBoxWriterLight: tt.fields.asciiBoxWriterLight,
+ pos: tt.fields.pos,
+ }
+ tt.wantErr(t, b.PopContext(tt.args.logicalName, tt.args.in1...), fmt.Sprintf("PopContext(%v, %v)", tt.args.logicalName, tt.args.in1))
+ })
+ }
+}
+
+func Test_boxedWriteBuffer_PushContext(t *testing.T) {
+ type fields struct {
+ BufferCommons BufferCommons
+ List *list.List
+ desiredWidth int
+ currentWidth int
+ mergeSingleBoxes bool
+ omitEmptyBoxes bool
+ asciiBoxWriter AsciiBoxWriter
+ asciiBoxWriterLight AsciiBoxWriter
+ pos uint
+ }
+ type args struct {
+ in0 string
+ in1 []WithWriterArgs
+ }
+ tests := []struct {
+ name string
+ fields fields
+ args args
+ wantErr assert.ErrorAssertionFunc
+ }{
+ {
+ name: "push it",
+ fields: fields{
+ List: list.New(),
+ asciiBoxWriter: NewAsciiBoxWriter(),
+ },
+ wantErr: assert.NoError,
+ },
+ }
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ b := &boxedWriteBuffer{
+ BufferCommons: tt.fields.BufferCommons,
+ List: tt.fields.List,
+ desiredWidth: tt.fields.desiredWidth,
+ currentWidth: tt.fields.currentWidth,
+ mergeSingleBoxes: tt.fields.mergeSingleBoxes,
+ omitEmptyBoxes: tt.fields.omitEmptyBoxes,
+ asciiBoxWriter: tt.fields.asciiBoxWriter,
+ asciiBoxWriterLight: tt.fields.asciiBoxWriterLight,
+ pos: tt.fields.pos,
+ }
+ tt.wantErr(t, b.PushContext(tt.args.in0, tt.args.in1...), fmt.Sprintf("PushContext(%v, %v)", tt.args.in0, tt.args.in1))
+ })
+ }
+}
+
+func Test_boxedWriteBuffer_WriteBigFloat(t *testing.T) {
+ type fields struct {
+ BufferCommons BufferCommons
+ List *list.List
+ desiredWidth int
+ currentWidth int
+ mergeSingleBoxes bool
+ omitEmptyBoxes bool
+ asciiBoxWriter AsciiBoxWriter
+ asciiBoxWriterLight AsciiBoxWriter
+ pos uint
+ }
+ type args struct {
+ logicalName string
+ bitLength uint8
+ value *big.Float
+ writerArgs []WithWriterArgs
+ }
+ tests := []struct {
+ name string
+ fields fields
+ args args
+ wantErr assert.ErrorAssertionFunc
+ }{
+ {
+ name: "write it",
+ fields: fields{
+ List: list.New(),
+ asciiBoxWriter: NewAsciiBoxWriter(),
+ },
+ wantErr: assert.NoError,
+ },
+ }
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ b := &boxedWriteBuffer{
+ BufferCommons: tt.fields.BufferCommons,
+ List: tt.fields.List,
+ desiredWidth: tt.fields.desiredWidth,
+ currentWidth: tt.fields.currentWidth,
+ mergeSingleBoxes: tt.fields.mergeSingleBoxes,
+ omitEmptyBoxes: tt.fields.omitEmptyBoxes,
+ asciiBoxWriter: tt.fields.asciiBoxWriter,
+ asciiBoxWriterLight: tt.fields.asciiBoxWriterLight,
+ pos: tt.fields.pos,
+ }
+ tt.wantErr(t, b.WriteBigFloat(tt.args.logicalName, tt.args.bitLength, tt.args.value, tt.args.writerArgs...), fmt.Sprintf("WriteBigFloat(%v, %v, %v, %v)", tt.args.logicalName, tt.args.bitLength, tt.args.value, tt.args.writerArgs))
+ })
+ }
+}
+
+func Test_boxedWriteBuffer_WriteBigInt(t *testing.T) {
+ type fields struct {
+ BufferCommons BufferCommons
+ List *list.List
+ desiredWidth int
+ currentWidth int
+ mergeSingleBoxes bool
+ omitEmptyBoxes bool
+ asciiBoxWriter AsciiBoxWriter
+ asciiBoxWriterLight AsciiBoxWriter
+ pos uint
+ }
+ type args struct {
+ logicalName string
+ bitLength uint8
+ value *big.Int
+ writerArgs []WithWriterArgs
+ }
+ tests := []struct {
+ name string
+ fields fields
+ args args
+ wantErr assert.ErrorAssertionFunc
+ }{
+ {
+ name: "write it",
+ fields: fields{
+ List: list.New(),
+ asciiBoxWriter: NewAsciiBoxWriter(),
+ },
+ wantErr: assert.NoError,
+ },
+ }
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ b := &boxedWriteBuffer{
+ BufferCommons: tt.fields.BufferCommons,
+ List: tt.fields.List,
+ desiredWidth: tt.fields.desiredWidth,
+ currentWidth: tt.fields.currentWidth,
+ mergeSingleBoxes: tt.fields.mergeSingleBoxes,
+ omitEmptyBoxes: tt.fields.omitEmptyBoxes,
+ asciiBoxWriter: tt.fields.asciiBoxWriter,
+ asciiBoxWriterLight: tt.fields.asciiBoxWriterLight,
+ pos: tt.fields.pos,
+ }
+ tt.wantErr(t, b.WriteBigInt(tt.args.logicalName, tt.args.bitLength, tt.args.value, tt.args.writerArgs...), fmt.Sprintf("WriteBigInt(%v, %v, %v, %v)", tt.args.logicalName, tt.args.bitLength, tt.args.value, tt.args.writerArgs))
+ })
+ }
+}
+
+func Test_boxedWriteBuffer_WriteBit(t *testing.T) {
+ type fields struct {
+ BufferCommons BufferCommons
+ List *list.List
+ desiredWidth int
+ currentWidth int
+ mergeSingleBoxes bool
+ omitEmptyBoxes bool
+ asciiBoxWriter AsciiBoxWriter
+ asciiBoxWriterLight AsciiBoxWriter
+ pos uint
+ }
+ type args struct {
+ logicalName string
+ value bool
+ writerArgs []WithWriterArgs
+ }
+ tests := []struct {
+ name string
+ fields fields
+ args args
+ wantErr assert.ErrorAssertionFunc
+ }{
+ {
+ name: "write it",
+ fields: fields{
+ List: list.New(),
+ asciiBoxWriter: NewAsciiBoxWriter(),
+ },
+ wantErr: assert.NoError,
+ },
+ }
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ b := &boxedWriteBuffer{
+ BufferCommons: tt.fields.BufferCommons,
+ List: tt.fields.List,
+ desiredWidth: tt.fields.desiredWidth,
+ currentWidth: tt.fields.currentWidth,
+ mergeSingleBoxes: tt.fields.mergeSingleBoxes,
+ omitEmptyBoxes: tt.fields.omitEmptyBoxes,
+ asciiBoxWriter: tt.fields.asciiBoxWriter,
+ asciiBoxWriterLight: tt.fields.asciiBoxWriterLight,
+ pos: tt.fields.pos,
+ }
+ tt.wantErr(t, b.WriteBit(tt.args.logicalName, tt.args.value, tt.args.writerArgs...), fmt.Sprintf("WriteBit(%v, %v, %v)", tt.args.logicalName, tt.args.value, tt.args.writerArgs))
+ })
+ }
+}
+
+func Test_boxedWriteBuffer_WriteByte(t *testing.T) {
+ type fields struct {
+ BufferCommons BufferCommons
+ List *list.List
+ desiredWidth int
+ currentWidth int
+ mergeSingleBoxes bool
+ omitEmptyBoxes bool
+ asciiBoxWriter AsciiBoxWriter
+ asciiBoxWriterLight AsciiBoxWriter
+ pos uint
+ }
+ type args struct {
+ logicalName string
+ value byte
+ writerArgs []WithWriterArgs
+ }
+ tests := []struct {
+ name string
+ fields fields
+ args args
+ wantErr assert.ErrorAssertionFunc
+ }{
+ {
+ name: "write it",
+ fields: fields{
+ List: list.New(),
+ asciiBoxWriter: NewAsciiBoxWriter(),
+ },
+ wantErr: assert.NoError,
+ },
+ }
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ b := &boxedWriteBuffer{
+ BufferCommons: tt.fields.BufferCommons,
+ List: tt.fields.List,
+ desiredWidth: tt.fields.desiredWidth,
+ currentWidth: tt.fields.currentWidth,
+ mergeSingleBoxes: tt.fields.mergeSingleBoxes,
+ omitEmptyBoxes: tt.fields.omitEmptyBoxes,
+ asciiBoxWriter: tt.fields.asciiBoxWriter,
+ asciiBoxWriterLight: tt.fields.asciiBoxWriterLight,
+ pos: tt.fields.pos,
+ }
+ tt.wantErr(t, b.WriteByte(tt.args.logicalName, tt.args.value, tt.args.writerArgs...), fmt.Sprintf("WriteByte(%v, %v, %v)", tt.args.logicalName, tt.args.value, tt.args.writerArgs))
+ })
+ }
+}
+
+func Test_boxedWriteBuffer_WriteByteArray(t *testing.T) {
+ type fields struct {
+ BufferCommons BufferCommons
+ List *list.List
+ desiredWidth int
+ currentWidth int
+ mergeSingleBoxes bool
+ omitEmptyBoxes bool
+ asciiBoxWriter AsciiBoxWriter
+ asciiBoxWriterLight AsciiBoxWriter
+ pos uint
+ }
+ type args struct {
+ logicalName string
+ data []byte
+ writerArgs []WithWriterArgs
+ }
+ tests := []struct {
+ name string
+ fields fields
+ args args
+ wantErr assert.ErrorAssertionFunc
+ }{
+ {
+ name: "write it",
+ fields: fields{
+ List: list.New(),
+ asciiBoxWriter: NewAsciiBoxWriter(),
+ },
+ wantErr: assert.NoError,
+ },
+ }
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ b := &boxedWriteBuffer{
+ BufferCommons: tt.fields.BufferCommons,
+ List: tt.fields.List,
+ desiredWidth: tt.fields.desiredWidth,
+ currentWidth: tt.fields.currentWidth,
+ mergeSingleBoxes: tt.fields.mergeSingleBoxes,
+ omitEmptyBoxes: tt.fields.omitEmptyBoxes,
+ asciiBoxWriter: tt.fields.asciiBoxWriter,
+ asciiBoxWriterLight: tt.fields.asciiBoxWriterLight,
+ pos: tt.fields.pos,
+ }
+ tt.wantErr(t, b.WriteByteArray(tt.args.logicalName, tt.args.data, tt.args.writerArgs...), fmt.Sprintf("WriteByteArray(%v, %v, %v)", tt.args.logicalName, tt.args.data, tt.args.writerArgs))
+ })
+ }
+}
+
+func Test_boxedWriteBuffer_WriteFloat32(t *testing.T) {
+ type fields struct {
+ BufferCommons BufferCommons
+ List *list.List
+ desiredWidth int
+ currentWidth int
+ mergeSingleBoxes bool
+ omitEmptyBoxes bool
+ asciiBoxWriter AsciiBoxWriter
+ asciiBoxWriterLight AsciiBoxWriter
+ pos uint
+ }
+ type args struct {
+ logicalName string
+ bitLength uint8
+ value float32
+ writerArgs []WithWriterArgs
+ }
+ tests := []struct {
+ name string
+ fields fields
+ args args
+ wantErr assert.ErrorAssertionFunc
+ }{
+ {
+ name: "write it",
+ fields: fields{
+ List: list.New(),
+ asciiBoxWriter: NewAsciiBoxWriter(),
+ },
+ wantErr: assert.NoError,
+ },
+ }
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ b := &boxedWriteBuffer{
+ BufferCommons: tt.fields.BufferCommons,
+ List: tt.fields.List,
+ desiredWidth: tt.fields.desiredWidth,
+ currentWidth: tt.fields.currentWidth,
+ mergeSingleBoxes: tt.fields.mergeSingleBoxes,
+ omitEmptyBoxes: tt.fields.omitEmptyBoxes,
+ asciiBoxWriter: tt.fields.asciiBoxWriter,
+ asciiBoxWriterLight: tt.fields.asciiBoxWriterLight,
+ pos: tt.fields.pos,
+ }
+ tt.wantErr(t, b.WriteFloat32(tt.args.logicalName, tt.args.bitLength, tt.args.value, tt.args.writerArgs...), fmt.Sprintf("WriteFloat32(%v, %v, %v, %v)", tt.args.logicalName, tt.args.bitLength, tt.args.value, tt.args.writerArgs))
+ })
+ }
+}
+
+func Test_boxedWriteBuffer_WriteFloat64(t *testing.T) {
+ type fields struct {
+ BufferCommons BufferCommons
+ List *list.List
+ desiredWidth int
+ currentWidth int
+ mergeSingleBoxes bool
+ omitEmptyBoxes bool
+ asciiBoxWriter AsciiBoxWriter
+ asciiBoxWriterLight AsciiBoxWriter
+ pos uint
+ }
+ type args struct {
+ logicalName string
+ bitLength uint8
+ value float64
+ writerArgs []WithWriterArgs
+ }
+ tests := []struct {
+ name string
+ fields fields
+ args args
+ wantErr assert.ErrorAssertionFunc
+ }{
+ {
+ name: "write it",
+ fields: fields{
+ List: list.New(),
+ asciiBoxWriter: NewAsciiBoxWriter(),
+ },
+ wantErr: assert.NoError,
+ },
+ }
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ b := &boxedWriteBuffer{
+ BufferCommons: tt.fields.BufferCommons,
+ List: tt.fields.List,
+ desiredWidth: tt.fields.desiredWidth,
+ currentWidth: tt.fields.currentWidth,
+ mergeSingleBoxes: tt.fields.mergeSingleBoxes,
+ omitEmptyBoxes: tt.fields.omitEmptyBoxes,
+ asciiBoxWriter: tt.fields.asciiBoxWriter,
+ asciiBoxWriterLight: tt.fields.asciiBoxWriterLight,
+ pos: tt.fields.pos,
+ }
+ tt.wantErr(t, b.WriteFloat64(tt.args.logicalName, tt.args.bitLength, tt.args.value, tt.args.writerArgs...), fmt.Sprintf("WriteFloat64(%v, %v, %v, %v)", tt.args.logicalName, tt.args.bitLength, tt.args.value, tt.args.writerArgs))
+ })
+ }
+}
+
+func Test_boxedWriteBuffer_WriteInt16(t *testing.T) {
+ type fields struct {
+ BufferCommons BufferCommons
+ List *list.List
+ desiredWidth int
+ currentWidth int
+ mergeSingleBoxes bool
+ omitEmptyBoxes bool
+ asciiBoxWriter AsciiBoxWriter
+ asciiBoxWriterLight AsciiBoxWriter
+ pos uint
+ }
+ type args struct {
+ logicalName string
+ bitLength uint8
+ value int16
+ writerArgs []WithWriterArgs
+ }
+ tests := []struct {
+ name string
+ fields fields
+ args args
+ wantErr assert.ErrorAssertionFunc
+ }{
+ {
+ name: "write it",
+ fields: fields{
+ List: list.New(),
+ asciiBoxWriter: NewAsciiBoxWriter(),
+ },
+ wantErr: assert.NoError,
+ },
+ }
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ b := &boxedWriteBuffer{
+ BufferCommons: tt.fields.BufferCommons,
+ List: tt.fields.List,
+ desiredWidth: tt.fields.desiredWidth,
+ currentWidth: tt.fields.currentWidth,
+ mergeSingleBoxes: tt.fields.mergeSingleBoxes,
+ omitEmptyBoxes: tt.fields.omitEmptyBoxes,
+ asciiBoxWriter: tt.fields.asciiBoxWriter,
+ asciiBoxWriterLight: tt.fields.asciiBoxWriterLight,
+ pos: tt.fields.pos,
+ }
+ tt.wantErr(t, b.WriteInt16(tt.args.logicalName, tt.args.bitLength, tt.args.value, tt.args.writerArgs...), fmt.Sprintf("WriteInt16(%v, %v, %v, %v)", tt.args.logicalName, tt.args.bitLength, tt.args.value, tt.args.writerArgs))
+ })
+ }
+}
+
+func Test_boxedWriteBuffer_WriteInt32(t *testing.T) {
+ type fields struct {
+ BufferCommons BufferCommons
+ List *list.List
+ desiredWidth int
+ currentWidth int
+ mergeSingleBoxes bool
+ omitEmptyBoxes bool
+ asciiBoxWriter AsciiBoxWriter
+ asciiBoxWriterLight AsciiBoxWriter
+ pos uint
+ }
+ type args struct {
+ logicalName string
+ bitLength uint8
+ value int32
+ writerArgs []WithWriterArgs
+ }
+ tests := []struct {
+ name string
+ fields fields
+ args args
+ wantErr assert.ErrorAssertionFunc
+ }{
+ {
+ name: "write it",
+ fields: fields{
+ List: list.New(),
+ asciiBoxWriter: NewAsciiBoxWriter(),
+ },
+ wantErr: assert.NoError,
+ },
+ }
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ b := &boxedWriteBuffer{
+ BufferCommons: tt.fields.BufferCommons,
+ List: tt.fields.List,
+ desiredWidth: tt.fields.desiredWidth,
+ currentWidth: tt.fields.currentWidth,
+ mergeSingleBoxes: tt.fields.mergeSingleBoxes,
+ omitEmptyBoxes: tt.fields.omitEmptyBoxes,
+ asciiBoxWriter: tt.fields.asciiBoxWriter,
+ asciiBoxWriterLight: tt.fields.asciiBoxWriterLight,
+ pos: tt.fields.pos,
+ }
+ tt.wantErr(t, b.WriteInt32(tt.args.logicalName, tt.args.bitLength, tt.args.value, tt.args.writerArgs...), fmt.Sprintf("WriteInt32(%v, %v, %v, %v)", tt.args.logicalName, tt.args.bitLength, tt.args.value, tt.args.writerArgs))
+ })
+ }
+}
+
+func Test_boxedWriteBuffer_WriteInt64(t *testing.T) {
+ type fields struct {
+ BufferCommons BufferCommons
+ List *list.List
+ desiredWidth int
+ currentWidth int
+ mergeSingleBoxes bool
+ omitEmptyBoxes bool
+ asciiBoxWriter AsciiBoxWriter
+ asciiBoxWriterLight AsciiBoxWriter
+ pos uint
+ }
+ type args struct {
+ logicalName string
+ bitLength uint8
+ value int64
+ writerArgs []WithWriterArgs
+ }
+ tests := []struct {
+ name string
+ fields fields
+ args args
+ wantErr assert.ErrorAssertionFunc
+ }{
+ {
+ name: "write it",
+ fields: fields{
+ List: list.New(),
+ asciiBoxWriter: NewAsciiBoxWriter(),
+ },
+ wantErr: assert.NoError,
+ },
+ }
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ b := &boxedWriteBuffer{
+ BufferCommons: tt.fields.BufferCommons,
+ List: tt.fields.List,
+ desiredWidth: tt.fields.desiredWidth,
+ currentWidth: tt.fields.currentWidth,
+ mergeSingleBoxes: tt.fields.mergeSingleBoxes,
+ omitEmptyBoxes: tt.fields.omitEmptyBoxes,
+ asciiBoxWriter: tt.fields.asciiBoxWriter,
+ asciiBoxWriterLight: tt.fields.asciiBoxWriterLight,
+ pos: tt.fields.pos,
+ }
+ tt.wantErr(t, b.WriteInt64(tt.args.logicalName, tt.args.bitLength, tt.args.value, tt.args.writerArgs...), fmt.Sprintf("WriteInt64(%v, %v, %v, %v)", tt.args.logicalName, tt.args.bitLength, tt.args.value, tt.args.writerArgs))
+ })
+ }
+}
+
+func Test_boxedWriteBuffer_WriteInt8(t *testing.T) {
+ type fields struct {
+ BufferCommons BufferCommons
+ List *list.List
+ desiredWidth int
+ currentWidth int
+ mergeSingleBoxes bool
+ omitEmptyBoxes bool
+ asciiBoxWriter AsciiBoxWriter
+ asciiBoxWriterLight AsciiBoxWriter
+ pos uint
+ }
+ type args struct {
+ logicalName string
+ bitLength uint8
+ value int8
+ writerArgs []WithWriterArgs
+ }
+ tests := []struct {
+ name string
+ fields fields
+ args args
+ wantErr assert.ErrorAssertionFunc
+ }{
+ {
+ name: "write it",
+ fields: fields{
+ List: list.New(),
+ asciiBoxWriter: NewAsciiBoxWriter(),
+ },
+ wantErr: assert.NoError,
+ },
+ }
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ b := &boxedWriteBuffer{
+ BufferCommons: tt.fields.BufferCommons,
+ List: tt.fields.List,
+ desiredWidth: tt.fields.desiredWidth,
+ currentWidth: tt.fields.currentWidth,
+ mergeSingleBoxes: tt.fields.mergeSingleBoxes,
+ omitEmptyBoxes: tt.fields.omitEmptyBoxes,
+ asciiBoxWriter: tt.fields.asciiBoxWriter,
+ asciiBoxWriterLight: tt.fields.asciiBoxWriterLight,
+ pos: tt.fields.pos,
+ }
+ tt.wantErr(t, b.WriteInt8(tt.args.logicalName, tt.args.bitLength, tt.args.value, tt.args.writerArgs...), fmt.Sprintf("WriteInt8(%v, %v, %v, %v)", tt.args.logicalName, tt.args.bitLength, tt.args.value, tt.args.writerArgs))
+ })
+ }
+}
+
+func Test_boxedWriteBuffer_WriteSerializable(t *testing.T) {
+ type fields struct {
+ BufferCommons BufferCommons
+ List *list.List
+ desiredWidth int
+ currentWidth int
+ mergeSingleBoxes bool
+ omitEmptyBoxes bool
+ asciiBoxWriter AsciiBoxWriter
+ asciiBoxWriterLight AsciiBoxWriter
+ pos uint
+ }
+ type args struct {
+ ctx context.Context
+ serializable Serializable
+ }
+ tests := []struct {
+ name string
+ fields fields
+ args args
+ wantErr assert.ErrorAssertionFunc
+ }{
+ {
+ name: "write it",
+ fields: fields{
+ List: list.New(),
+ asciiBoxWriter: NewAsciiBoxWriter(),
+ },
+ wantErr: assert.NoError,
+ },
+ }
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ b := &boxedWriteBuffer{
+ BufferCommons: tt.fields.BufferCommons,
+ List: tt.fields.List,
+ desiredWidth: tt.fields.desiredWidth,
+ currentWidth: tt.fields.currentWidth,
+ mergeSingleBoxes: tt.fields.mergeSingleBoxes,
+ omitEmptyBoxes: tt.fields.omitEmptyBoxes,
+ asciiBoxWriter: tt.fields.asciiBoxWriter,
+ asciiBoxWriterLight: tt.fields.asciiBoxWriterLight,
+ pos: tt.fields.pos,
+ }
+ tt.wantErr(t, b.WriteSerializable(tt.args.ctx, tt.args.serializable), fmt.Sprintf("WriteSerializable(%v, %v)", tt.args.ctx, tt.args.serializable))
+ })
+ }
+}
+
+func Test_boxedWriteBuffer_WriteString(t *testing.T) {
+ type fields struct {
+ BufferCommons BufferCommons
+ List *list.List
+ desiredWidth int
+ currentWidth int
+ mergeSingleBoxes bool
+ omitEmptyBoxes bool
+ asciiBoxWriter AsciiBoxWriter
+ asciiBoxWriterLight AsciiBoxWriter
+ pos uint
+ }
+ type args struct {
+ logicalName string
+ bitLength uint32
+ in2 string
+ value string
+ writerArgs []WithWriterArgs
+ }
+ tests := []struct {
+ name string
+ fields fields
+ args args
+ wantErr assert.ErrorAssertionFunc
+ }{
+ {
+ name: "write it",
+ fields: fields{
+ List: list.New(),
+ asciiBoxWriter: NewAsciiBoxWriter(),
+ },
+ wantErr: assert.NoError,
+ },
+ }
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ b := &boxedWriteBuffer{
+ BufferCommons: tt.fields.BufferCommons,
+ List: tt.fields.List,
+ desiredWidth: tt.fields.desiredWidth,
+ currentWidth: tt.fields.currentWidth,
+ mergeSingleBoxes: tt.fields.mergeSingleBoxes,
+ omitEmptyBoxes: tt.fields.omitEmptyBoxes,
+ asciiBoxWriter: tt.fields.asciiBoxWriter,
+ asciiBoxWriterLight: tt.fields.asciiBoxWriterLight,
+ pos: tt.fields.pos,
+ }
+ tt.wantErr(t, b.WriteString(tt.args.logicalName, tt.args.bitLength, tt.args.in2, tt.args.value, tt.args.writerArgs...), fmt.Sprintf("WriteString(%v, %v, %v, %v, %v)", tt.args.logicalName, tt.args.bitLength, tt.args.in2, tt.args.value, tt.args.writerArgs))
+ })
+ }
+}
+
+func Test_boxedWriteBuffer_WriteUint16(t *testing.T) {
+ type fields struct {
+ BufferCommons BufferCommons
+ List *list.List
+ desiredWidth int
+ currentWidth int
+ mergeSingleBoxes bool
+ omitEmptyBoxes bool
+ asciiBoxWriter AsciiBoxWriter
+ asciiBoxWriterLight AsciiBoxWriter
+ pos uint
+ }
+ type args struct {
+ logicalName string
+ bitLength uint8
+ value uint16
+ writerArgs []WithWriterArgs
+ }
+ tests := []struct {
+ name string
+ fields fields
+ args args
+ wantErr assert.ErrorAssertionFunc
+ }{
+ {
+ name: "write it",
+ fields: fields{
+ List: list.New(),
+ asciiBoxWriter: NewAsciiBoxWriter(),
+ },
+ wantErr: assert.NoError,
+ },
+ }
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ b := &boxedWriteBuffer{
+ BufferCommons: tt.fields.BufferCommons,
+ List: tt.fields.List,
+ desiredWidth: tt.fields.desiredWidth,
+ currentWidth: tt.fields.currentWidth,
+ mergeSingleBoxes: tt.fields.mergeSingleBoxes,
+ omitEmptyBoxes: tt.fields.omitEmptyBoxes,
+ asciiBoxWriter: tt.fields.asciiBoxWriter,
+ asciiBoxWriterLight: tt.fields.asciiBoxWriterLight,
+ pos: tt.fields.pos,
+ }
+ tt.wantErr(t, b.WriteUint16(tt.args.logicalName, tt.args.bitLength, tt.args.value, tt.args.writerArgs...), fmt.Sprintf("WriteUint16(%v, %v, %v, %v)", tt.args.logicalName, tt.args.bitLength, tt.args.value, tt.args.writerArgs))
+ })
+ }
+}
+
+func Test_boxedWriteBuffer_WriteUint32(t *testing.T) {
+ type fields struct {
+ BufferCommons BufferCommons
+ List *list.List
+ desiredWidth int
+ currentWidth int
+ mergeSingleBoxes bool
+ omitEmptyBoxes bool
+ asciiBoxWriter AsciiBoxWriter
+ asciiBoxWriterLight AsciiBoxWriter
+ pos uint
+ }
+ type args struct {
+ logicalName string
+ bitLength uint8
+ value uint32
+ writerArgs []WithWriterArgs
+ }
+ tests := []struct {
+ name string
+ fields fields
+ args args
+ wantErr assert.ErrorAssertionFunc
+ }{
+ {
+ name: "write it",
+ fields: fields{
+ List: list.New(),
+ asciiBoxWriter: NewAsciiBoxWriter(),
+ },
+ wantErr: assert.NoError,
+ },
+ }
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ b := &boxedWriteBuffer{
+ BufferCommons: tt.fields.BufferCommons,
+ List: tt.fields.List,
+ desiredWidth: tt.fields.desiredWidth,
+ currentWidth: tt.fields.currentWidth,
+ mergeSingleBoxes: tt.fields.mergeSingleBoxes,
+ omitEmptyBoxes: tt.fields.omitEmptyBoxes,
+ asciiBoxWriter: tt.fields.asciiBoxWriter,
+ asciiBoxWriterLight: tt.fields.asciiBoxWriterLight,
+ pos: tt.fields.pos,
+ }
+ tt.wantErr(t, b.WriteUint32(tt.args.logicalName, tt.args.bitLength, tt.args.value, tt.args.writerArgs...), fmt.Sprintf("WriteUint32(%v, %v, %v, %v)", tt.args.logicalName, tt.args.bitLength, tt.args.value, tt.args.writerArgs))
+ })
+ }
+}
+
+func Test_boxedWriteBuffer_WriteUint64(t *testing.T) {
+ type fields struct {
+ BufferCommons BufferCommons
+ List *list.List
+ desiredWidth int
+ currentWidth int
+ mergeSingleBoxes bool
+ omitEmptyBoxes bool
+ asciiBoxWriter AsciiBoxWriter
+ asciiBoxWriterLight AsciiBoxWriter
+ pos uint
+ }
+ type args struct {
+ logicalName string
+ bitLength uint8
+ value uint64
+ writerArgs []WithWriterArgs
+ }
+ tests := []struct {
+ name string
+ fields fields
+ args args
+ wantErr assert.ErrorAssertionFunc
+ }{
+ {
+ name: "write it",
+ fields: fields{
+ List: list.New(),
+ asciiBoxWriter: NewAsciiBoxWriter(),
+ },
+ wantErr: assert.NoError,
+ },
+ }
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ b := &boxedWriteBuffer{
+ BufferCommons: tt.fields.BufferCommons,
+ List: tt.fields.List,
+ desiredWidth: tt.fields.desiredWidth,
+ currentWidth: tt.fields.currentWidth,
+ mergeSingleBoxes: tt.fields.mergeSingleBoxes,
+ omitEmptyBoxes: tt.fields.omitEmptyBoxes,
+ asciiBoxWriter: tt.fields.asciiBoxWriter,
+ asciiBoxWriterLight: tt.fields.asciiBoxWriterLight,
+ pos: tt.fields.pos,
+ }
+ tt.wantErr(t, b.WriteUint64(tt.args.logicalName, tt.args.bitLength, tt.args.value, tt.args.writerArgs...), fmt.Sprintf("WriteUint64(%v, %v, %v, %v)", tt.args.logicalName, tt.args.bitLength, tt.args.value, tt.args.writerArgs))
+ })
+ }
+}
+
+func Test_boxedWriteBuffer_WriteUint8(t *testing.T) {
+ type fields struct {
+ BufferCommons BufferCommons
+ List *list.List
+ desiredWidth int
+ currentWidth int
+ mergeSingleBoxes bool
+ omitEmptyBoxes bool
+ asciiBoxWriter AsciiBoxWriter
+ asciiBoxWriterLight AsciiBoxWriter
+ pos uint
+ }
+ type args struct {
+ logicalName string
+ bitLength uint8
+ value uint8
+ writerArgs []WithWriterArgs
+ }
+ tests := []struct {
+ name string
+ fields fields
+ args args
+ wantErr assert.ErrorAssertionFunc
+ }{
+ {
+ name: "write it",
+ fields: fields{
+ List: list.New(),
+ asciiBoxWriter: NewAsciiBoxWriter(),
+ },
+ wantErr: assert.NoError,
+ },
+ }
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ b := &boxedWriteBuffer{
+ BufferCommons: tt.fields.BufferCommons,
+ List: tt.fields.List,
+ desiredWidth: tt.fields.desiredWidth,
+ currentWidth: tt.fields.currentWidth,
+ mergeSingleBoxes: tt.fields.mergeSingleBoxes,
+ omitEmptyBoxes: tt.fields.omitEmptyBoxes,
+ asciiBoxWriter: tt.fields.asciiBoxWriter,
+ asciiBoxWriterLight: tt.fields.asciiBoxWriterLight,
+ pos: tt.fields.pos,
+ }
+ tt.wantErr(t, b.WriteUint8(tt.args.logicalName, tt.args.bitLength, tt.args.value, tt.args.writerArgs...), fmt.Sprintf("WriteUint8(%v, %v, %v, %v)", tt.args.logicalName, tt.args.bitLength, tt.args.value, tt.args.writerArgs))
+ })
+ }
+}
+
+func Test_boxedWriteBuffer_WriteVirtual(t *testing.T) {
+ type fields struct {
+ BufferCommons BufferCommons
+ List *list.List
+ desiredWidth int
+ currentWidth int
+ mergeSingleBoxes bool
+ omitEmptyBoxes bool
+ asciiBoxWriter AsciiBoxWriter
+ asciiBoxWriterLight AsciiBoxWriter
+ pos uint
+ }
+ type args struct {
+ ctx context.Context
+ logicalName string
+ value any
+ writerArgs []WithWriterArgs
+ }
+ tests := []struct {
+ name string
+ fields fields
+ args args
+ wantErr assert.ErrorAssertionFunc
+ }{
+ {
+ name: "write it",
+ fields: fields{
+ List: list.New(),
+ asciiBoxWriter: NewAsciiBoxWriter(),
+ },
+ wantErr: assert.NoError,
+ },
+ }
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ b := &boxedWriteBuffer{
+ BufferCommons: tt.fields.BufferCommons,
+ List: tt.fields.List,
+ desiredWidth: tt.fields.desiredWidth,
+ currentWidth: tt.fields.currentWidth,
+ mergeSingleBoxes: tt.fields.mergeSingleBoxes,
+ omitEmptyBoxes: tt.fields.omitEmptyBoxes,
+ asciiBoxWriter: tt.fields.asciiBoxWriter,
+ asciiBoxWriterLight: tt.fields.asciiBoxWriterLight,
+ pos: tt.fields.pos,
+ }
+ tt.wantErr(t, b.WriteVirtual(tt.args.ctx, tt.args.logicalName, tt.args.value, tt.args.writerArgs...), fmt.Sprintf("WriteVirtual(%v, %v, %v, %v)", tt.args.ctx, tt.args.logicalName, tt.args.value, tt.args.writerArgs))
+ })
+ }
+}
+
+func Test_boxedWriteBuffer_extractAdditionalStringRepresentation(t *testing.T) {
+ type fields struct {
+ BufferCommons BufferCommons
+ List *list.List
+ desiredWidth int
+ currentWidth int
+ mergeSingleBoxes bool
+ omitEmptyBoxes bool
+ asciiBoxWriter AsciiBoxWriter
+ asciiBoxWriterLight AsciiBoxWriter
+ pos uint
+ }
+ type args struct {
+ readerWriterArgs []WithReaderWriterArgs
+ }
+ tests := []struct {
+ name string
+ fields fields
+ args args
+ want string
+ }{
+ {
+ name: "extract it",
+ },
+ }
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ b := &boxedWriteBuffer{
+ BufferCommons: tt.fields.BufferCommons,
+ List: tt.fields.List,
+ desiredWidth: tt.fields.desiredWidth,
+ currentWidth: tt.fields.currentWidth,
+ mergeSingleBoxes: tt.fields.mergeSingleBoxes,
+ omitEmptyBoxes: tt.fields.omitEmptyBoxes,
+ asciiBoxWriter: tt.fields.asciiBoxWriter,
+ asciiBoxWriterLight: tt.fields.asciiBoxWriterLight,
+ pos: tt.fields.pos,
+ }
+ assert.Equalf(t, tt.want, b.extractAdditionalStringRepresentation(tt.args.readerWriterArgs...), "extractAdditionalStringRepresentation(%v)", tt.args.readerWriterArgs)
+ })
+ }
+}
+
+func Test_boxedWriteBuffer_move(t *testing.T) {
+ type fields struct {
+ BufferCommons BufferCommons
+ List *list.List
+ desiredWidth int
+ currentWidth int
+ mergeSingleBoxes bool
+ omitEmptyBoxes bool
+ asciiBoxWriter AsciiBoxWriter
+ asciiBoxWriterLight AsciiBoxWriter
+ pos uint
+ }
+ type args struct {
+ bits uint
+ }
+ tests := []struct {
+ name string
+ fields fields
+ args args
+ }{
+ {
+ name: "move it",
+ },
+ }
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ b := &boxedWriteBuffer{
+ BufferCommons: tt.fields.BufferCommons,
+ List: tt.fields.List,
+ desiredWidth: tt.fields.desiredWidth,
+ currentWidth: tt.fields.currentWidth,
+ mergeSingleBoxes: tt.fields.mergeSingleBoxes,
+ omitEmptyBoxes: tt.fields.omitEmptyBoxes,
+ asciiBoxWriter: tt.fields.asciiBoxWriter,
+ asciiBoxWriterLight: tt.fields.asciiBoxWriterLight,
+ pos: tt.fields.pos,
+ }
+ b.move(tt.args.bits)
+ })
+ }
+}
diff --git a/plc4go/spi/utils/WriteBufferJsonBased_test.go b/plc4go/spi/utils/WriteBufferJsonBased_test.go
new file mode 100644
index 0000000000..49dc3aeb39
--- /dev/null
+++ b/plc4go/spi/utils/WriteBufferJsonBased_test.go
@@ -0,0 +1,1156 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package utils
+
+import (
+ "context"
+ "encoding/json"
+ "fmt"
+ "github.com/stretchr/testify/assert"
+ "math/big"
+ "strings"
+ "testing"
+)
+
+func TestNewJsonWriteBuffer(t *testing.T) {
+ tests := []struct {
+ name string
+ want WriteBufferJsonBased
+ }{
+ {
+ name: "create it",
+ want: func() WriteBufferJsonBased {
+ var jsonString strings.Builder
+ encoder := json.NewEncoder(&jsonString)
+ encoder.SetIndent("", " ")
+ return &jsonWriteBuffer{
+ jsonString: &jsonString,
+ Encoder: encoder,
+ doRenderAttr: true,
+ }
+ }(),
+ },
+ }
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ assert.Equalf(t, tt.want, NewJsonWriteBuffer(), "NewJsonWriteBuffer()")
+ })
+ }
+}
+
+func TestNewJsonWriteBufferWithOptions(t *testing.T) {
+ type args struct {
+ renderAttr bool
+ }
+ tests := []struct {
+ name string
+ args args
+ want WriteBufferJsonBased
+ }{
+ {
+ name: "create it",
+ want: func() WriteBufferJsonBased {
+ var jsonString strings.Builder
+ encoder := json.NewEncoder(&jsonString)
+ encoder.SetIndent("", " ")
+ return &jsonWriteBuffer{
+ jsonString: &jsonString,
+ Encoder: encoder,
+ doRenderAttr: false,
+ }
+ }(),
+ },
+ }
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ assert.Equalf(t, tt.want, NewJsonWriteBufferWithOptions(tt.args.renderAttr), "NewJsonWriteBufferWithOptions(%v)", tt.args.renderAttr)
+ })
+ }
+}
+
+func Test_jsonWriteBuffer_GetJsonString(t *testing.T) {
+ type fields struct {
+ BufferCommons BufferCommons
+ Stack Stack
+ Encoder *json.Encoder
+ jsonString *strings.Builder
+ rootNode any
+ doRenderAttr bool
+ pos uint
+ }
+ tests := []struct {
+ name string
+ fields fields
+ want string
+ wantErr assert.ErrorAssertionFunc
+ }{
+ {
+ name: "get it (no content)",
+ wantErr: assert.Error,
+ },
+ // TODO: at other tests
+ }
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ j := &jsonWriteBuffer{
+ BufferCommons: tt.fields.BufferCommons,
+ Stack: tt.fields.Stack,
+ Encoder: tt.fields.Encoder,
+ jsonString: tt.fields.jsonString,
+ rootNode: tt.fields.rootNode,
+ doRenderAttr: tt.fields.doRenderAttr,
+ pos: tt.fields.pos,
+ }
+ got, err := j.GetJsonString()
+ if !tt.wantErr(t, err, fmt.Sprintf("GetJsonString()")) {
+ return
+ }
+ assert.Equalf(t, tt.want, got, "GetJsonString()")
+ })
+ }
+}
+
+func Test_jsonWriteBuffer_GetPos(t *testing.T) {
+ type fields struct {
+ BufferCommons BufferCommons
+ Stack Stack
+ Encoder *json.Encoder
+ jsonString *strings.Builder
+ rootNode any
+ doRenderAttr bool
+ pos uint
+ }
+ tests := []struct {
+ name string
+ fields fields
+ want uint16
+ }{
+ {
+ name: "get it",
+ },
+ }
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ j := &jsonWriteBuffer{
+ BufferCommons: tt.fields.BufferCommons,
+ Stack: tt.fields.Stack,
+ Encoder: tt.fields.Encoder,
+ jsonString: tt.fields.jsonString,
+ rootNode: tt.fields.rootNode,
+ doRenderAttr: tt.fields.doRenderAttr,
+ pos: tt.fields.pos,
+ }
+ assert.Equalf(t, tt.want, j.GetPos(), "GetPos()")
+ })
+ }
+}
+
+func Test_jsonWriteBuffer_PopContext(t *testing.T) {
+ type fields struct {
+ BufferCommons BufferCommons
+ Stack Stack
+ Encoder *json.Encoder
+ jsonString *strings.Builder
+ rootNode any
+ doRenderAttr bool
+ pos uint
+ }
+ type args struct {
+ logicalName string
+ in1 []WithWriterArgs
+ }
+ tests := []struct {
+ name string
+ fields fields
+ args args
+ wantErr assert.ErrorAssertionFunc
+ }{
+ {
+ name: "pop it",
+ wantErr: assert.Error,
+ },
+ // TODO: write other tests...
+ }
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ j := &jsonWriteBuffer{
+ BufferCommons: tt.fields.BufferCommons,
+ Stack: tt.fields.Stack,
+ Encoder: tt.fields.Encoder,
+ jsonString: tt.fields.jsonString,
+ rootNode: tt.fields.rootNode,
+ doRenderAttr: tt.fields.doRenderAttr,
+ pos: tt.fields.pos,
+ }
+ tt.wantErr(t, j.PopContext(tt.args.logicalName, tt.args.in1...), fmt.Sprintf("PopContext(%v, %v)", tt.args.logicalName, tt.args.in1))
+ })
+ }
+}
+
+func Test_jsonWriteBuffer_PushContext(t *testing.T) {
+ type fields struct {
+ BufferCommons BufferCommons
+ Stack Stack
+ Encoder *json.Encoder
+ jsonString *strings.Builder
+ rootNode any
+ doRenderAttr bool
+ pos uint
+ }
+ type args struct {
+ logicalName string
+ writerArgs []WithWriterArgs
+ }
+ tests := []struct {
+ name string
+ fields fields
+ args args
+ wantErr assert.ErrorAssertionFunc
+ }{
+ {
+ name: "push it",
+ wantErr: assert.NoError,
+ },
+ }
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ j := &jsonWriteBuffer{
+ BufferCommons: tt.fields.BufferCommons,
+ Stack: tt.fields.Stack,
+ Encoder: tt.fields.Encoder,
+ jsonString: tt.fields.jsonString,
+ rootNode: tt.fields.rootNode,
+ doRenderAttr: tt.fields.doRenderAttr,
+ pos: tt.fields.pos,
+ }
+ tt.wantErr(t, j.PushContext(tt.args.logicalName, tt.args.writerArgs...), fmt.Sprintf("PushContext(%v, %v)", tt.args.logicalName, tt.args.writerArgs))
+ })
+ }
+}
+
+func Test_jsonWriteBuffer_WriteBigFloat(t *testing.T) {
+ type fields struct {
+ BufferCommons BufferCommons
+ Stack Stack
+ Encoder *json.Encoder
+ jsonString *strings.Builder
+ rootNode any
+ doRenderAttr bool
+ pos uint
+ }
+ type args struct {
+ logicalName string
+ bitLength uint8
+ value *big.Float
+ writerArgs []WithWriterArgs
+ }
+ tests := []struct {
+ name string
+ fields fields
+ args args
+ wantErr assert.ErrorAssertionFunc
+ }{
+ {
+ name: "write it",
+ wantErr: assert.NoError,
+ },
+ }
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ j := &jsonWriteBuffer{
+ BufferCommons: tt.fields.BufferCommons,
+ Stack: tt.fields.Stack,
+ Encoder: tt.fields.Encoder,
+ jsonString: tt.fields.jsonString,
+ rootNode: tt.fields.rootNode,
+ doRenderAttr: tt.fields.doRenderAttr,
+ pos: tt.fields.pos,
+ }
+ tt.wantErr(t, j.WriteBigFloat(tt.args.logicalName, tt.args.bitLength, tt.args.value, tt.args.writerArgs...), fmt.Sprintf("WriteBigFloat(%v, %v, %v, %v)", tt.args.logicalName, tt.args.bitLength, tt.args.value, tt.args.writerArgs))
+ })
+ }
+}
+
+func Test_jsonWriteBuffer_WriteBigInt(t *testing.T) {
+ type fields struct {
+ BufferCommons BufferCommons
+ Stack Stack
+ Encoder *json.Encoder
+ jsonString *strings.Builder
+ rootNode any
+ doRenderAttr bool
+ pos uint
+ }
+ type args struct {
+ logicalName string
+ bitLength uint8
+ value *big.Int
+ writerArgs []WithWriterArgs
+ }
+ tests := []struct {
+ name string
+ fields fields
+ args args
+ wantErr assert.ErrorAssertionFunc
+ }{
+ {
+ name: "write it",
+ wantErr: assert.NoError,
+ },
+ }
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ j := &jsonWriteBuffer{
+ BufferCommons: tt.fields.BufferCommons,
+ Stack: tt.fields.Stack,
+ Encoder: tt.fields.Encoder,
+ jsonString: tt.fields.jsonString,
+ rootNode: tt.fields.rootNode,
+ doRenderAttr: tt.fields.doRenderAttr,
+ pos: tt.fields.pos,
+ }
+ tt.wantErr(t, j.WriteBigInt(tt.args.logicalName, tt.args.bitLength, tt.args.value, tt.args.writerArgs...), fmt.Sprintf("WriteBigInt(%v, %v, %v, %v)", tt.args.logicalName, tt.args.bitLength, tt.args.value, tt.args.writerArgs))
+ })
+ }
+}
+
+func Test_jsonWriteBuffer_WriteBit(t *testing.T) {
+ type fields struct {
+ BufferCommons BufferCommons
+ Stack Stack
+ Encoder *json.Encoder
+ jsonString *strings.Builder
+ rootNode any
+ doRenderAttr bool
+ pos uint
+ }
+ type args struct {
+ logicalName string
+ value bool
+ writerArgs []WithWriterArgs
+ }
+ tests := []struct {
+ name string
+ fields fields
+ args args
+ wantErr assert.ErrorAssertionFunc
+ }{
+ {
+ name: "write it",
+ wantErr: assert.NoError,
+ },
+ }
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ j := &jsonWriteBuffer{
+ BufferCommons: tt.fields.BufferCommons,
+ Stack: tt.fields.Stack,
+ Encoder: tt.fields.Encoder,
+ jsonString: tt.fields.jsonString,
+ rootNode: tt.fields.rootNode,
+ doRenderAttr: tt.fields.doRenderAttr,
+ pos: tt.fields.pos,
+ }
+ tt.wantErr(t, j.WriteBit(tt.args.logicalName, tt.args.value, tt.args.writerArgs...), fmt.Sprintf("WriteBit(%v, %v, %v)", tt.args.logicalName, tt.args.value, tt.args.writerArgs))
+ })
+ }
+}
+
+func Test_jsonWriteBuffer_WriteByte(t *testing.T) {
+ type fields struct {
+ BufferCommons BufferCommons
+ Stack Stack
+ Encoder *json.Encoder
+ jsonString *strings.Builder
+ rootNode any
+ doRenderAttr bool
+ pos uint
+ }
+ type args struct {
+ logicalName string
+ value byte
+ writerArgs []WithWriterArgs
+ }
+ tests := []struct {
+ name string
+ fields fields
+ args args
+ wantErr assert.ErrorAssertionFunc
+ }{
+ {
+ name: "write it",
+ wantErr: assert.NoError,
+ },
+ }
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ j := &jsonWriteBuffer{
+ BufferCommons: tt.fields.BufferCommons,
+ Stack: tt.fields.Stack,
+ Encoder: tt.fields.Encoder,
+ jsonString: tt.fields.jsonString,
+ rootNode: tt.fields.rootNode,
+ doRenderAttr: tt.fields.doRenderAttr,
+ pos: tt.fields.pos,
+ }
+ tt.wantErr(t, j.WriteByte(tt.args.logicalName, tt.args.value, tt.args.writerArgs...), fmt.Sprintf("WriteByte(%v, %v, %v)", tt.args.logicalName, tt.args.value, tt.args.writerArgs))
+ })
+ }
+}
+
+func Test_jsonWriteBuffer_WriteByteArray(t *testing.T) {
+ type fields struct {
+ BufferCommons BufferCommons
+ Stack Stack
+ Encoder *json.Encoder
+ jsonString *strings.Builder
+ rootNode any
+ doRenderAttr bool
+ pos uint
+ }
+ type args struct {
+ logicalName string
+ data []byte
+ writerArgs []WithWriterArgs
+ }
+ tests := []struct {
+ name string
+ fields fields
+ args args
+ wantErr assert.ErrorAssertionFunc
+ }{
+ {
+ name: "write it",
+ wantErr: assert.NoError,
+ },
+ }
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ j := &jsonWriteBuffer{
+ BufferCommons: tt.fields.BufferCommons,
+ Stack: tt.fields.Stack,
+ Encoder: tt.fields.Encoder,
+ jsonString: tt.fields.jsonString,
+ rootNode: tt.fields.rootNode,
+ doRenderAttr: tt.fields.doRenderAttr,
+ pos: tt.fields.pos,
+ }
+ tt.wantErr(t, j.WriteByteArray(tt.args.logicalName, tt.args.data, tt.args.writerArgs...), fmt.Sprintf("WriteByteArray(%v, %v, %v)", tt.args.logicalName, tt.args.data, tt.args.writerArgs))
+ })
+ }
+}
+
+func Test_jsonWriteBuffer_WriteFloat32(t *testing.T) {
+ type fields struct {
+ BufferCommons BufferCommons
+ Stack Stack
+ Encoder *json.Encoder
+ jsonString *strings.Builder
+ rootNode any
+ doRenderAttr bool
+ pos uint
+ }
+ type args struct {
+ logicalName string
+ bitLength uint8
+ value float32
+ writerArgs []WithWriterArgs
+ }
+ tests := []struct {
+ name string
+ fields fields
+ args args
+ wantErr assert.ErrorAssertionFunc
+ }{
+ {
+ name: "write it",
+ wantErr: assert.NoError,
+ },
+ }
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ j := &jsonWriteBuffer{
+ BufferCommons: tt.fields.BufferCommons,
+ Stack: tt.fields.Stack,
+ Encoder: tt.fields.Encoder,
+ jsonString: tt.fields.jsonString,
+ rootNode: tt.fields.rootNode,
+ doRenderAttr: tt.fields.doRenderAttr,
+ pos: tt.fields.pos,
+ }
+ tt.wantErr(t, j.WriteFloat32(tt.args.logicalName, tt.args.bitLength, tt.args.value, tt.args.writerArgs...), fmt.Sprintf("WriteFloat32(%v, %v, %v, %v)", tt.args.logicalName, tt.args.bitLength, tt.args.value, tt.args.writerArgs))
+ })
+ }
+}
+
+func Test_jsonWriteBuffer_WriteFloat64(t *testing.T) {
+ type fields struct {
+ BufferCommons BufferCommons
+ Stack Stack
+ Encoder *json.Encoder
+ jsonString *strings.Builder
+ rootNode any
+ doRenderAttr bool
+ pos uint
+ }
+ type args struct {
+ logicalName string
+ bitLength uint8
+ value float64
+ writerArgs []WithWriterArgs
+ }
+ tests := []struct {
+ name string
+ fields fields
+ args args
+ wantErr assert.ErrorAssertionFunc
+ }{
+ {
+ name: "write it",
+ wantErr: assert.NoError,
+ },
+ }
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ j := &jsonWriteBuffer{
+ BufferCommons: tt.fields.BufferCommons,
+ Stack: tt.fields.Stack,
+ Encoder: tt.fields.Encoder,
+ jsonString: tt.fields.jsonString,
+ rootNode: tt.fields.rootNode,
+ doRenderAttr: tt.fields.doRenderAttr,
+ pos: tt.fields.pos,
+ }
+ tt.wantErr(t, j.WriteFloat64(tt.args.logicalName, tt.args.bitLength, tt.args.value, tt.args.writerArgs...), fmt.Sprintf("WriteFloat64(%v, %v, %v, %v)", tt.args.logicalName, tt.args.bitLength, tt.args.value, tt.args.writerArgs))
+ })
+ }
+}
+
+func Test_jsonWriteBuffer_WriteInt16(t *testing.T) {
+ type fields struct {
+ BufferCommons BufferCommons
+ Stack Stack
+ Encoder *json.Encoder
+ jsonString *strings.Builder
+ rootNode any
+ doRenderAttr bool
+ pos uint
+ }
+ type args struct {
+ logicalName string
+ bitLength uint8
+ value int16
+ writerArgs []WithWriterArgs
+ }
+ tests := []struct {
+ name string
+ fields fields
+ args args
+ wantErr assert.ErrorAssertionFunc
+ }{
+ {
+ name: "write it",
+ wantErr: assert.NoError,
+ },
+ }
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ j := &jsonWriteBuffer{
+ BufferCommons: tt.fields.BufferCommons,
+ Stack: tt.fields.Stack,
+ Encoder: tt.fields.Encoder,
+ jsonString: tt.fields.jsonString,
+ rootNode: tt.fields.rootNode,
+ doRenderAttr: tt.fields.doRenderAttr,
+ pos: tt.fields.pos,
+ }
+ tt.wantErr(t, j.WriteInt16(tt.args.logicalName, tt.args.bitLength, tt.args.value, tt.args.writerArgs...), fmt.Sprintf("WriteInt16(%v, %v, %v, %v)", tt.args.logicalName, tt.args.bitLength, tt.args.value, tt.args.writerArgs))
+ })
+ }
+}
+
+func Test_jsonWriteBuffer_WriteInt32(t *testing.T) {
+ type fields struct {
+ BufferCommons BufferCommons
+ Stack Stack
+ Encoder *json.Encoder
+ jsonString *strings.Builder
+ rootNode any
+ doRenderAttr bool
+ pos uint
+ }
+ type args struct {
+ logicalName string
+ bitLength uint8
+ value int32
+ writerArgs []WithWriterArgs
+ }
+ tests := []struct {
+ name string
+ fields fields
+ args args
+ wantErr assert.ErrorAssertionFunc
+ }{
+ {
+ name: "write it",
+ wantErr: assert.NoError,
+ },
+ }
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ j := &jsonWriteBuffer{
+ BufferCommons: tt.fields.BufferCommons,
+ Stack: tt.fields.Stack,
+ Encoder: tt.fields.Encoder,
+ jsonString: tt.fields.jsonString,
+ rootNode: tt.fields.rootNode,
+ doRenderAttr: tt.fields.doRenderAttr,
+ pos: tt.fields.pos,
+ }
+ tt.wantErr(t, j.WriteInt32(tt.args.logicalName, tt.args.bitLength, tt.args.value, tt.args.writerArgs...), fmt.Sprintf("WriteInt32(%v, %v, %v, %v)", tt.args.logicalName, tt.args.bitLength, tt.args.value, tt.args.writerArgs))
+ })
+ }
+}
+
+func Test_jsonWriteBuffer_WriteInt64(t *testing.T) {
+ type fields struct {
+ BufferCommons BufferCommons
+ Stack Stack
+ Encoder *json.Encoder
+ jsonString *strings.Builder
+ rootNode any
+ doRenderAttr bool
+ pos uint
+ }
+ type args struct {
+ logicalName string
+ bitLength uint8
+ value int64
+ writerArgs []WithWriterArgs
+ }
+ tests := []struct {
+ name string
+ fields fields
+ args args
+ wantErr assert.ErrorAssertionFunc
+ }{
+ {
+ name: "write it",
+ wantErr: assert.NoError,
+ },
+ }
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ j := &jsonWriteBuffer{
+ BufferCommons: tt.fields.BufferCommons,
+ Stack: tt.fields.Stack,
+ Encoder: tt.fields.Encoder,
+ jsonString: tt.fields.jsonString,
+ rootNode: tt.fields.rootNode,
+ doRenderAttr: tt.fields.doRenderAttr,
+ pos: tt.fields.pos,
+ }
+ tt.wantErr(t, j.WriteInt64(tt.args.logicalName, tt.args.bitLength, tt.args.value, tt.args.writerArgs...), fmt.Sprintf("WriteInt64(%v, %v, %v, %v)", tt.args.logicalName, tt.args.bitLength, tt.args.value, tt.args.writerArgs))
+ })
+ }
+}
+
+func Test_jsonWriteBuffer_WriteInt8(t *testing.T) {
+ type fields struct {
+ BufferCommons BufferCommons
+ Stack Stack
+ Encoder *json.Encoder
+ jsonString *strings.Builder
+ rootNode any
+ doRenderAttr bool
+ pos uint
+ }
+ type args struct {
+ logicalName string
+ bitLength uint8
+ value int8
+ writerArgs []WithWriterArgs
+ }
+ tests := []struct {
+ name string
+ fields fields
+ args args
+ wantErr assert.ErrorAssertionFunc
+ }{
+ {
+ name: "write it",
+ wantErr: assert.NoError,
+ },
+ }
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ j := &jsonWriteBuffer{
+ BufferCommons: tt.fields.BufferCommons,
+ Stack: tt.fields.Stack,
+ Encoder: tt.fields.Encoder,
+ jsonString: tt.fields.jsonString,
+ rootNode: tt.fields.rootNode,
+ doRenderAttr: tt.fields.doRenderAttr,
+ pos: tt.fields.pos,
+ }
+ tt.wantErr(t, j.WriteInt8(tt.args.logicalName, tt.args.bitLength, tt.args.value, tt.args.writerArgs...), fmt.Sprintf("WriteInt8(%v, %v, %v, %v)", tt.args.logicalName, tt.args.bitLength, tt.args.value, tt.args.writerArgs))
+ })
+ }
+}
+
+func Test_jsonWriteBuffer_WriteSerializable(t *testing.T) {
+ type fields struct {
+ BufferCommons BufferCommons
+ Stack Stack
+ Encoder *json.Encoder
+ jsonString *strings.Builder
+ rootNode any
+ doRenderAttr bool
+ pos uint
+ }
+ type args struct {
+ ctx context.Context
+ serializable Serializable
+ }
+ tests := []struct {
+ name string
+ fields fields
+ args args
+ wantErr assert.ErrorAssertionFunc
+ }{
+ {
+ name: "write it",
+ wantErr: assert.NoError,
+ },
+ }
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ j := &jsonWriteBuffer{
+ BufferCommons: tt.fields.BufferCommons,
+ Stack: tt.fields.Stack,
+ Encoder: tt.fields.Encoder,
+ jsonString: tt.fields.jsonString,
+ rootNode: tt.fields.rootNode,
+ doRenderAttr: tt.fields.doRenderAttr,
+ pos: tt.fields.pos,
+ }
+ tt.wantErr(t, j.WriteSerializable(tt.args.ctx, tt.args.serializable), fmt.Sprintf("WriteSerializable(%v, %v)", tt.args.ctx, tt.args.serializable))
+ })
+ }
+}
+
+func Test_jsonWriteBuffer_WriteString(t *testing.T) {
+ type fields struct {
+ BufferCommons BufferCommons
+ Stack Stack
+ Encoder *json.Encoder
+ jsonString *strings.Builder
+ rootNode any
+ doRenderAttr bool
+ pos uint
+ }
+ type args struct {
+ logicalName string
+ bitLength uint32
+ encoding string
+ value string
+ writerArgs []WithWriterArgs
+ }
+ tests := []struct {
+ name string
+ fields fields
+ args args
+ wantErr assert.ErrorAssertionFunc
+ }{
+ {
+ name: "write it",
+ wantErr: assert.NoError,
+ },
+ }
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ j := &jsonWriteBuffer{
+ BufferCommons: tt.fields.BufferCommons,
+ Stack: tt.fields.Stack,
+ Encoder: tt.fields.Encoder,
+ jsonString: tt.fields.jsonString,
+ rootNode: tt.fields.rootNode,
+ doRenderAttr: tt.fields.doRenderAttr,
+ pos: tt.fields.pos,
+ }
+ tt.wantErr(t, j.WriteString(tt.args.logicalName, tt.args.bitLength, tt.args.encoding, tt.args.value, tt.args.writerArgs...), fmt.Sprintf("WriteString(%v, %v, %v, %v, %v)", tt.args.logicalName, tt.args.bitLength, tt.args.encoding, tt.args.value, tt.args.writerArgs))
+ })
+ }
+}
+
+func Test_jsonWriteBuffer_WriteUint16(t *testing.T) {
+ type fields struct {
+ BufferCommons BufferCommons
+ Stack Stack
+ Encoder *json.Encoder
+ jsonString *strings.Builder
+ rootNode any
+ doRenderAttr bool
+ pos uint
+ }
+ type args struct {
+ logicalName string
+ bitLength uint8
+ value uint16
+ writerArgs []WithWriterArgs
+ }
+ tests := []struct {
+ name string
+ fields fields
+ args args
+ wantErr assert.ErrorAssertionFunc
+ }{
+ {
+ name: "write it",
+ wantErr: assert.NoError,
+ },
+ }
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ j := &jsonWriteBuffer{
+ BufferCommons: tt.fields.BufferCommons,
+ Stack: tt.fields.Stack,
+ Encoder: tt.fields.Encoder,
+ jsonString: tt.fields.jsonString,
+ rootNode: tt.fields.rootNode,
+ doRenderAttr: tt.fields.doRenderAttr,
+ pos: tt.fields.pos,
+ }
+ tt.wantErr(t, j.WriteUint16(tt.args.logicalName, tt.args.bitLength, tt.args.value, tt.args.writerArgs...), fmt.Sprintf("WriteUint16(%v, %v, %v, %v)", tt.args.logicalName, tt.args.bitLength, tt.args.value, tt.args.writerArgs))
+ })
+ }
+}
+
+func Test_jsonWriteBuffer_WriteUint32(t *testing.T) {
+ type fields struct {
+ BufferCommons BufferCommons
+ Stack Stack
+ Encoder *json.Encoder
+ jsonString *strings.Builder
+ rootNode any
+ doRenderAttr bool
+ pos uint
+ }
+ type args struct {
+ logicalName string
+ bitLength uint8
+ value uint32
+ writerArgs []WithWriterArgs
+ }
+ tests := []struct {
+ name string
+ fields fields
+ args args
+ wantErr assert.ErrorAssertionFunc
+ }{
+ {
+ name: "write it",
+ wantErr: assert.NoError,
+ },
+ }
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ j := &jsonWriteBuffer{
+ BufferCommons: tt.fields.BufferCommons,
+ Stack: tt.fields.Stack,
+ Encoder: tt.fields.Encoder,
+ jsonString: tt.fields.jsonString,
+ rootNode: tt.fields.rootNode,
+ doRenderAttr: tt.fields.doRenderAttr,
+ pos: tt.fields.pos,
+ }
+ tt.wantErr(t, j.WriteUint32(tt.args.logicalName, tt.args.bitLength, tt.args.value, tt.args.writerArgs...), fmt.Sprintf("WriteUint32(%v, %v, %v, %v)", tt.args.logicalName, tt.args.bitLength, tt.args.value, tt.args.writerArgs))
+ })
+ }
+}
+
+func Test_jsonWriteBuffer_WriteUint64(t *testing.T) {
+ type fields struct {
+ BufferCommons BufferCommons
+ Stack Stack
+ Encoder *json.Encoder
+ jsonString *strings.Builder
+ rootNode any
+ doRenderAttr bool
+ pos uint
+ }
+ type args struct {
+ logicalName string
+ bitLength uint8
+ value uint64
+ writerArgs []WithWriterArgs
+ }
+ tests := []struct {
+ name string
+ fields fields
+ args args
+ wantErr assert.ErrorAssertionFunc
+ }{
+ {
+ name: "write it",
+ wantErr: assert.NoError,
+ },
+ }
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ j := &jsonWriteBuffer{
+ BufferCommons: tt.fields.BufferCommons,
+ Stack: tt.fields.Stack,
+ Encoder: tt.fields.Encoder,
+ jsonString: tt.fields.jsonString,
+ rootNode: tt.fields.rootNode,
+ doRenderAttr: tt.fields.doRenderAttr,
+ pos: tt.fields.pos,
+ }
+ tt.wantErr(t, j.WriteUint64(tt.args.logicalName, tt.args.bitLength, tt.args.value, tt.args.writerArgs...), fmt.Sprintf("WriteUint64(%v, %v, %v, %v)", tt.args.logicalName, tt.args.bitLength, tt.args.value, tt.args.writerArgs))
+ })
+ }
+}
+
+func Test_jsonWriteBuffer_WriteUint8(t *testing.T) {
+ type fields struct {
+ BufferCommons BufferCommons
+ Stack Stack
+ Encoder *json.Encoder
+ jsonString *strings.Builder
+ rootNode any
+ doRenderAttr bool
+ pos uint
+ }
+ type args struct {
+ logicalName string
+ bitLength uint8
+ value uint8
+ writerArgs []WithWriterArgs
+ }
+ tests := []struct {
+ name string
+ fields fields
+ args args
+ wantErr assert.ErrorAssertionFunc
+ }{
+ {
+ name: "write it",
+ wantErr: assert.NoError,
+ },
+ }
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ j := &jsonWriteBuffer{
+ BufferCommons: tt.fields.BufferCommons,
+ Stack: tt.fields.Stack,
+ Encoder: tt.fields.Encoder,
+ jsonString: tt.fields.jsonString,
+ rootNode: tt.fields.rootNode,
+ doRenderAttr: tt.fields.doRenderAttr,
+ pos: tt.fields.pos,
+ }
+ tt.wantErr(t, j.WriteUint8(tt.args.logicalName, tt.args.bitLength, tt.args.value, tt.args.writerArgs...), fmt.Sprintf("WriteUint8(%v, %v, %v, %v)", tt.args.logicalName, tt.args.bitLength, tt.args.value, tt.args.writerArgs))
+ })
+ }
+}
+
+func Test_jsonWriteBuffer_WriteVirtual(t *testing.T) {
+ type fields struct {
+ BufferCommons BufferCommons
+ Stack Stack
+ Encoder *json.Encoder
+ jsonString *strings.Builder
+ rootNode any
+ doRenderAttr bool
+ pos uint
+ }
+ type args struct {
+ ctx context.Context
+ logicalName string
+ value any
+ writerArgs []WithWriterArgs
+ }
+ tests := []struct {
+ name string
+ fields fields
+ args args
+ wantErr assert.ErrorAssertionFunc
+ }{
+ {
+ name: "write it",
+ wantErr: assert.NoError,
+ },
+ }
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ j := &jsonWriteBuffer{
+ BufferCommons: tt.fields.BufferCommons,
+ Stack: tt.fields.Stack,
+ Encoder: tt.fields.Encoder,
+ jsonString: tt.fields.jsonString,
+ rootNode: tt.fields.rootNode,
+ doRenderAttr: tt.fields.doRenderAttr,
+ pos: tt.fields.pos,
+ }
+ tt.wantErr(t, j.WriteVirtual(tt.args.ctx, tt.args.logicalName, tt.args.value, tt.args.writerArgs...), fmt.Sprintf("WriteVirtual(%v, %v, %v, %v)", tt.args.ctx, tt.args.logicalName, tt.args.value, tt.args.writerArgs))
+ })
+ }
+}
+
+func Test_jsonWriteBuffer_encodeNode(t *testing.T) {
+ type fields struct {
+ BufferCommons BufferCommons
+ Stack Stack
+ Encoder *json.Encoder
+ jsonString *strings.Builder
+ rootNode any
+ doRenderAttr bool
+ pos uint
+ }
+ type args struct {
+ logicalName string
+ value any
+ attr map[string]any
+ in3 []WithWriterArgs
+ }
+ tests := []struct {
+ name string
+ fields fields
+ args args
+ wantErr assert.ErrorAssertionFunc
+ }{
+ {
+ name: "encode it",
+ wantErr: assert.NoError,
+ },
+ }
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ j := &jsonWriteBuffer{
+ BufferCommons: tt.fields.BufferCommons,
+ Stack: tt.fields.Stack,
+ Encoder: tt.fields.Encoder,
+ jsonString: tt.fields.jsonString,
+ rootNode: tt.fields.rootNode,
+ doRenderAttr: tt.fields.doRenderAttr,
+ pos: tt.fields.pos,
+ }
+ tt.wantErr(t, j.encodeNode(tt.args.logicalName, tt.args.value, tt.args.attr, tt.args.in3...), fmt.Sprintf("encodeNode(%v, %v, %v, %v)", tt.args.logicalName, tt.args.value, tt.args.attr, tt.args.in3))
+ })
+ }
+}
+
+func Test_jsonWriteBuffer_generateAttr(t *testing.T) {
+ type fields struct {
+ BufferCommons BufferCommons
+ Stack Stack
+ Encoder *json.Encoder
+ jsonString *strings.Builder
+ rootNode any
+ doRenderAttr bool
+ pos uint
+ }
+ type args struct {
+ logicalName string
+ dataType string
+ bitLength uint
+ writerArgs []WithWriterArgs
+ }
+ tests := []struct {
+ name string
+ fields fields
+ args args
+ want map[string]any
+ }{
+ {
+ name: "generate it (disabled)",
+ want: map[string]any{},
+ },
+ {
+ name: "generate it",
+ fields: fields{
+ doRenderAttr: true,
+ },
+ args: args{
+ writerArgs: []WithWriterArgs{
+ WithAdditionalStringRepresentation("nope"),
+ },
+ },
+ want: map[string]any{
+ "value__plc4x_bitLength": uint(0x0),
+ "value__plc4x_dataType": "",
+ "value__plc4x_stringRepresentation": "nope",
+ },
+ },
+ }
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ j := &jsonWriteBuffer{
+ BufferCommons: tt.fields.BufferCommons,
+ Stack: tt.fields.Stack,
+ Encoder: tt.fields.Encoder,
+ jsonString: tt.fields.jsonString,
+ rootNode: tt.fields.rootNode,
+ doRenderAttr: tt.fields.doRenderAttr,
+ pos: tt.fields.pos,
+ }
+ assert.Equalf(t, tt.want, j.generateAttr(tt.args.logicalName, tt.args.dataType, tt.args.bitLength, tt.args.writerArgs...), "generateAttr(%v, %v, %v, %v)", tt.args.logicalName, tt.args.dataType, tt.args.bitLength, tt.args.writerArgs)
+ })
+ }
+}
+
+func Test_jsonWriteBuffer_move(t *testing.T) {
+ type fields struct {
+ BufferCommons BufferCommons
+ Stack Stack
+ Encoder *json.Encoder
+ jsonString *strings.Builder
+ rootNode any
+ doRenderAttr bool
+ pos uint
+ }
+ type args struct {
+ bits uint
+ }
+ tests := []struct {
+ name string
+ fields fields
+ args args
+ }{
+ {
+ name: "move it",
+ },
+ }
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ j := &jsonWriteBuffer{
+ BufferCommons: tt.fields.BufferCommons,
+ Stack: tt.fields.Stack,
+ Encoder: tt.fields.Encoder,
+ jsonString: tt.fields.jsonString,
+ rootNode: tt.fields.rootNode,
+ doRenderAttr: tt.fields.doRenderAttr,
+ pos: tt.fields.pos,
+ }
+ j.move(tt.args.bits)
+ })
+ }
+}
diff --git a/plc4go/spi/utils/WriteBufferXmlBased_test.go b/plc4go/spi/utils/WriteBufferXmlBased_test.go
new file mode 100644
index 0000000000..8c2c5efd80
--- /dev/null
+++ b/plc4go/spi/utils/WriteBufferXmlBased_test.go
@@ -0,0 +1,1251 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package utils
+
+import (
+ "context"
+ "encoding/xml"
+ "fmt"
+ "github.com/stretchr/testify/assert"
+ "math/big"
+ "strings"
+ "testing"
+)
+
+func TestNewConfiguredXmlWriteBuffer(t *testing.T) {
+ type args struct {
+ renderLists bool
+ renderAttr bool
+ }
+ tests := []struct {
+ name string
+ args args
+ want WriteBufferXmlBased
+ }{
+ {
+ name: "create it",
+ want: func() WriteBufferXmlBased {
+ var xmlString strings.Builder
+ encoder := xml.NewEncoder(&xmlString)
+ encoder.Indent("", " ")
+ return &xmlWriteBuffer{
+ xmlString: &xmlString,
+ Encoder: encoder,
+ doRenderLists: false,
+ doRenderAttr: false,
+ }
+ }(),
+ },
+ }
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ assert.Equalf(t, tt.want, NewConfiguredXmlWriteBuffer(tt.args.renderLists, tt.args.renderAttr), "NewConfiguredXmlWriteBuffer(%v, %v)", tt.args.renderLists, tt.args.renderAttr)
+ })
+ }
+}
+
+func TestNewXmlWriteBuffer(t *testing.T) {
+ tests := []struct {
+ name string
+ want WriteBufferXmlBased
+ }{
+ {
+ name: "create it",
+ want: func() WriteBufferXmlBased {
+ var xmlString strings.Builder
+ encoder := xml.NewEncoder(&xmlString)
+ encoder.Indent("", " ")
+ return &xmlWriteBuffer{
+ xmlString: &xmlString,
+ Encoder: encoder,
+ doRenderLists: true,
+ doRenderAttr: true,
+ }
+ }(),
+ },
+ }
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ assert.Equalf(t, tt.want, NewXmlWriteBuffer(), "NewXmlWriteBuffer()")
+ })
+ }
+}
+
+func Test_xmlWriteBuffer_GetPos(t *testing.T) {
+ type fields struct {
+ BufferCommons BufferCommons
+ xmlString *strings.Builder
+ Encoder *xml.Encoder
+ doRenderLists bool
+ doRenderAttr bool
+ pos uint
+ }
+ tests := []struct {
+ name string
+ fields fields
+ want uint16
+ }{
+ {
+ name: "get it",
+ },
+ }
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ x := &xmlWriteBuffer{
+ BufferCommons: tt.fields.BufferCommons,
+ xmlString: tt.fields.xmlString,
+ Encoder: tt.fields.Encoder,
+ doRenderLists: tt.fields.doRenderLists,
+ doRenderAttr: tt.fields.doRenderAttr,
+ pos: tt.fields.pos,
+ }
+ assert.Equalf(t, tt.want, x.GetPos(), "GetPos()")
+ })
+ }
+}
+
+func Test_xmlWriteBuffer_GetXmlString(t *testing.T) {
+ type fields struct {
+ BufferCommons BufferCommons
+ xmlString *strings.Builder
+ Encoder *xml.Encoder
+ doRenderLists bool
+ doRenderAttr bool
+ pos uint
+ }
+ tests := []struct {
+ name string
+ fields fields
+ want string
+ }{
+ {
+ name: "get it",
+ fields: fields{
+ xmlString: &strings.Builder{},
+ },
+ },
+ }
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ x := &xmlWriteBuffer{
+ BufferCommons: tt.fields.BufferCommons,
+ xmlString: tt.fields.xmlString,
+ Encoder: tt.fields.Encoder,
+ doRenderLists: tt.fields.doRenderLists,
+ doRenderAttr: tt.fields.doRenderAttr,
+ pos: tt.fields.pos,
+ }
+ assert.Equalf(t, tt.want, x.GetXmlString(), "GetXmlString()")
+ })
+ }
+}
+
+func Test_xmlWriteBuffer_PopContext(t *testing.T) {
+ type fields struct {
+ BufferCommons BufferCommons
+ xmlString *strings.Builder
+ Encoder *xml.Encoder
+ doRenderLists bool
+ doRenderAttr bool
+ pos uint
+ }
+ type args struct {
+ logicalName string
+ in1 []WithWriterArgs
+ }
+ tests := []struct {
+ name string
+ fields fields
+ args args
+ wantErr assert.ErrorAssertionFunc
+ }{
+ {
+ name: "pop it (not context)",
+ fields: fields{
+ Encoder: func() *xml.Encoder {
+ var xmlString strings.Builder
+ return xml.NewEncoder(&xmlString)
+ }(),
+ },
+ wantErr: assert.Error,
+ },
+ }
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ x := &xmlWriteBuffer{
+ BufferCommons: tt.fields.BufferCommons,
+ xmlString: tt.fields.xmlString,
+ Encoder: tt.fields.Encoder,
+ doRenderLists: tt.fields.doRenderLists,
+ doRenderAttr: tt.fields.doRenderAttr,
+ pos: tt.fields.pos,
+ }
+ tt.wantErr(t, x.PopContext(tt.args.logicalName, tt.args.in1...), fmt.Sprintf("PopContext(%v, %v)", tt.args.logicalName, tt.args.in1))
+ })
+ }
+}
+
+func Test_xmlWriteBuffer_PushContext(t *testing.T) {
+ type fields struct {
+ BufferCommons BufferCommons
+ xmlString *strings.Builder
+ Encoder *xml.Encoder
+ doRenderLists bool
+ doRenderAttr bool
+ pos uint
+ }
+ type args struct {
+ logicalName string
+ writerArgs []WithWriterArgs
+ }
+ tests := []struct {
+ name string
+ fields fields
+ args args
+ wantErr assert.ErrorAssertionFunc
+ }{
+ {
+ name: "push it",
+ fields: fields{
+ Encoder: func() *xml.Encoder {
+ var xmlString strings.Builder
+ return xml.NewEncoder(&xmlString)
+ }(),
+ },
+ wantErr: assert.NoError,
+ },
+ }
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ x := &xmlWriteBuffer{
+ BufferCommons: tt.fields.BufferCommons,
+ xmlString: tt.fields.xmlString,
+ Encoder: tt.fields.Encoder,
+ doRenderLists: tt.fields.doRenderLists,
+ doRenderAttr: tt.fields.doRenderAttr,
+ pos: tt.fields.pos,
+ }
+ tt.wantErr(t, x.PushContext(tt.args.logicalName, tt.args.writerArgs...), fmt.Sprintf("PushContext(%v, %v)", tt.args.logicalName, tt.args.writerArgs))
+ })
+ }
+}
+
+func Test_xmlWriteBuffer_WriteBigFloat(t *testing.T) {
+ type fields struct {
+ BufferCommons BufferCommons
+ xmlString *strings.Builder
+ Encoder *xml.Encoder
+ doRenderLists bool
+ doRenderAttr bool
+ pos uint
+ }
+ type args struct {
+ logicalName string
+ bitLength uint8
+ value *big.Float
+ writerArgs []WithWriterArgs
+ }
+ tests := []struct {
+ name string
+ fields fields
+ args args
+ wantErr assert.ErrorAssertionFunc
+ }{
+ {
+ name: "write it",
+ fields: fields{
+ Encoder: func() *xml.Encoder {
+ var xmlString strings.Builder
+ return xml.NewEncoder(&xmlString)
+ }(),
+ },
+ wantErr: assert.NoError,
+ },
+ }
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ x := &xmlWriteBuffer{
+ BufferCommons: tt.fields.BufferCommons,
+ xmlString: tt.fields.xmlString,
+ Encoder: tt.fields.Encoder,
+ doRenderLists: tt.fields.doRenderLists,
+ doRenderAttr: tt.fields.doRenderAttr,
+ pos: tt.fields.pos,
+ }
+ tt.wantErr(t, x.WriteBigFloat(tt.args.logicalName, tt.args.bitLength, tt.args.value, tt.args.writerArgs...), fmt.Sprintf("WriteBigFloat(%v, %v, %v, %v)", tt.args.logicalName, tt.args.bitLength, tt.args.value, tt.args.writerArgs))
+ })
+ }
+}
+
+func Test_xmlWriteBuffer_WriteBigInt(t *testing.T) {
+ type fields struct {
+ BufferCommons BufferCommons
+ xmlString *strings.Builder
+ Encoder *xml.Encoder
+ doRenderLists bool
+ doRenderAttr bool
+ pos uint
+ }
+ type args struct {
+ logicalName string
+ bitLength uint8
+ value *big.Int
+ writerArgs []WithWriterArgs
+ }
+ tests := []struct {
+ name string
+ fields fields
+ args args
+ wantErr assert.ErrorAssertionFunc
+ }{
+ {
+ name: "write it",
+ fields: fields{
+ Encoder: func() *xml.Encoder {
+ var xmlString strings.Builder
+ return xml.NewEncoder(&xmlString)
+ }(),
+ },
+ wantErr: assert.NoError,
+ },
+ }
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ x := &xmlWriteBuffer{
+ BufferCommons: tt.fields.BufferCommons,
+ xmlString: tt.fields.xmlString,
+ Encoder: tt.fields.Encoder,
+ doRenderLists: tt.fields.doRenderLists,
+ doRenderAttr: tt.fields.doRenderAttr,
+ pos: tt.fields.pos,
+ }
+ tt.wantErr(t, x.WriteBigInt(tt.args.logicalName, tt.args.bitLength, tt.args.value, tt.args.writerArgs...), fmt.Sprintf("WriteBigInt(%v, %v, %v, %v)", tt.args.logicalName, tt.args.bitLength, tt.args.value, tt.args.writerArgs))
+ })
+ }
+}
+
+func Test_xmlWriteBuffer_WriteBit(t *testing.T) {
+ type fields struct {
+ BufferCommons BufferCommons
+ xmlString *strings.Builder
+ Encoder *xml.Encoder
+ doRenderLists bool
+ doRenderAttr bool
+ pos uint
+ }
+ type args struct {
+ logicalName string
+ value bool
+ writerArgs []WithWriterArgs
+ }
+ tests := []struct {
+ name string
+ fields fields
+ args args
+ wantErr assert.ErrorAssertionFunc
+ }{
+ {
+ name: "write it",
+ fields: fields{
+ Encoder: func() *xml.Encoder {
+ var xmlString strings.Builder
+ return xml.NewEncoder(&xmlString)
+ }(),
+ },
+ wantErr: assert.NoError,
+ },
+ }
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ x := &xmlWriteBuffer{
+ BufferCommons: tt.fields.BufferCommons,
+ xmlString: tt.fields.xmlString,
+ Encoder: tt.fields.Encoder,
+ doRenderLists: tt.fields.doRenderLists,
+ doRenderAttr: tt.fields.doRenderAttr,
+ pos: tt.fields.pos,
+ }
+ tt.wantErr(t, x.WriteBit(tt.args.logicalName, tt.args.value, tt.args.writerArgs...), fmt.Sprintf("WriteBit(%v, %v, %v)", tt.args.logicalName, tt.args.value, tt.args.writerArgs))
+ })
+ }
+}
+
+func Test_xmlWriteBuffer_WriteByte(t *testing.T) {
+ type fields struct {
+ BufferCommons BufferCommons
+ xmlString *strings.Builder
+ Encoder *xml.Encoder
+ doRenderLists bool
+ doRenderAttr bool
+ pos uint
+ }
+ type args struct {
+ logicalName string
+ value byte
+ writerArgs []WithWriterArgs
+ }
+ tests := []struct {
+ name string
+ fields fields
+ args args
+ wantErr assert.ErrorAssertionFunc
+ }{
+ {
+ name: "write it",
+ fields: fields{
+ Encoder: func() *xml.Encoder {
+ var xmlString strings.Builder
+ return xml.NewEncoder(&xmlString)
+ }(),
+ },
+ wantErr: assert.NoError,
+ },
+ }
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ x := &xmlWriteBuffer{
+ BufferCommons: tt.fields.BufferCommons,
+ xmlString: tt.fields.xmlString,
+ Encoder: tt.fields.Encoder,
+ doRenderLists: tt.fields.doRenderLists,
+ doRenderAttr: tt.fields.doRenderAttr,
+ pos: tt.fields.pos,
+ }
+ tt.wantErr(t, x.WriteByte(tt.args.logicalName, tt.args.value, tt.args.writerArgs...), fmt.Sprintf("WriteByte(%v, %v, %v)", tt.args.logicalName, tt.args.value, tt.args.writerArgs))
+ })
+ }
+}
+
+func Test_xmlWriteBuffer_WriteByteArray(t *testing.T) {
+ type fields struct {
+ BufferCommons BufferCommons
+ xmlString *strings.Builder
+ Encoder *xml.Encoder
+ doRenderLists bool
+ doRenderAttr bool
+ pos uint
+ }
+ type args struct {
+ logicalName string
+ data []byte
+ writerArgs []WithWriterArgs
+ }
+ tests := []struct {
+ name string
+ fields fields
+ args args
+ wantErr assert.ErrorAssertionFunc
+ }{
+ {
+ name: "write it",
+ fields: fields{
+ Encoder: func() *xml.Encoder {
+ var xmlString strings.Builder
+ return xml.NewEncoder(&xmlString)
+ }(),
+ },
+ wantErr: assert.NoError,
+ },
+ }
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ x := &xmlWriteBuffer{
+ BufferCommons: tt.fields.BufferCommons,
+ xmlString: tt.fields.xmlString,
+ Encoder: tt.fields.Encoder,
+ doRenderLists: tt.fields.doRenderLists,
+ doRenderAttr: tt.fields.doRenderAttr,
+ pos: tt.fields.pos,
+ }
+ tt.wantErr(t, x.WriteByteArray(tt.args.logicalName, tt.args.data, tt.args.writerArgs...), fmt.Sprintf("WriteByteArray(%v, %v, %v)", tt.args.logicalName, tt.args.data, tt.args.writerArgs))
+ })
+ }
+}
+
+func Test_xmlWriteBuffer_WriteFloat32(t *testing.T) {
+ type fields struct {
+ BufferCommons BufferCommons
+ xmlString *strings.Builder
+ Encoder *xml.Encoder
+ doRenderLists bool
+ doRenderAttr bool
+ pos uint
+ }
+ type args struct {
+ logicalName string
+ bitLength uint8
+ value float32
+ writerArgs []WithWriterArgs
+ }
+ tests := []struct {
+ name string
+ fields fields
+ args args
+ wantErr assert.ErrorAssertionFunc
+ }{
+ {
+ name: "write it",
+ fields: fields{
+ Encoder: func() *xml.Encoder {
+ var xmlString strings.Builder
+ return xml.NewEncoder(&xmlString)
+ }(),
+ },
+ wantErr: assert.NoError,
+ },
+ }
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ x := &xmlWriteBuffer{
+ BufferCommons: tt.fields.BufferCommons,
+ xmlString: tt.fields.xmlString,
+ Encoder: tt.fields.Encoder,
+ doRenderLists: tt.fields.doRenderLists,
+ doRenderAttr: tt.fields.doRenderAttr,
+ pos: tt.fields.pos,
+ }
+ tt.wantErr(t, x.WriteFloat32(tt.args.logicalName, tt.args.bitLength, tt.args.value, tt.args.writerArgs...), fmt.Sprintf("WriteFloat32(%v, %v, %v, %v)", tt.args.logicalName, tt.args.bitLength, tt.args.value, tt.args.writerArgs))
+ })
+ }
+}
+
+func Test_xmlWriteBuffer_WriteFloat64(t *testing.T) {
+ type fields struct {
+ BufferCommons BufferCommons
+ xmlString *strings.Builder
+ Encoder *xml.Encoder
+ doRenderLists bool
+ doRenderAttr bool
+ pos uint
+ }
+ type args struct {
+ logicalName string
+ bitLength uint8
+ value float64
+ writerArgs []WithWriterArgs
+ }
+ tests := []struct {
+ name string
+ fields fields
+ args args
+ wantErr assert.ErrorAssertionFunc
+ }{
+ {
+ name: "write it",
+ fields: fields{
+ Encoder: func() *xml.Encoder {
+ var xmlString strings.Builder
+ return xml.NewEncoder(&xmlString)
+ }(),
+ },
+ wantErr: assert.NoError,
+ },
+ }
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ x := &xmlWriteBuffer{
+ BufferCommons: tt.fields.BufferCommons,
+ xmlString: tt.fields.xmlString,
+ Encoder: tt.fields.Encoder,
+ doRenderLists: tt.fields.doRenderLists,
+ doRenderAttr: tt.fields.doRenderAttr,
+ pos: tt.fields.pos,
+ }
+ tt.wantErr(t, x.WriteFloat64(tt.args.logicalName, tt.args.bitLength, tt.args.value, tt.args.writerArgs...), fmt.Sprintf("WriteFloat64(%v, %v, %v, %v)", tt.args.logicalName, tt.args.bitLength, tt.args.value, tt.args.writerArgs))
+ })
+ }
+}
+
+func Test_xmlWriteBuffer_WriteInt16(t *testing.T) {
+ type fields struct {
+ BufferCommons BufferCommons
+ xmlString *strings.Builder
+ Encoder *xml.Encoder
+ doRenderLists bool
+ doRenderAttr bool
+ pos uint
+ }
+ type args struct {
+ logicalName string
+ bitLength uint8
+ value int16
+ writerArgs []WithWriterArgs
+ }
+ tests := []struct {
+ name string
+ fields fields
+ args args
+ wantErr assert.ErrorAssertionFunc
+ }{
+ {
+ name: "write it",
+ fields: fields{
+ Encoder: func() *xml.Encoder {
+ var xmlString strings.Builder
+ return xml.NewEncoder(&xmlString)
+ }(),
+ },
+ wantErr: assert.NoError,
+ },
+ }
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ x := &xmlWriteBuffer{
+ BufferCommons: tt.fields.BufferCommons,
+ xmlString: tt.fields.xmlString,
+ Encoder: tt.fields.Encoder,
+ doRenderLists: tt.fields.doRenderLists,
+ doRenderAttr: tt.fields.doRenderAttr,
+ pos: tt.fields.pos,
+ }
+ tt.wantErr(t, x.WriteInt16(tt.args.logicalName, tt.args.bitLength, tt.args.value, tt.args.writerArgs...), fmt.Sprintf("WriteInt16(%v, %v, %v, %v)", tt.args.logicalName, tt.args.bitLength, tt.args.value, tt.args.writerArgs))
+ })
+ }
+}
+
+func Test_xmlWriteBuffer_WriteInt32(t *testing.T) {
+ type fields struct {
+ BufferCommons BufferCommons
+ xmlString *strings.Builder
+ Encoder *xml.Encoder
+ doRenderLists bool
+ doRenderAttr bool
+ pos uint
+ }
+ type args struct {
+ logicalName string
+ bitLength uint8
+ value int32
+ writerArgs []WithWriterArgs
+ }
+ tests := []struct {
+ name string
+ fields fields
+ args args
+ wantErr assert.ErrorAssertionFunc
+ }{
+ {
+ name: "write it",
+ fields: fields{
+ Encoder: func() *xml.Encoder {
+ var xmlString strings.Builder
+ return xml.NewEncoder(&xmlString)
+ }(),
+ },
+ wantErr: assert.NoError,
+ },
+ }
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ x := &xmlWriteBuffer{
+ BufferCommons: tt.fields.BufferCommons,
+ xmlString: tt.fields.xmlString,
+ Encoder: tt.fields.Encoder,
+ doRenderLists: tt.fields.doRenderLists,
+ doRenderAttr: tt.fields.doRenderAttr,
+ pos: tt.fields.pos,
+ }
+ tt.wantErr(t, x.WriteInt32(tt.args.logicalName, tt.args.bitLength, tt.args.value, tt.args.writerArgs...), fmt.Sprintf("WriteInt32(%v, %v, %v, %v)", tt.args.logicalName, tt.args.bitLength, tt.args.value, tt.args.writerArgs))
+ })
+ }
+}
+
+func Test_xmlWriteBuffer_WriteInt64(t *testing.T) {
+ type fields struct {
+ BufferCommons BufferCommons
+ xmlString *strings.Builder
+ Encoder *xml.Encoder
+ doRenderLists bool
+ doRenderAttr bool
+ pos uint
+ }
+ type args struct {
+ logicalName string
+ bitLength uint8
+ value int64
+ writerArgs []WithWriterArgs
+ }
+ tests := []struct {
+ name string
+ fields fields
+ args args
+ wantErr assert.ErrorAssertionFunc
+ }{
+ {
+ name: "write it",
+ fields: fields{
+ Encoder: func() *xml.Encoder {
+ var xmlString strings.Builder
+ return xml.NewEncoder(&xmlString)
+ }(),
+ },
+ wantErr: assert.NoError,
+ },
+ }
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ x := &xmlWriteBuffer{
+ BufferCommons: tt.fields.BufferCommons,
+ xmlString: tt.fields.xmlString,
+ Encoder: tt.fields.Encoder,
+ doRenderLists: tt.fields.doRenderLists,
+ doRenderAttr: tt.fields.doRenderAttr,
+ pos: tt.fields.pos,
+ }
+ tt.wantErr(t, x.WriteInt64(tt.args.logicalName, tt.args.bitLength, tt.args.value, tt.args.writerArgs...), fmt.Sprintf("WriteInt64(%v, %v, %v, %v)", tt.args.logicalName, tt.args.bitLength, tt.args.value, tt.args.writerArgs))
+ })
+ }
+}
+
+func Test_xmlWriteBuffer_WriteInt8(t *testing.T) {
+ type fields struct {
+ BufferCommons BufferCommons
+ xmlString *strings.Builder
+ Encoder *xml.Encoder
+ doRenderLists bool
+ doRenderAttr bool
+ pos uint
+ }
+ type args struct {
+ logicalName string
+ bitLength uint8
+ value int8
+ writerArgs []WithWriterArgs
+ }
+ tests := []struct {
+ name string
+ fields fields
+ args args
+ wantErr assert.ErrorAssertionFunc
+ }{
+ {
+ name: "write it",
+ fields: fields{
+ Encoder: func() *xml.Encoder {
+ var xmlString strings.Builder
+ return xml.NewEncoder(&xmlString)
+ }(),
+ },
+ wantErr: assert.NoError,
+ },
+ }
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ x := &xmlWriteBuffer{
+ BufferCommons: tt.fields.BufferCommons,
+ xmlString: tt.fields.xmlString,
+ Encoder: tt.fields.Encoder,
+ doRenderLists: tt.fields.doRenderLists,
+ doRenderAttr: tt.fields.doRenderAttr,
+ pos: tt.fields.pos,
+ }
+ tt.wantErr(t, x.WriteInt8(tt.args.logicalName, tt.args.bitLength, tt.args.value, tt.args.writerArgs...), fmt.Sprintf("WriteInt8(%v, %v, %v, %v)", tt.args.logicalName, tt.args.bitLength, tt.args.value, tt.args.writerArgs))
+ })
+ }
+}
+
+func Test_xmlWriteBuffer_WriteSerializable(t *testing.T) {
+ type fields struct {
+ BufferCommons BufferCommons
+ xmlString *strings.Builder
+ Encoder *xml.Encoder
+ doRenderLists bool
+ doRenderAttr bool
+ pos uint
+ }
+ type args struct {
+ ctx context.Context
+ serializable Serializable
+ }
+ tests := []struct {
+ name string
+ fields fields
+ args args
+ wantErr assert.ErrorAssertionFunc
+ }{
+ {
+ name: "write it",
+ fields: fields{
+ Encoder: func() *xml.Encoder {
+ var xmlString strings.Builder
+ return xml.NewEncoder(&xmlString)
+ }(),
+ },
+ wantErr: assert.NoError,
+ },
+ }
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ x := &xmlWriteBuffer{
+ BufferCommons: tt.fields.BufferCommons,
+ xmlString: tt.fields.xmlString,
+ Encoder: tt.fields.Encoder,
+ doRenderLists: tt.fields.doRenderLists,
+ doRenderAttr: tt.fields.doRenderAttr,
+ pos: tt.fields.pos,
+ }
+ tt.wantErr(t, x.WriteSerializable(tt.args.ctx, tt.args.serializable), fmt.Sprintf("WriteSerializable(%v, %v)", tt.args.ctx, tt.args.serializable))
+ })
+ }
+}
+
+func Test_xmlWriteBuffer_WriteString(t *testing.T) {
+ type fields struct {
+ BufferCommons BufferCommons
+ xmlString *strings.Builder
+ Encoder *xml.Encoder
+ doRenderLists bool
+ doRenderAttr bool
+ pos uint
+ }
+ type args struct {
+ logicalName string
+ bitLength uint32
+ encoding string
+ value string
+ writerArgs []WithWriterArgs
+ }
+ tests := []struct {
+ name string
+ fields fields
+ args args
+ wantErr assert.ErrorAssertionFunc
+ }{
+ {
+ name: "write it",
+ fields: fields{
+ Encoder: func() *xml.Encoder {
+ var xmlString strings.Builder
+ return xml.NewEncoder(&xmlString)
+ }(),
+ },
+ wantErr: assert.NoError,
+ },
+ }
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ x := &xmlWriteBuffer{
+ BufferCommons: tt.fields.BufferCommons,
+ xmlString: tt.fields.xmlString,
+ Encoder: tt.fields.Encoder,
+ doRenderLists: tt.fields.doRenderLists,
+ doRenderAttr: tt.fields.doRenderAttr,
+ pos: tt.fields.pos,
+ }
+ tt.wantErr(t, x.WriteString(tt.args.logicalName, tt.args.bitLength, tt.args.encoding, tt.args.value, tt.args.writerArgs...), fmt.Sprintf("WriteString(%v, %v, %v, %v, %v)", tt.args.logicalName, tt.args.bitLength, tt.args.encoding, tt.args.value, tt.args.writerArgs))
+ })
+ }
+}
+
+func Test_xmlWriteBuffer_WriteUint16(t *testing.T) {
+ type fields struct {
+ BufferCommons BufferCommons
+ xmlString *strings.Builder
+ Encoder *xml.Encoder
+ doRenderLists bool
+ doRenderAttr bool
+ pos uint
+ }
+ type args struct {
+ logicalName string
+ bitLength uint8
+ value uint16
+ writerArgs []WithWriterArgs
+ }
+ tests := []struct {
+ name string
+ fields fields
+ args args
+ wantErr assert.ErrorAssertionFunc
+ }{
+ {
+ name: "write it",
+ fields: fields{
+ Encoder: func() *xml.Encoder {
+ var xmlString strings.Builder
+ return xml.NewEncoder(&xmlString)
+ }(),
+ },
+ wantErr: assert.NoError,
+ },
+ }
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ x := &xmlWriteBuffer{
+ BufferCommons: tt.fields.BufferCommons,
+ xmlString: tt.fields.xmlString,
+ Encoder: tt.fields.Encoder,
+ doRenderLists: tt.fields.doRenderLists,
+ doRenderAttr: tt.fields.doRenderAttr,
+ pos: tt.fields.pos,
+ }
+ tt.wantErr(t, x.WriteUint16(tt.args.logicalName, tt.args.bitLength, tt.args.value, tt.args.writerArgs...), fmt.Sprintf("WriteUint16(%v, %v, %v, %v)", tt.args.logicalName, tt.args.bitLength, tt.args.value, tt.args.writerArgs))
+ })
+ }
+}
+
+func Test_xmlWriteBuffer_WriteUint32(t *testing.T) {
+ type fields struct {
+ BufferCommons BufferCommons
+ xmlString *strings.Builder
+ Encoder *xml.Encoder
+ doRenderLists bool
+ doRenderAttr bool
+ pos uint
+ }
+ type args struct {
+ logicalName string
+ bitLength uint8
+ value uint32
+ writerArgs []WithWriterArgs
+ }
+ tests := []struct {
+ name string
+ fields fields
+ args args
+ wantErr assert.ErrorAssertionFunc
+ }{
+ {
+ name: "write it",
+ fields: fields{
+ Encoder: func() *xml.Encoder {
+ var xmlString strings.Builder
+ return xml.NewEncoder(&xmlString)
+ }(),
+ },
+ wantErr: assert.NoError,
+ },
+ }
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ x := &xmlWriteBuffer{
+ BufferCommons: tt.fields.BufferCommons,
+ xmlString: tt.fields.xmlString,
+ Encoder: tt.fields.Encoder,
+ doRenderLists: tt.fields.doRenderLists,
+ doRenderAttr: tt.fields.doRenderAttr,
+ pos: tt.fields.pos,
+ }
+ tt.wantErr(t, x.WriteUint32(tt.args.logicalName, tt.args.bitLength, tt.args.value, tt.args.writerArgs...), fmt.Sprintf("WriteUint32(%v, %v, %v, %v)", tt.args.logicalName, tt.args.bitLength, tt.args.value, tt.args.writerArgs))
+ })
+ }
+}
+
+func Test_xmlWriteBuffer_WriteUint64(t *testing.T) {
+ type fields struct {
+ BufferCommons BufferCommons
+ xmlString *strings.Builder
+ Encoder *xml.Encoder
+ doRenderLists bool
+ doRenderAttr bool
+ pos uint
+ }
+ type args struct {
+ logicalName string
+ bitLength uint8
+ value uint64
+ writerArgs []WithWriterArgs
+ }
+ tests := []struct {
+ name string
+ fields fields
+ args args
+ wantErr assert.ErrorAssertionFunc
+ }{
+ {
+ name: "write it",
+ fields: fields{
+ Encoder: func() *xml.Encoder {
+ var xmlString strings.Builder
+ return xml.NewEncoder(&xmlString)
+ }(),
+ },
+ wantErr: assert.NoError,
+ },
+ }
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ x := &xmlWriteBuffer{
+ BufferCommons: tt.fields.BufferCommons,
+ xmlString: tt.fields.xmlString,
+ Encoder: tt.fields.Encoder,
+ doRenderLists: tt.fields.doRenderLists,
+ doRenderAttr: tt.fields.doRenderAttr,
+ pos: tt.fields.pos,
+ }
+ tt.wantErr(t, x.WriteUint64(tt.args.logicalName, tt.args.bitLength, tt.args.value, tt.args.writerArgs...), fmt.Sprintf("WriteUint64(%v, %v, %v, %v)", tt.args.logicalName, tt.args.bitLength, tt.args.value, tt.args.writerArgs))
+ })
+ }
+}
+
+func Test_xmlWriteBuffer_WriteUint8(t *testing.T) {
+ type fields struct {
+ BufferCommons BufferCommons
+ xmlString *strings.Builder
+ Encoder *xml.Encoder
+ doRenderLists bool
+ doRenderAttr bool
+ pos uint
+ }
+ type args struct {
+ logicalName string
+ bitLength uint8
+ value uint8
+ writerArgs []WithWriterArgs
+ }
+ tests := []struct {
+ name string
+ fields fields
+ args args
+ wantErr assert.ErrorAssertionFunc
+ }{
+ {
+ name: "write it",
+ fields: fields{
+ Encoder: func() *xml.Encoder {
+ var xmlString strings.Builder
+ return xml.NewEncoder(&xmlString)
+ }(),
+ },
+ wantErr: assert.NoError,
+ },
+ }
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ x := &xmlWriteBuffer{
+ BufferCommons: tt.fields.BufferCommons,
+ xmlString: tt.fields.xmlString,
+ Encoder: tt.fields.Encoder,
+ doRenderLists: tt.fields.doRenderLists,
+ doRenderAttr: tt.fields.doRenderAttr,
+ pos: tt.fields.pos,
+ }
+ tt.wantErr(t, x.WriteUint8(tt.args.logicalName, tt.args.bitLength, tt.args.value, tt.args.writerArgs...), fmt.Sprintf("WriteUint8(%v, %v, %v, %v)", tt.args.logicalName, tt.args.bitLength, tt.args.value, tt.args.writerArgs))
+ })
+ }
+}
+
+func Test_xmlWriteBuffer_WriteVirtual(t *testing.T) {
+ type fields struct {
+ BufferCommons BufferCommons
+ xmlString *strings.Builder
+ Encoder *xml.Encoder
+ doRenderLists bool
+ doRenderAttr bool
+ pos uint
+ }
+ type args struct {
+ in0 context.Context
+ in1 string
+ in2 any
+ in3 []WithWriterArgs
+ }
+ tests := []struct {
+ name string
+ fields fields
+ args args
+ wantErr assert.ErrorAssertionFunc
+ }{
+ {
+ name: "write it",
+ fields: fields{
+ Encoder: func() *xml.Encoder {
+ var xmlString strings.Builder
+ return xml.NewEncoder(&xmlString)
+ }(),
+ },
+ wantErr: assert.NoError,
+ },
+ }
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ x := &xmlWriteBuffer{
+ BufferCommons: tt.fields.BufferCommons,
+ xmlString: tt.fields.xmlString,
+ Encoder: tt.fields.Encoder,
+ doRenderLists: tt.fields.doRenderLists,
+ doRenderAttr: tt.fields.doRenderAttr,
+ pos: tt.fields.pos,
+ }
+ tt.wantErr(t, x.WriteVirtual(tt.args.in0, tt.args.in1, tt.args.in2, tt.args.in3...), fmt.Sprintf("WriteVirtual(%v, %v, %v, %v)", tt.args.in0, tt.args.in1, tt.args.in2, tt.args.in3))
+ })
+ }
+}
+
+func Test_xmlWriteBuffer_encodeElement(t *testing.T) {
+ type fields struct {
+ BufferCommons BufferCommons
+ xmlString *strings.Builder
+ Encoder *xml.Encoder
+ doRenderLists bool
+ doRenderAttr bool
+ pos uint
+ }
+ type args struct {
+ logicalName string
+ value any
+ attr []xml.Attr
+ in3 []WithWriterArgs
+ }
+ tests := []struct {
+ name string
+ fields fields
+ args args
+ wantErr assert.ErrorAssertionFunc
+ }{
+ {
+ name: "encode it",
+ fields: fields{
+ Encoder: func() *xml.Encoder {
+ var xmlString strings.Builder
+ return xml.NewEncoder(&xmlString)
+ }(),
+ },
+ wantErr: assert.NoError,
+ },
+ }
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ x := &xmlWriteBuffer{
+ BufferCommons: tt.fields.BufferCommons,
+ xmlString: tt.fields.xmlString,
+ Encoder: tt.fields.Encoder,
+ doRenderLists: tt.fields.doRenderLists,
+ doRenderAttr: tt.fields.doRenderAttr,
+ pos: tt.fields.pos,
+ }
+ tt.wantErr(t, x.encodeElement(tt.args.logicalName, tt.args.value, tt.args.attr, tt.args.in3...), fmt.Sprintf("encodeElement(%v, %v, %v, %v)", tt.args.logicalName, tt.args.value, tt.args.attr, tt.args.in3))
+ })
+ }
+}
+
+func Test_xmlWriteBuffer_generateAttr(t *testing.T) {
+ type fields struct {
+ BufferCommons BufferCommons
+ xmlString *strings.Builder
+ Encoder *xml.Encoder
+ doRenderLists bool
+ doRenderAttr bool
+ pos uint
+ }
+ type args struct {
+ dataType string
+ bitLength uint
+ writerArgs []WithWriterArgs
+ }
+ tests := []struct {
+ name string
+ fields fields
+ args args
+ want []xml.Attr
+ }{
+ {
+ name: "generate it",
+ want: []xml.Attr{{Name: xml.Name{Space: "", Local: ""}, Value: ""}, {Name: xml.Name{Space: "", Local: ""}, Value: ""}},
+ },
+ }
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ x := &xmlWriteBuffer{
+ BufferCommons: tt.fields.BufferCommons,
+ xmlString: tt.fields.xmlString,
+ Encoder: tt.fields.Encoder,
+ doRenderLists: tt.fields.doRenderLists,
+ doRenderAttr: tt.fields.doRenderAttr,
+ pos: tt.fields.pos,
+ }
+ assert.Equalf(t, tt.want, x.generateAttr(tt.args.dataType, tt.args.bitLength, tt.args.writerArgs...), "generateAttr(%v, %v, %v)", tt.args.dataType, tt.args.bitLength, tt.args.writerArgs)
+ })
+ }
+}
+
+func Test_xmlWriteBuffer_markAsListIfRequired(t *testing.T) {
+ type fields struct {
+ BufferCommons BufferCommons
+ xmlString *strings.Builder
+ Encoder *xml.Encoder
+ doRenderLists bool
+ doRenderAttr bool
+ pos uint
+ }
+ type args struct {
+ writerArgs []WithWriterArgs
+ attrs []xml.Attr
+ }
+ tests := []struct {
+ name string
+ fields fields
+ args args
+ want []xml.Attr
+ }{
+ {
+ name: "mark it",
+ },
+ }
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ x := &xmlWriteBuffer{
+ BufferCommons: tt.fields.BufferCommons,
+ xmlString: tt.fields.xmlString,
+ Encoder: tt.fields.Encoder,
+ doRenderLists: tt.fields.doRenderLists,
+ doRenderAttr: tt.fields.doRenderAttr,
+ pos: tt.fields.pos,
+ }
+ assert.Equalf(t, tt.want, x.markAsListIfRequired(tt.args.writerArgs, tt.args.attrs), "markAsListIfRequired(%v, %v)", tt.args.writerArgs, tt.args.attrs)
+ })
+ }
+}
+
+func Test_xmlWriteBuffer_move(t *testing.T) {
+ type fields struct {
+ BufferCommons BufferCommons
+ xmlString *strings.Builder
+ Encoder *xml.Encoder
+ doRenderLists bool
+ doRenderAttr bool
+ pos uint
+ }
+ type args struct {
+ bits uint
+ }
+ tests := []struct {
+ name string
+ fields fields
+ args args
+ }{
+ {
+ name: "move it",
+ },
+ }
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ x := &xmlWriteBuffer{
+ BufferCommons: tt.fields.BufferCommons,
+ xmlString: tt.fields.xmlString,
+ Encoder: tt.fields.Encoder,
+ doRenderLists: tt.fields.doRenderLists,
+ doRenderAttr: tt.fields.doRenderAttr,
+ pos: tt.fields.pos,
+ }
+ x.move(tt.args.bits)
+ })
+ }
+}