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/30 15:16:24 UTC
[plc4x] 02/04: test(plc4go/spi): add tests for special methods of PlcValue
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 b4e1c448926b6d5bdad2395c889f7555077df30b
Author: Sebastian Rühl <sr...@apache.org>
AuthorDate: Tue May 30 16:25:40 2023 +0200
test(plc4go/spi): add tests for special methods of PlcValue
---
plc4go/spi/values/PlcDWORD.go | 14 +
plc4go/spi/values/PlcINT.go | 2 +-
plc4go/spi/values/PlcLINT.go | 2 +-
plc4go/spi/values/PlcLREAL.go | 2 +-
plc4go/spi/values/PlcLWORD.go | 11 +-
plc4go/spi/values/PlcSINT.go | 2 +-
plc4go/spi/values/PlcUDINT.go | 2 +-
plc4go/spi/values/PlcUINT.go | 2 +-
plc4go/spi/values/PlcULINT.go | 2 +-
plc4go/spi/values/PlcUSINT.go | 2 +-
plc4go/spi/values/PlcValueAdapter.go | 6 +-
plc4go/spi/values/PlcValueAdapter_test.go | 411 ++++++++++++++++++++++++++++
plc4go/spi/values/value_combination_test.go | 160 +++++++++++
13 files changed, 605 insertions(+), 13 deletions(-)
diff --git a/plc4go/spi/values/PlcDWORD.go b/plc4go/spi/values/PlcDWORD.go
index 61274beb8e..378b189230 100644
--- a/plc4go/spi/values/PlcDWORD.go
+++ b/plc4go/spi/values/PlcDWORD.go
@@ -158,15 +158,29 @@ func (m PlcDWORD) GetInt32() int32 {
return 0
}
+func (m PlcDWORD) IsInt64() bool {
+ return m.value < math.MaxUint32
+}
+
func (m PlcDWORD) GetInt64() int64 {
return int64(m.GetUint32())
}
+func (m PlcDWORD) IsFloat32() bool {
+ //TODO: Check if this is ok
+ return true
+}
+
func (m PlcDWORD) GetFloat32() float32 {
//TODO: Check if this is ok
return float32(m.GetUint32())
}
+func (m PlcDWORD) IsFloat64() bool {
+ //TODO: Check if this is ok
+ return true
+}
+
func (m PlcDWORD) GetFloat64() float64 {
//TODO: Check if this is ok
return float64(m.GetUint32())
diff --git a/plc4go/spi/values/PlcINT.go b/plc4go/spi/values/PlcINT.go
index 15c196250c..c35ee2a8ce 100644
--- a/plc4go/spi/values/PlcINT.go
+++ b/plc4go/spi/values/PlcINT.go
@@ -50,7 +50,7 @@ func (m PlcINT) GetRaw() []byte {
return theBytes
}
-func (m PlcINT) GetBoolean() bool {
+func (m PlcINT) GetBool() bool {
if m.value == 0 {
return false
}
diff --git a/plc4go/spi/values/PlcLINT.go b/plc4go/spi/values/PlcLINT.go
index 6aeb24742c..3a71e04dc0 100644
--- a/plc4go/spi/values/PlcLINT.go
+++ b/plc4go/spi/values/PlcLINT.go
@@ -50,7 +50,7 @@ func (m PlcLINT) GetRaw() []byte {
return theBytes
}
-func (m PlcLINT) GetBoolean() bool {
+func (m PlcLINT) GetBool() bool {
if m.value == 0 {
return false
}
diff --git a/plc4go/spi/values/PlcLREAL.go b/plc4go/spi/values/PlcLREAL.go
index 0a5829c594..ec974aabfe 100644
--- a/plc4go/spi/values/PlcLREAL.go
+++ b/plc4go/spi/values/PlcLREAL.go
@@ -49,7 +49,7 @@ func (m PlcLREAL) GetRaw() []byte {
return theBytes
}
-func (m PlcLREAL) GetBoolean() bool {
+func (m PlcLREAL) GetBool() bool {
if m.value == 0.0 {
return false
}
diff --git a/plc4go/spi/values/PlcLWORD.go b/plc4go/spi/values/PlcLWORD.go
index a7b69b7335..24f76a43c7 100644
--- a/plc4go/spi/values/PlcLWORD.go
+++ b/plc4go/spi/values/PlcLWORD.go
@@ -192,14 +192,21 @@ func (m PlcLWORD) GetInt64() int64 {
return 0
}
+func (m PlcLWORD) IsFloat32() bool {
+ return m.IsUint32()
+}
+
func (m PlcLWORD) GetFloat32() float32 {
//TODO: Check if this is ok
- return float32(m.GetUint32())
+ return float32(m.value)
+}
+func (m PlcLWORD) IsFloat64() bool {
+ return true
}
func (m PlcLWORD) GetFloat64() float64 {
//TODO: Check if this is ok
- return float64(m.GetUint32())
+ return float64(m.value)
}
func (m PlcLWORD) IsString() bool {
diff --git a/plc4go/spi/values/PlcSINT.go b/plc4go/spi/values/PlcSINT.go
index 2ff6750c2f..32e2ebea4e 100644
--- a/plc4go/spi/values/PlcSINT.go
+++ b/plc4go/spi/values/PlcSINT.go
@@ -49,7 +49,7 @@ func (m PlcSINT) GetRaw() []byte {
return theBytes
}
-func (m PlcSINT) GetBoolean() bool {
+func (m PlcSINT) GetBool() bool {
if m.value == 0 {
return false
}
diff --git a/plc4go/spi/values/PlcUDINT.go b/plc4go/spi/values/PlcUDINT.go
index dc47773e4d..6c7581ae4c 100644
--- a/plc4go/spi/values/PlcUDINT.go
+++ b/plc4go/spi/values/PlcUDINT.go
@@ -50,7 +50,7 @@ func (m PlcUDINT) GetRaw() []byte {
return theBytes
}
-func (m PlcUDINT) GetBoolean() bool {
+func (m PlcUDINT) GetBool() bool {
if m.value == 0 {
return false
}
diff --git a/plc4go/spi/values/PlcUINT.go b/plc4go/spi/values/PlcUINT.go
index 8fb035d76d..d42dc7f50e 100644
--- a/plc4go/spi/values/PlcUINT.go
+++ b/plc4go/spi/values/PlcUINT.go
@@ -50,7 +50,7 @@ func (m PlcUINT) GetRaw() []byte {
return theBytes
}
-func (m PlcUINT) GetBoolean() bool {
+func (m PlcUINT) GetBool() bool {
if m.value == 0 {
return false
}
diff --git a/plc4go/spi/values/PlcULINT.go b/plc4go/spi/values/PlcULINT.go
index 5e281c7696..97a1cee62e 100644
--- a/plc4go/spi/values/PlcULINT.go
+++ b/plc4go/spi/values/PlcULINT.go
@@ -50,7 +50,7 @@ func (m PlcULINT) GetRaw() []byte {
return theBytes
}
-func (m PlcULINT) GetBoolean() bool {
+func (m PlcULINT) GetBool() bool {
if m.value == 0 {
return false
}
diff --git a/plc4go/spi/values/PlcUSINT.go b/plc4go/spi/values/PlcUSINT.go
index abad6115f5..6432bca48d 100644
--- a/plc4go/spi/values/PlcUSINT.go
+++ b/plc4go/spi/values/PlcUSINT.go
@@ -50,7 +50,7 @@ func (m PlcUSINT) GetRaw() []byte {
return theBytes
}
-func (m PlcUSINT) GetBoolean() bool {
+func (m PlcUSINT) GetBool() bool {
if m.value == 0 {
return false
}
diff --git a/plc4go/spi/values/PlcValueAdapter.go b/plc4go/spi/values/PlcValueAdapter.go
index e51ef3bd65..173869cf2e 100644
--- a/plc4go/spi/values/PlcValueAdapter.go
+++ b/plc4go/spi/values/PlcValueAdapter.go
@@ -204,8 +204,8 @@ func (m PlcValueAdapter) IsList() bool {
func (m PlcValueAdapter) GetLength() uint32 {
panic("GetLength not implemented")
}
-func (m PlcValueAdapter) GetIndex(i uint32) apiValues.PlcValue {
- return nil
+func (m PlcValueAdapter) GetIndex(_ uint32) apiValues.PlcValue {
+ panic("GetIndex not Implemented")
}
func (m PlcValueAdapter) GetList() []apiValues.PlcValue {
panic("GetList not implemented")
@@ -223,7 +223,7 @@ func (m PlcValueAdapter) GetKeys() []string {
panic("GetKeys not implemented")
}
func (m PlcValueAdapter) HasKey(_ string) bool {
- return false
+ panic("HasKey not implemented")
}
func (m PlcValueAdapter) GetValue(_ string) apiValues.PlcValue {
panic("GetValue not implemented")
diff --git a/plc4go/spi/values/PlcValueAdapter_test.go b/plc4go/spi/values/PlcValueAdapter_test.go
new file mode 100644
index 0000000000..21797cfc4b
--- /dev/null
+++ b/plc4go/spi/values/PlcValueAdapter_test.go
@@ -0,0 +1,411 @@
+/*
+ * 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 values
+
+import (
+ "testing"
+
+ "github.com/stretchr/testify/assert"
+)
+
+func TestPlcSimpleNumericValueAdapter_IsBool(t *testing.T) {
+ assert.False(t, PlcValueAdapter{}.IsBool())
+}
+
+func TestPlcSimpleNumericValueAdapter_IsByte(t *testing.T) {
+ assert.False(t, PlcValueAdapter{}.IsByte())
+}
+
+func TestPlcSimpleNumericValueAdapter_IsFloat32(t *testing.T) {
+ assert.False(t, PlcValueAdapter{}.IsFloat32())
+}
+
+func TestPlcSimpleNumericValueAdapter_IsFloat64(t *testing.T) {
+ assert.False(t, PlcValueAdapter{}.IsFloat64())
+}
+
+func TestPlcSimpleNumericValueAdapter_IsInt16(t *testing.T) {
+ assert.False(t, PlcValueAdapter{}.IsInt16())
+}
+
+func TestPlcSimpleNumericValueAdapter_IsInt32(t *testing.T) {
+ assert.False(t, PlcValueAdapter{}.IsInt32())
+}
+
+func TestPlcSimpleNumericValueAdapter_IsInt64(t *testing.T) {
+ assert.False(t, PlcValueAdapter{}.IsInt64())
+}
+
+func TestPlcSimpleNumericValueAdapter_IsInt8(t *testing.T) {
+ assert.False(t, PlcValueAdapter{}.IsInt8())
+}
+
+func TestPlcSimpleNumericValueAdapter_IsString(t *testing.T) {
+ assert.False(t, PlcValueAdapter{}.IsString())
+}
+
+func TestPlcSimpleNumericValueAdapter_IsUint16(t *testing.T) {
+ assert.False(t, PlcValueAdapter{}.IsUint16())
+}
+
+func TestPlcSimpleNumericValueAdapter_IsUint32(t *testing.T) {
+ assert.False(t, PlcValueAdapter{}.IsUint32())
+}
+
+func TestPlcSimpleNumericValueAdapter_IsUint64(t *testing.T) {
+ assert.False(t, PlcValueAdapter{}.IsUint64())
+}
+
+func TestPlcSimpleNumericValueAdapter_IsUint8(t *testing.T) {
+ assert.False(t, PlcValueAdapter{}.IsUint8())
+}
+
+func TestPlcSimpleNumericValueAdapter_String(t *testing.T) {
+ assert.Equal(t, "not implemented", PlcSimpleNumericValueAdapter{}.String())
+}
+
+func TestPlcSimpleValueAdapter_GetLength(t *testing.T) {
+ assert.Equal(t, uint32(1), PlcSimpleNumericValueAdapter{}.GetLength())
+}
+
+func TestPlcSimpleValueAdapter_IsSimple(t *testing.T) {
+ assert.True(t, PlcSimpleNumericValueAdapter{}.IsSimple())
+}
+
+func TestPlcSimpleValueAdapter_String(t *testing.T) {
+ assert.Equal(t, "not implemented", PlcSimpleValueAdapter{}.String())
+}
+
+func TestPlcValueAdapter_GetBool(t *testing.T) {
+ assert.False(t, PlcValueAdapter{}.GetBool())
+}
+
+func TestPlcValueAdapter_GetBoolArray(t *testing.T) {
+ assert.Nil(t, PlcValueAdapter{}.GetBoolArray())
+}
+
+func TestPlcValueAdapter_GetBoolAt(t *testing.T) {
+ t.Run("index 0", func(t *testing.T) {
+ assert.False(t, PlcValueAdapter{}.GetBoolAt(0))
+ })
+ t.Run("index 1", func(t *testing.T) {
+ assert.False(t, PlcValueAdapter{}.GetBoolAt(1))
+ })
+}
+
+func TestPlcValueAdapter_GetBoolLength(t *testing.T) {
+ assert.Equal(t, uint32(1), PlcValueAdapter{}.GetBoolLength())
+}
+
+func TestPlcValueAdapter_GetByte(t *testing.T) {
+ defer func() {
+ recover()
+ }()
+ PlcValueAdapter{}.GetByte()
+ t.Error("above should panic")
+}
+
+func TestPlcValueAdapter_GetDate(t *testing.T) {
+ defer func() {
+ recover()
+ }()
+ PlcValueAdapter{}.GetDate()
+ t.Error("above should panic")
+}
+
+func TestPlcValueAdapter_GetDateTime(t *testing.T) {
+ defer func() {
+ recover()
+ }()
+ PlcValueAdapter{}.GetDateTime()
+ t.Error("above should panic")
+}
+
+func TestPlcValueAdapter_GetDuration(t *testing.T) {
+ defer func() {
+ recover()
+ }()
+ PlcValueAdapter{}.GetDuration()
+ t.Error("above should panic")
+}
+
+func TestPlcValueAdapter_GetFloat32(t *testing.T) {
+ defer func() {
+ recover()
+ }()
+ PlcValueAdapter{}.GetFloat32()
+ t.Error("above should panic")
+}
+
+func TestPlcValueAdapter_GetFloat64(t *testing.T) {
+ defer func() {
+ recover()
+ }()
+ PlcValueAdapter{}.GetFloat64()
+ t.Error("above should panic")
+}
+
+func TestPlcValueAdapter_GetIndex(t *testing.T) {
+ defer func() {
+ recover()
+ }()
+ PlcValueAdapter{}.GetIndex(0)
+ t.Error("above should panic")
+}
+
+func TestPlcValueAdapter_GetInt16(t *testing.T) {
+ defer func() {
+ recover()
+ }()
+ PlcValueAdapter{}.GetInt16()
+ t.Error("above should panic")
+}
+
+func TestPlcValueAdapter_GetInt32(t *testing.T) {
+ defer func() {
+ recover()
+ }()
+ PlcValueAdapter{}.GetInt32()
+ t.Error("above should panic")
+}
+
+func TestPlcValueAdapter_GetInt64(t *testing.T) {
+ defer func() {
+ recover()
+ }()
+ PlcValueAdapter{}.GetInt64()
+ t.Error("above should panic")
+}
+
+func TestPlcValueAdapter_GetInt8(t *testing.T) {
+ defer func() {
+ recover()
+ }()
+ PlcValueAdapter{}.GetInt8()
+ t.Error("above should panic")
+}
+
+func TestPlcValueAdapter_GetKeys(t *testing.T) {
+ defer func() {
+ recover()
+ }()
+ PlcValueAdapter{}.GetKeys()
+ t.Error("above should panic")
+}
+
+func TestPlcValueAdapter_GetLength(t *testing.T) {
+ defer func() {
+ recover()
+ }()
+ PlcValueAdapter{}.GetLength()
+ t.Error("above should panic")
+}
+
+func TestPlcValueAdapter_GetList(t *testing.T) {
+ defer func() {
+ recover()
+ }()
+ PlcValueAdapter{}.GetList()
+ t.Error("above should panic")
+}
+
+func TestPlcValueAdapter_GetPlcValueType(t *testing.T) {
+ defer func() {
+ recover()
+ }()
+ PlcValueAdapter{}.GetPlcValueType()
+ t.Error("above should panic")
+}
+
+func TestPlcValueAdapter_GetRaw(t *testing.T) {
+ defer func() {
+ recover()
+ }()
+ PlcValueAdapter{}.GetRaw()
+ t.Error("above should panic")
+}
+
+func TestPlcValueAdapter_GetString(t *testing.T) {
+ defer func() {
+ recover()
+ }()
+ PlcValueAdapter{}.GetString()
+ t.Error("above should panic")
+}
+
+func TestPlcValueAdapter_GetStruct(t *testing.T) {
+ defer func() {
+ recover()
+ }()
+ PlcValueAdapter{}.GetStruct()
+ t.Error("above should panic")
+}
+
+func TestPlcValueAdapter_GetTime(t *testing.T) {
+ defer func() {
+ recover()
+ }()
+ PlcValueAdapter{}.GetTime()
+ t.Error("above should panic")
+}
+
+func TestPlcValueAdapter_GetUint16(t *testing.T) {
+ defer func() {
+ recover()
+ }()
+ PlcValueAdapter{}.GetUint16()
+ t.Error("above should panic")
+}
+
+func TestPlcValueAdapter_GetUint32(t *testing.T) {
+ defer func() {
+ recover()
+ }()
+ PlcValueAdapter{}.GetUint32()
+ t.Error("above should panic")
+}
+
+func TestPlcValueAdapter_GetUint64(t *testing.T) {
+ defer func() {
+ recover()
+ }()
+ PlcValueAdapter{}.GetUint64()
+ t.Error("above should panic")
+}
+
+func TestPlcValueAdapter_GetUint8(t *testing.T) {
+ defer func() {
+ recover()
+ }()
+ PlcValueAdapter{}.GetUint8()
+ t.Error("above should panic")
+}
+
+func TestPlcValueAdapter_GetValue(t *testing.T) {
+ defer func() {
+ recover()
+ }()
+ PlcValueAdapter{}.GetValue("")
+ t.Error("above should panic")
+}
+
+func TestPlcValueAdapter_HasKey(t *testing.T) {
+ defer func() {
+ recover()
+ }()
+ PlcValueAdapter{}.HasKey("")
+ t.Error("above should panic")
+}
+
+func TestPlcValueAdapter_IsBool(t *testing.T) {
+ assert.False(t, PlcValueAdapter{}.IsBool())
+}
+
+func TestPlcValueAdapter_IsByte(t *testing.T) {
+ assert.False(t, PlcValueAdapter{}.IsByte())
+}
+
+func TestPlcValueAdapter_IsDate(t *testing.T) {
+ assert.False(t, PlcValueAdapter{}.IsDate())
+}
+
+func TestPlcValueAdapter_IsDateTime(t *testing.T) {
+ assert.False(t, PlcValueAdapter{}.IsDateTime())
+}
+
+func TestPlcValueAdapter_IsDuration(t *testing.T) {
+ assert.False(t, PlcValueAdapter{}.IsDuration())
+}
+
+func TestPlcValueAdapter_IsFloat32(t *testing.T) {
+ assert.False(t, PlcValueAdapter{}.IsFloat32())
+}
+
+func TestPlcValueAdapter_IsFloat64(t *testing.T) {
+ assert.False(t, PlcValueAdapter{}.IsFloat64())
+}
+
+func TestPlcValueAdapter_IsInt16(t *testing.T) {
+ assert.False(t, PlcValueAdapter{}.IsInt16())
+}
+
+func TestPlcValueAdapter_IsInt32(t *testing.T) {
+ assert.False(t, PlcValueAdapter{}.IsInt32())
+}
+
+func TestPlcValueAdapter_IsInt64(t *testing.T) {
+ assert.False(t, PlcValueAdapter{}.IsInt64())
+}
+
+func TestPlcValueAdapter_IsInt8(t *testing.T) {
+ assert.False(t, PlcValueAdapter{}.IsInt8())
+}
+
+func TestPlcValueAdapter_IsList(t *testing.T) {
+ assert.False(t, PlcValueAdapter{}.IsList())
+}
+
+func TestPlcValueAdapter_IsNull(t *testing.T) {
+ assert.False(t, PlcValueAdapter{}.IsNull())
+}
+
+func TestPlcValueAdapter_IsNullable(t *testing.T) {
+ assert.False(t, PlcValueAdapter{}.IsNullable())
+}
+
+func TestPlcValueAdapter_IsRaw(t *testing.T) {
+ assert.False(t, PlcValueAdapter{}.IsRaw())
+}
+
+func TestPlcValueAdapter_IsSimple(t *testing.T) {
+ assert.False(t, PlcValueAdapter{}.IsSimple())
+}
+
+func TestPlcValueAdapter_IsString(t *testing.T) {
+ assert.False(t, PlcValueAdapter{}.IsString())
+}
+
+func TestPlcValueAdapter_IsStruct(t *testing.T) {
+ assert.False(t, PlcValueAdapter{}.IsStruct())
+}
+
+func TestPlcValueAdapter_IsTime(t *testing.T) {
+ assert.False(t, PlcValueAdapter{}.IsTime())
+}
+
+func TestPlcValueAdapter_IsUint16(t *testing.T) {
+ assert.False(t, PlcValueAdapter{}.IsUint16())
+}
+
+func TestPlcValueAdapter_IsUint32(t *testing.T) {
+ assert.False(t, PlcValueAdapter{}.IsUint32())
+}
+
+func TestPlcValueAdapter_IsUint64(t *testing.T) {
+ assert.False(t, PlcValueAdapter{}.IsUint64())
+}
+
+func TestPlcValueAdapter_IsUint8(t *testing.T) {
+ assert.False(t, PlcValueAdapter{}.IsUint8())
+}
+
+func TestPlcValueAdapter_String(t *testing.T) {
+ assert.Equal(t, "not implemented", PlcValueAdapter{}.String())
+}
diff --git a/plc4go/spi/values/value_combination_test.go b/plc4go/spi/values/value_combination_test.go
index 9cb7e74db8..0a69d0a159 100644
--- a/plc4go/spi/values/value_combination_test.go
+++ b/plc4go/spi/values/value_combination_test.go
@@ -505,3 +505,163 @@ func TestCombinations(t *testing.T) {
})
}
}
+
+func TestExtraTests(t *testing.T) {
+ // These tests are for extra methods not covered by TestCombinations
+ t.Run("PLCDate", func(t *testing.T) {
+ t.Run("constructors", func(t *testing.T) {
+ t.Run("uint16", func(t *testing.T) {
+ assert.NotNil(t, NewPlcDATE(uint16(1)))
+ })
+ t.Run("uint32", func(t *testing.T) {
+ assert.NotNil(t, NewPlcDATE(uint32(1)))
+ })
+ t.Run("FromSecondsSinceEpoch", func(t *testing.T) {
+ assert.NotNil(t, NewPlcDATEFromSecondsSinceEpoch(1))
+ })
+ t.Run("FromDaysSinceEpoch", func(t *testing.T) {
+ assert.NotNil(t, NewPlcDATEFromDaysSinceEpoch(1))
+ })
+ t.Run("FromDaysSinceSiemensEpoch", func(t *testing.T) {
+ assert.NotNil(t, NewPlcDATEFromDaysSinceSiemensEpoch(1))
+ })
+ })
+ t.Run("GetSecondsSinceEpoch", func(t *testing.T) {
+ NewPlcDATE(time.Now()).GetSecondsSinceEpoch()
+ })
+ t.Run("GetDaysSinceEpoch", func(t *testing.T) {
+ NewPlcDATE(time.Now()).GetDaysSinceEpoch()
+ })
+ t.Run("GetDaysSinceSiemensEpoch", func(t *testing.T) {
+ NewPlcDATE(time.Now()).GetDaysSinceSiemensEpoch()
+ })
+ })
+ t.Run("PlcLDATE_AND_TIME", func(t *testing.T) {
+ t.Run("constructors", func(t *testing.T) {
+ t.Run("uint16", func(t *testing.T) {
+ assert.NotNil(t, NewPlcLDATE_AND_TIME(uint16(1)))
+ })
+ t.Run("uint32", func(t *testing.T) {
+ assert.NotNil(t, NewPlcLDATE_AND_TIME(uint32(1)))
+ })
+ t.Run("FromNanosecondsSinceEpoch", func(t *testing.T) {
+ assert.NotNil(t, NewPlcLDATE_AND_TIMEFromNanosecondsSinceEpoch(1))
+ })
+ })
+ t.Run("GetNanosecondsSinceEpoch", func(t *testing.T) {
+ NewPlcLDATE_AND_TIME(time.Now()).GetNanosecondsSinceEpoch()
+ })
+ })
+ t.Run("PlcLDATE", func(t *testing.T) {
+ t.Run("constructors", func(t *testing.T) {
+ t.Run("uint16", func(t *testing.T) {
+ assert.NotNil(t, NewPlcLDATE(uint16(1)))
+ })
+ t.Run("uint64", func(t *testing.T) {
+ assert.NotNil(t, NewPlcLDATE(uint64(1)))
+ })
+ t.Run("FromNanosecondsSinceEpoch", func(t *testing.T) {
+ assert.NotNil(t, NewPlcLDATEFromNanosecondsSinceEpoch(1))
+ })
+ })
+ t.Run("GetNanosecondsSinceEpoch", func(t *testing.T) {
+ NewPlcLDATE(time.Now()).GetNanosecondsSinceEpoch()
+ })
+ })
+ t.Run("PlcList", func(t *testing.T) {
+ t.Run("GetLength", func(t *testing.T) {
+ NewPlcList([]apiValues.PlcValue{NewPlcNULL()}).GetLength()
+ })
+ t.Run("GetIndex", func(t *testing.T) {
+ NewPlcList([]apiValues.PlcValue{NewPlcNULL()}).GetIndex(0)
+ })
+ t.Run("GetKeys", func(t *testing.T) {
+ NewPlcList([]apiValues.PlcValue{NewPlcStruct(map[string]apiValues.PlcValue{})}).GetKeys()
+ })
+ t.Run("HasKey", func(t *testing.T) {
+ NewPlcList([]apiValues.PlcValue{NewPlcStruct(map[string]apiValues.PlcValue{})}).HasKey("")
+ })
+ t.Run("GetValue", func(t *testing.T) {
+ NewPlcList([]apiValues.PlcValue{NewPlcStruct(map[string]apiValues.PlcValue{})}).GetValue("")
+ })
+ })
+ t.Run("PlcLTIME", func(t *testing.T) {
+ t.Run("FromNanoseconds", func(t *testing.T) {
+ assert.NotNil(t, NewPlcLTIMEFromNanoseconds(0))
+ })
+ t.Run("GetNanoseconds", func(t *testing.T) {
+ NewPlcLTIMEFromNanoseconds(0).GetNanoseconds()
+ })
+ })
+ t.Run("PlcLTIME_OF_DAY", func(t *testing.T) {
+ t.Run("constructors", func(t *testing.T) {
+ t.Run("uint16", func(t *testing.T) {
+ assert.NotNil(t, NewPlcLTIME_OF_DAY(uint16(1)))
+ })
+ t.Run("uint64", func(t *testing.T) {
+ assert.NotNil(t, NewPlcLTIME_OF_DAY(uint64(1)))
+ })
+ t.Run("FromNanosecondsSinceMidnight", func(t *testing.T) {
+ assert.NotNil(t, NewPlcLTIME_OF_DAYFromNanosecondsSinceMidnight(1))
+ })
+ })
+ t.Run("GetNanosecondsSinceEpoch", func(t *testing.T) {
+ NewPlcLTIME_OF_DAY(time.Now()).GetNanosecondsSinceMidnight()
+ })
+ })
+ t.Run("PlcRawByteArray", func(t *testing.T) {
+ t.Run("GetLength", func(t *testing.T) {
+ NewPlcRawByteArray([]byte{1, 2, 3, 4}).GetLength()
+ })
+ t.Run("GetIndex", func(t *testing.T) {
+ NewPlcRawByteArray([]byte{1, 2, 3, 4}).GetIndex(0)
+ })
+ })
+ t.Run("PlcStruct", func(t *testing.T) {
+ t.Run("GetKeys", func(t *testing.T) {
+ NewPlcStruct(map[string]apiValues.PlcValue{
+ "a": NewPlcNULL(),
+ "b": NewPlcNULL(),
+ "c": NewPlcNULL(),
+ }).GetKeys()
+ })
+ t.Run("HasKey", func(t *testing.T) {
+ NewPlcStruct(map[string]apiValues.PlcValue{
+ "a": NewPlcNULL(),
+ "b": NewPlcNULL(),
+ "c": NewPlcNULL(),
+ }).HasKey("a")
+ })
+ t.Run("GetValue", func(t *testing.T) {
+ NewPlcStruct(map[string]apiValues.PlcValue{
+ "a": NewPlcNULL(),
+ "b": NewPlcNULL(),
+ "c": NewPlcNULL(),
+ }).GetValue("a")
+ })
+ })
+ t.Run("PlcTIME", func(t *testing.T) {
+ t.Run("FromMilliseconds", func(t *testing.T) {
+ assert.NotNil(t, NewPlcTIMEFromMilliseconds(1))
+ })
+ t.Run("GetMilliseconds", func(t *testing.T) {
+ NewPlcTIMEFromMilliseconds(1).GetMilliseconds()
+ })
+ })
+ t.Run("PlcTIME_OF_DAY", func(t *testing.T) {
+ t.Run("constructors", func(t *testing.T) {
+ t.Run("uint16", func(t *testing.T) {
+ assert.NotNil(t, NewPlcTIME_OF_DAY(uint16(1)))
+ })
+ t.Run("uint32", func(t *testing.T) {
+ assert.NotNil(t, NewPlcTIME_OF_DAY(uint32(1)))
+ })
+ t.Run("FromMillisecondsSinceMidnight(", func(t *testing.T) {
+ assert.NotNil(t, NewPlcTIME_OF_DAYFromMillisecondsSinceMidnight(1))
+ })
+ })
+ t.Run("GetMillisecondsSinceMidnight", func(t *testing.T) {
+ NewPlcTIME_OF_DAY(time.Now()).GetMillisecondsSinceMidnight()
+ })
+ })
+}