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/04/26 10:25:19 UTC
[plc4x] 02/02: test(plc4go): replace reflect.DeepEqual with assert.Equal
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 f45218e6763adfd5135bd245fd27214df2686bcf
Author: Sebastian Rühl <sr...@apache.org>
AuthorDate: Wed Apr 26 12:24:56 2023 +0200
test(plc4go): replace reflect.DeepEqual with assert.Equal
---
plc4go/internal/ads/TagHandler_test.go | 4 ++--
plc4go/internal/knxnetip/ConnectionHelper.go | 1 -
plc4go/internal/s7/s7Io_test.go | 3 +--
plc4go/internal/simulated/Connection_test.go | 13 ++++++-------
plc4go/internal/simulated/Device_test.go | 8 ++++----
plc4go/internal/simulated/Reader_test.go | 12 ++++++++----
plc4go/internal/simulated/TagHandler_test.go | 4 ++--
plc4go/internal/simulated/Tag_test.go | 4 ++--
plc4go/internal/simulated/Writer_test.go | 10 ++++++----
.../protocols/cbus/readwrite/model/StaticHelper_test.go | 12 ++++++------
.../spi/interceptors/SingleItemRequestInterceptor_test.go | 15 +++++++--------
plc4go/spi/utils/ReadBufferByteBased_test.go | 10 +++++-----
plc4go/spi/utils/WriteBufferByteBased_test.go | 13 ++++++-------
plc4go/spi/utils/hex_test.go | 4 ++--
14 files changed, 57 insertions(+), 56 deletions(-)
diff --git a/plc4go/internal/ads/TagHandler_test.go b/plc4go/internal/ads/TagHandler_test.go
index c9ce4ff5fc..8e487af9da 100644
--- a/plc4go/internal/ads/TagHandler_test.go
+++ b/plc4go/internal/ads/TagHandler_test.go
@@ -20,7 +20,7 @@
package ads
import (
- "reflect"
+ "github.com/stretchr/testify/assert"
"regexp"
"testing"
@@ -407,7 +407,7 @@ func TestTagHandler_ParseQuery(t *testing.T) {
t.Errorf("ParseQuery() error = %v, wantErr %v", err, tt.wantErr)
return
}
- if !reflect.DeepEqual(got, tt.want) {
+ if !assert.Equal(t, tt.want, got) {
t.Errorf("ParseQuery() got = %v, want %v", got, tt.want)
}
})
diff --git a/plc4go/internal/knxnetip/ConnectionHelper.go b/plc4go/internal/knxnetip/ConnectionHelper.go
index 12d38c9fca..f06dfcea49 100644
--- a/plc4go/internal/knxnetip/ConnectionHelper.go
+++ b/plc4go/internal/knxnetip/ConnectionHelper.go
@@ -180,7 +180,6 @@ func (m *Connection) removeSubscriber(subscriber *Subscriber) {
}
}
-// TODO: we can replace this with reflect.DeepEqual()
func (m *Connection) sliceEqual(a, b []byte) bool {
if len(a) != len(b) {
return false
diff --git a/plc4go/internal/s7/s7Io_test.go b/plc4go/internal/s7/s7Io_test.go
index f2e4249488..b6d3df0bff 100644
--- a/plc4go/internal/s7/s7Io_test.go
+++ b/plc4go/internal/s7/s7Io_test.go
@@ -22,7 +22,6 @@ package s7
import (
"context"
"fmt"
- "reflect"
"strings"
"testing"
@@ -937,7 +936,7 @@ func TestS7MessageBytes(t *testing.T) {
t.Run("json roundtrip", func(t *testing.T) {
reader := strings.NewReader(tt.wantStringJson)
readBuffer := utils.NewJsonReadBuffer(reader)
- if got, err := model.TPKTPacketParseWithBuffer(context.Background(), readBuffer); err != nil || !reflect.DeepEqual(got, tt.args.debuggable) {
+ if got, err := model.TPKTPacketParseWithBuffer(context.Background(), readBuffer); err != nil || !assert.Equal(t, tt.args.debuggable, got) {
if err != nil {
t.Error(err)
} else {
diff --git a/plc4go/internal/simulated/Connection_test.go b/plc4go/internal/simulated/Connection_test.go
index f988c93202..99573f4d6c 100644
--- a/plc4go/internal/simulated/Connection_test.go
+++ b/plc4go/internal/simulated/Connection_test.go
@@ -21,7 +21,6 @@ package simulated
import (
"github.com/stretchr/testify/assert"
- "reflect"
"testing"
"time"
@@ -143,7 +142,7 @@ func TestConnection_Connect(t *testing.T) {
t.Errorf("TestConnection.Connect() hasErr= %v, wantErr %v", connectResult.GetErr() != nil, tt.wantErr)
} else if !tt.wantErr {
// Check if we're connected.
- if !reflect.DeepEqual(connectResult, tt.want) {
+ if !assert.Equal(t, tt.want, connectResult) {
t.Errorf("TestConnection.Connect() = %v, want %v", connectResult, tt.want)
}
}
@@ -259,7 +258,7 @@ func TestConnection_Close(t *testing.T) {
if tt.wantErr != (closeResult.GetErr() != nil) {
t.Errorf("TestConnection.Close() hasErr= %v, wantErr %v", closeResult.GetErr() != nil, tt.wantErr)
} else if !tt.wantErr {
- if !reflect.DeepEqual(closeResult, tt.want) {
+ if !assert.Equal(t, tt.want, closeResult) {
t.Errorf("TestConnection.Close() = %v, want %v", closeResult, tt.want)
}
}
@@ -397,7 +396,7 @@ func TestConnection_GetMetadata(t *testing.T) {
options: tt.fields.options,
connected: tt.fields.connected,
}
- if got := c.GetMetadata(); !reflect.DeepEqual(got, tt.want) {
+ if got := c.GetMetadata(); !assert.Equal(t, tt.want, got) {
t.Errorf("GetMetadata() = %v, want %v", got, tt.want)
}
})
@@ -521,7 +520,7 @@ func TestConnection_Ping(t *testing.T) {
t.Errorf("TestConnection.Ping() completed too fast. Expected at least %v but returned after %v", tt.delayAtLeast, pingTime)
}
}
- if !reflect.DeepEqual(pingResult, tt.want) {
+ if !assert.Equal(t, tt.want, pingResult) {
t.Errorf("TestConnection.Ping() = %v, want %v", pingResult, tt.want)
}
case <-timeout.C:
@@ -609,7 +608,7 @@ func TestConnection_ReadRequestBuilder(t *testing.T) {
options: tt.fields.options,
connected: tt.fields.connected,
}
- if got := c.ReadRequestBuilder(); !reflect.DeepEqual(got, tt.want) {
+ if got := c.ReadRequestBuilder(); !assert.Equal(t, tt.want, got) {
t.Errorf("ReadRequestBuilder() = %v, want %v", got, tt.want)
}
})
@@ -733,7 +732,7 @@ func TestConnection_WriteRequestBuilder(t *testing.T) {
options: tt.fields.options,
connected: tt.fields.connected,
}
- if got := c.WriteRequestBuilder(); !reflect.DeepEqual(got, tt.want) {
+ if got := c.WriteRequestBuilder(); !assert.Equal(t, tt.want, got) {
t.Errorf("WriteRequestBuilder() = %v, want %v", got, tt.want)
}
})
diff --git a/plc4go/internal/simulated/Device_test.go b/plc4go/internal/simulated/Device_test.go
index 2852eab754..0c262048ff 100644
--- a/plc4go/internal/simulated/Device_test.go
+++ b/plc4go/internal/simulated/Device_test.go
@@ -20,7 +20,7 @@
package simulated
import (
- "reflect"
+ "github.com/stretchr/testify/assert"
"testing"
"github.com/apache/plc4x/plc4go/pkg/api/values"
@@ -95,7 +95,7 @@ func TestDevice_Get(t1 *testing.T) {
} else {
log.Debug().Msg("Result: nil")
}
- if tt.args.verifyOutput && !reflect.DeepEqual(got, tt.want) {
+ if tt.args.verifyOutput && !assert.Equal(t1, tt.want, got) {
t1.Errorf("Get() = %v, want %v", got, tt.want)
}
})
@@ -257,7 +257,7 @@ func TestDevice_getRandomValue(t1 *testing.T) {
Name: tt.fields.Name,
State: tt.fields.State,
}
- if got := t.getRandomValue(tt.args.field); !reflect.DeepEqual(got, tt.want) {
+ if got := t.getRandomValue(tt.args.field); !assert.Equal(t1, tt.want, got) {
t1.Errorf("getRandomValue() = %v, want %v", got, tt.want)
}
})
@@ -277,7 +277,7 @@ func TestNewDevice(t *testing.T) {
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
- if got := NewDevice(tt.args.name); !reflect.DeepEqual(got, tt.want) {
+ if got := NewDevice(tt.args.name); !assert.Equal(t, tt.want, got) {
t.Errorf("NewDevice() = %v, want %v", got, tt.want)
}
})
diff --git a/plc4go/internal/simulated/Reader_test.go b/plc4go/internal/simulated/Reader_test.go
index 41e9bace88..c9ef020161 100644
--- a/plc4go/internal/simulated/Reader_test.go
+++ b/plc4go/internal/simulated/Reader_test.go
@@ -21,7 +21,7 @@ package simulated
import (
"context"
- "reflect"
+ "github.com/stretchr/testify/assert"
"testing"
"time"
@@ -178,15 +178,19 @@ func TestReader_Read(t *testing.T) {
t.Errorf("Reader.Read() completed too fast. Expected at least %v but returned after %v", tt.delayAtLeast, pingTime)
}
}
- if !reflect.DeepEqual(readResponse.GetRequest(), readRequest) {
+ if !assert.Equal(t, readRequest, readResponse.GetRequest()) {
t.Errorf("Reader.Read() ReadRequest = %v, want %v", readResponse.GetRequest(), readRequest)
}
for _, fieldName := range readRequest.GetTagNames() {
- if !reflect.DeepEqual(readResponse.GetResponse().GetResponseCode(fieldName), tt.want.GetResponseCode(fieldName)) {
+ wantCode := tt.want.GetResponseCode(fieldName)
+ gotCode := readResponse.GetResponse().GetResponseCode(fieldName)
+ if !assert.Equal(t, wantCode, gotCode) {
t.Errorf("Reader.Read() PlcResponse.ResponseCode = %v, want %v",
readResponse.GetResponse().GetResponseCode(fieldName), tt.want.GetResponseCode(fieldName))
}
- if !reflect.DeepEqual(readResponse.GetResponse().GetValue(fieldName), tt.want.GetValue(fieldName)) {
+ wantValue := tt.want.GetValue(fieldName)
+ gotValue := readResponse.GetResponse().GetValue(fieldName)
+ if !assert.Equal(t, wantValue, gotValue) {
t.Errorf("Reader.Read() PlcResponse.Value = %v, want %v",
readResponse.GetResponse().GetValue(fieldName), tt.want.GetValue(fieldName))
}
diff --git a/plc4go/internal/simulated/TagHandler_test.go b/plc4go/internal/simulated/TagHandler_test.go
index 60927d8d3e..6d788311d0 100644
--- a/plc4go/internal/simulated/TagHandler_test.go
+++ b/plc4go/internal/simulated/TagHandler_test.go
@@ -20,7 +20,7 @@
package simulated
import (
- "reflect"
+ "github.com/stretchr/testify/assert"
"testing"
"github.com/apache/plc4x/plc4go/pkg/api/model"
@@ -126,7 +126,7 @@ func TestFieldHandler_ParseQuery(t *testing.T) {
t.Errorf("ParseQuery() error = %v, wantErr %v", err, tt.wantErr)
return
}
- if !reflect.DeepEqual(got, tt.want) {
+ if !assert.Equal(t, tt.want, got) {
t.Errorf("ParseQuery() got = %v, want %v", got, tt.want)
}
})
diff --git a/plc4go/internal/simulated/Tag_test.go b/plc4go/internal/simulated/Tag_test.go
index 77ffacd41e..04616ef6ed 100644
--- a/plc4go/internal/simulated/Tag_test.go
+++ b/plc4go/internal/simulated/Tag_test.go
@@ -20,7 +20,7 @@
package simulated
import (
- "reflect"
+ "github.com/stretchr/testify/assert"
"testing"
"github.com/apache/plc4x/plc4go/protocols/simulated/readwrite/model"
@@ -56,7 +56,7 @@ func TestNewSimulatedField(t *testing.T) {
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
- if got := NewSimulatedTag(tt.args.fieldType, tt.args.name, tt.args.dataTypeSize, tt.args.quantity); !reflect.DeepEqual(got, tt.want) {
+ if got := NewSimulatedTag(tt.args.fieldType, tt.args.name, tt.args.dataTypeSize, tt.args.quantity); !assert.Equal(t, tt.want, got) {
t.Errorf("NewSimulatedTag() = %v, want %v", got, tt.want)
}
})
diff --git a/plc4go/internal/simulated/Writer_test.go b/plc4go/internal/simulated/Writer_test.go
index 9f0b10e97b..b70acd5ce1 100644
--- a/plc4go/internal/simulated/Writer_test.go
+++ b/plc4go/internal/simulated/Writer_test.go
@@ -21,7 +21,7 @@ package simulated
import (
"context"
- "reflect"
+ "github.com/stretchr/testify/assert"
"testing"
"time"
@@ -190,16 +190,18 @@ func TestWriter_Write(t *testing.T) {
t.Errorf("Writer.Write() completed too fast. Expected at least %v but returned after %v", tt.delayAtLeast, pingTime)
}
}
- if !reflect.DeepEqual(writeResponse.GetRequest(), writeRequest) {
+ if !assert.Equal(t, writeRequest, writeResponse.GetRequest()) {
t.Errorf("Writer.Write() ReadRequest = %v, want %v", writeResponse.GetRequest(), writeRequest)
}
for _, fieldName := range writeRequest.GetTagNames() {
- if !reflect.DeepEqual(writeResponse.GetResponse().GetResponseCode(fieldName), tt.want.GetResponseCode(fieldName)) {
+ gotCode := writeResponse.GetResponse().GetResponseCode(fieldName)
+ wantCode := tt.want.GetResponseCode(fieldName)
+ if !assert.Equal(t, wantCode, gotCode) {
t.Errorf("Writer.Write() PlcResponse.ResponseCode = %v, want %v",
writeResponse.GetResponse().GetResponseCode(fieldName), tt.want.GetResponseCode(fieldName))
}
}
- if !reflect.DeepEqual(tt.fields.device.State, tt.newState) {
+ if !assert.Equal(t, tt.newState, tt.fields.device.State) {
t.Errorf("Writer.Write() Device State = %v, want %v",
tt.fields.device.State, tt.newState)
}
diff --git a/plc4go/protocols/cbus/readwrite/model/StaticHelper_test.go b/plc4go/protocols/cbus/readwrite/model/StaticHelper_test.go
index 81f6df104c..b7e742bd75 100644
--- a/plc4go/protocols/cbus/readwrite/model/StaticHelper_test.go
+++ b/plc4go/protocols/cbus/readwrite/model/StaticHelper_test.go
@@ -22,7 +22,7 @@ package model
import (
"github.com/apache/plc4x/plc4go/spi"
"github.com/apache/plc4x/plc4go/spi/utils"
- "reflect"
+ "github.com/stretchr/testify/assert"
"testing"
)
@@ -349,7 +349,7 @@ func TestReadAndValidateChecksum(t *testing.T) {
t.Errorf("ReadAndValidateChecksum() error = %v, wantErr %v", err, tt.wantErr)
return
}
- if !reflect.DeepEqual(got, tt.want) {
+ if !assert.Equal(t, tt.want, got) {
t.Errorf("ReadAndValidateChecksum() got = %v, want %v", got, tt.want)
}
})
@@ -375,7 +375,7 @@ func TestReadCALData(t *testing.T) {
t.Errorf("ReadCALData() error = %v, wantErr %v", err, tt.wantErr)
return
}
- if !reflect.DeepEqual(got, tt.want) {
+ if !assert.Equal(t, tt.want, got) {
t.Errorf("ReadCALData() got = %v, want %v", got, tt.want)
}
})
@@ -403,7 +403,7 @@ func TestReadCBusCommand(t *testing.T) {
t.Errorf("ReadCBusCommand() error = %v, wantErr %v", err, tt.wantErr)
return
}
- if !reflect.DeepEqual(got, tt.want) {
+ if !assert.Equal(t, tt.want, got) {
t.Errorf("ReadCBusCommand() got = %v, want %v", got, tt.want)
}
})
@@ -432,7 +432,7 @@ func TestReadEncodedReply(t *testing.T) {
t.Errorf("ReadEncodedReply() error = %v, wantErr %v", err, tt.wantErr)
return
}
- if !reflect.DeepEqual(got, tt.want) {
+ if !assert.Equal(t, tt.want, got) {
t.Errorf("ReadEncodedReply() got = %v, want %v", got, tt.want)
}
})
@@ -594,7 +594,7 @@ func Test_readBytesFromHex(t *testing.T) {
t.Errorf("readBytesFromHex() error = %v, wantErr %v", err, tt.wantErr)
return
}
- if !reflect.DeepEqual(got, tt.want) {
+ if !assert.Equal(t, tt.want, got) {
t.Errorf("readBytesFromHex() got = %v, want %v", got, tt.want)
}
})
diff --git a/plc4go/spi/interceptors/SingleItemRequestInterceptor_test.go b/plc4go/spi/interceptors/SingleItemRequestInterceptor_test.go
index d400149b10..d5f7ea433b 100644
--- a/plc4go/spi/interceptors/SingleItemRequestInterceptor_test.go
+++ b/plc4go/spi/interceptors/SingleItemRequestInterceptor_test.go
@@ -26,7 +26,6 @@ import (
"github.com/apache/plc4x/plc4go/spi"
"github.com/apache/plc4x/plc4go/spi/utils"
"github.com/stretchr/testify/assert"
- "reflect"
"testing"
apiModel "github.com/apache/plc4x/plc4go/pkg/api/model"
@@ -51,7 +50,7 @@ func TestNewSingleItemRequestInterceptor(t *testing.T) {
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
- if got := NewSingleItemRequestInterceptor(tt.args.readRequestFactory, tt.args.writeRequestFactory, tt.args.readResponseFactory, tt.args.writeResponseFactory); !reflect.DeepEqual(got, tt.want) {
+ if got := NewSingleItemRequestInterceptor(tt.args.readRequestFactory, tt.args.writeRequestFactory, tt.args.readResponseFactory, tt.args.writeResponseFactory); !assert.Equal(t, tt.want, got) {
t.Errorf("NewSingleItemRequestInterceptor() = %v, want %v", got, tt.want)
}
})
@@ -350,7 +349,7 @@ func TestSingleItemRequestInterceptor_InterceptWriteRequest(t *testing.T) {
readResponseFactory: tt.fields.readResponseFactory,
writeResponseFactory: tt.fields.writeResponseFactory,
}
- if got := m.InterceptWriteRequest(tt.args.ctx, tt.args.writeRequest); !reflect.DeepEqual(got, tt.want) {
+ if got := m.InterceptWriteRequest(tt.args.ctx, tt.args.writeRequest); !assert.Equal(t, tt.want, got) {
t.Errorf("InterceptWriteRequest() = %v, want %v", got, tt.want)
}
})
@@ -704,7 +703,7 @@ func TestSingleItemRequestInterceptor_ProcessWriteResponses(t *testing.T) {
readResponseFactory: tt.fields.readResponseFactory,
writeResponseFactory: tt.fields.writeResponseFactory,
}
- if got := m.ProcessWriteResponses(tt.args.ctx, tt.args.writeRequest, tt.args.writeResults); !reflect.DeepEqual(got, tt.want) {
+ if got := m.ProcessWriteResponses(tt.args.ctx, tt.args.writeRequest, tt.args.writeResults); !assert.Equal(t, tt.want, got) {
t.Errorf("ProcessWriteResponses() = %v, want %v", got, tt.want)
}
})
@@ -762,7 +761,7 @@ func Test_interceptedPlcReadRequestResult_GetRequest(t *testing.T) {
Response: tt.fields.Response,
Err: tt.fields.Err,
}
- if got := d.GetRequest(); !reflect.DeepEqual(got, tt.want) {
+ if got := d.GetRequest(); !assert.Equal(t, tt.want, got) {
t.Errorf("GetRequest() = %v, want %v", got, tt.want)
}
})
@@ -791,7 +790,7 @@ func Test_interceptedPlcReadRequestResult_GetResponse(t *testing.T) {
Response: tt.fields.Response,
Err: tt.fields.Err,
}
- if got := d.GetResponse(); !reflect.DeepEqual(got, tt.want) {
+ if got := d.GetResponse(); !assert.Equal(t, tt.want, got) {
t.Errorf("GetResponse() = %v, want %v", got, tt.want)
}
})
@@ -849,7 +848,7 @@ func Test_interceptedPlcWriteRequestResult_GetRequest(t *testing.T) {
Response: tt.fields.Response,
Err: tt.fields.Err,
}
- if got := d.GetRequest(); !reflect.DeepEqual(got, tt.want) {
+ if got := d.GetRequest(); !assert.Equal(t, tt.want, got) {
t.Errorf("GetRequest() = %v, want %v", got, tt.want)
}
})
@@ -878,7 +877,7 @@ func Test_interceptedPlcWriteRequestResult_GetResponse(t *testing.T) {
Response: tt.fields.Response,
Err: tt.fields.Err,
}
- if got := d.GetResponse(); !reflect.DeepEqual(got, tt.want) {
+ if got := d.GetResponse(); !assert.Equal(t, tt.want, got) {
t.Errorf("GetResponse() = %v, want %v", got, tt.want)
}
})
diff --git a/plc4go/spi/utils/ReadBufferByteBased_test.go b/plc4go/spi/utils/ReadBufferByteBased_test.go
index 674de5d723..a84c652f51 100644
--- a/plc4go/spi/utils/ReadBufferByteBased_test.go
+++ b/plc4go/spi/utils/ReadBufferByteBased_test.go
@@ -22,9 +22,9 @@ package utils
import (
"encoding/binary"
"github.com/icza/bitio"
+ "github.com/stretchr/testify/assert"
"math"
"math/big"
- "reflect"
"testing"
)
@@ -41,7 +41,7 @@ func TestNewReadBuffer(t *testing.T) {
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
- if got := NewReadBufferByteBased(tt.args.data); !reflect.DeepEqual(got, tt.want) {
+ if got := NewReadBufferByteBased(tt.args.data); !assert.Equal(t, tt.want, got) {
t.Errorf("NewReadBufferByteBased() = %v, want %v", got, tt.want)
}
})
@@ -70,7 +70,7 @@ func TestReadBuffer_GetBytes(t *testing.T) {
pos: tt.fields.pos,
byteOrder: tt.fields.byteOrder,
}
- if got := rb.GetBytes(); !reflect.DeepEqual(got, tt.want) {
+ if got := rb.GetBytes(); !assert.Equal(t, tt.want, got) {
t.Errorf("GetBytes() = %v, want %v", got, tt.want)
}
})
@@ -233,7 +233,7 @@ func TestReadBuffer_ReadBigFloat(t *testing.T) {
t.Errorf("ReadBigFloat() error = %v, wantErr %v", err, tt.wantErr)
return
}
- if !reflect.DeepEqual(got, tt.want) {
+ if !assert.Equal(t, tt.want, got) {
t.Errorf("ReadBigFloat() got = %v, want %v", got, tt.want)
}
})
@@ -272,7 +272,7 @@ func TestReadBuffer_ReadBigInt(t *testing.T) {
t.Errorf("ReadBigInt() error = %v, wantErr %v", err, tt.wantErr)
return
}
- if !reflect.DeepEqual(got, tt.want) {
+ if !assert.Equal(t, tt.want, got) {
t.Errorf("ReadBigInt() got = %v, want %v", got, tt.want)
}
})
diff --git a/plc4go/spi/utils/WriteBufferByteBased_test.go b/plc4go/spi/utils/WriteBufferByteBased_test.go
index 9d5b701ce8..bfbba4f20f 100644
--- a/plc4go/spi/utils/WriteBufferByteBased_test.go
+++ b/plc4go/spi/utils/WriteBufferByteBased_test.go
@@ -24,7 +24,6 @@ import (
"context"
"encoding/binary"
"math/big"
- "reflect"
"testing"
"github.com/icza/bitio"
@@ -44,7 +43,7 @@ func TestNewWriteBufferByteBased(t *testing.T) {
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
- if got := NewWriteBufferByteBased(tt.args.options...); !reflect.DeepEqual(got, tt.want) {
+ if got := NewWriteBufferByteBased(tt.args.options...); !assert.Equal(t, tt.want, got) {
t.Errorf("NewWriteBufferByteBased() = %v, want %v", got, tt.want)
}
})
@@ -64,7 +63,7 @@ func TestWithByteOrderForByteBasedBuffer(t *testing.T) {
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
- if got := WithByteOrderForByteBasedBuffer(tt.args.byteOrder); !reflect.DeepEqual(got, tt.want) {
+ if got := WithByteOrderForByteBasedBuffer(tt.args.byteOrder); !assert.Equal(t, tt.want, got) {
//t.Errorf("WithByteOrderForByteBasedBuffer() = %v, want %v", got, tt.want)
}
})
@@ -84,7 +83,7 @@ func TestWithCustomBufferForByteBasedBuffer(t *testing.T) {
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
- if got := WithCustomBufferForByteBasedBuffer(tt.args.buffer); !reflect.DeepEqual(got, tt.want) {
+ if got := WithCustomBufferForByteBasedBuffer(tt.args.buffer); !assert.Equal(t, tt.want, got) {
// t.Errorf("WithCustomBufferForByteBasedBuffer() = %v, want %v", got, tt.want)
}
})
@@ -104,7 +103,7 @@ func TestWithInitialSizeForByteBasedBuffer(t *testing.T) {
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
- if got := WithInitialSizeForByteBasedBuffer(tt.args.length); !reflect.DeepEqual(got, tt.want) {
+ if got := WithInitialSizeForByteBasedBuffer(tt.args.length); !assert.Equal(t, tt.want, got) {
//t.Errorf("WithInitialSizeForByteBasedBuffer() = %v, want %v", got, tt.want)
}
})
@@ -133,7 +132,7 @@ func Test_byteWriteBuffer_GetByteOrder(t *testing.T) {
byteOrder: tt.fields.byteOrder,
pos: tt.fields.pos,
}
- if got := wb.GetByteOrder(); !reflect.DeepEqual(got, tt.want) {
+ if got := wb.GetByteOrder(); !assert.Equal(t, tt.want, got) {
t.Errorf("GetByteOrder() = %v, want %v", got, tt.want)
}
})
@@ -162,7 +161,7 @@ func Test_byteWriteBuffer_GetBytes(t *testing.T) {
byteOrder: tt.fields.byteOrder,
pos: tt.fields.pos,
}
- if got := wb.GetBytes(); !reflect.DeepEqual(got, tt.want) {
+ if got := wb.GetBytes(); !assert.Equal(t, tt.want, got) {
t.Errorf("GetBytes() = %v, want %v", got, tt.want)
}
})
diff --git a/plc4go/spi/utils/hex_test.go b/plc4go/spi/utils/hex_test.go
index 8bee4efeb2..ea96f252ce 100644
--- a/plc4go/spi/utils/hex_test.go
+++ b/plc4go/spi/utils/hex_test.go
@@ -20,8 +20,8 @@
package utils
import (
+ "github.com/stretchr/testify/assert"
"math"
- "reflect"
"strings"
"testing"
)
@@ -514,7 +514,7 @@ func Test_calculateBytesPerRowAndIndexWidth(t *testing.T) {
func Test_Immutability(t *testing.T) {
inputBytes := []byte{0, 1, 2, 46, 56, 0, 200}
_ = Dump(inputBytes)
- if !reflect.DeepEqual(inputBytes, []byte{0, 1, 2, 46, 56, 0, 200}) {
+ if !assert.Equal(t, []byte{0, 1, 2, 46, 56, 0, 200}, inputBytes) {
t.Errorf("Dump has mutated the array got:=%x, want:=%x", inputBytes, []byte{0, 1, 2, 46, 56, 0, 200})
}
}