From 388454989fe04b0b1855aa765ad731ab274e50e1 Mon Sep 17 00:00:00 2001 From: Christofer Dutz Date: Wed, 25 Sep 2024 23:39:04 +0200 Subject: [PATCH] refactor: Added more testcases to the PlcValueHandler tests --- .../apache/plc4x/java/spi/values/PlcDINT.java | 4 +- .../plc4x/java/spi/values/PlcDWORD.java | 4 +- .../apache/plc4x/java/spi/values/PlcINT.java | 4 +- .../apache/plc4x/java/spi/values/PlcLINT.java | 4 +- .../apache/plc4x/java/spi/values/PlcSINT.java | 4 +- .../plc4x/java/spi/values/PlcUDINT.java | 4 +- .../apache/plc4x/java/spi/values/PlcUINT.java | 4 +- .../plc4x/java/spi/values/PlcUSINT.java | 4 +- .../apache/plc4x/java/spi/values/PlcWORD.java | 4 +- .../values/DefaultPlcValueHandlerTest.java | 146 ++++++++++++++++-- 10 files changed, 153 insertions(+), 29 deletions(-) diff --git a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/values/PlcDINT.java b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/values/PlcDINT.java index dc587043a94..bf53361080a 100644 --- a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/values/PlcDINT.java +++ b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/values/PlcDINT.java @@ -85,7 +85,7 @@ public PlcDINT(Long value) { } public PlcDINT(Float value) { - if ((value < minValue) || (value > maxValue) || (value % 1 != 0)) { + if ((value < minValue) || (value > maxValue)) { throw new PlcInvalidTagException(String.format(VALUE_OUT_OF_RANGE, value, minValue, maxValue, this.getClass().getSimpleName())); } this.value = value.intValue(); @@ -93,7 +93,7 @@ public PlcDINT(Float value) { } public PlcDINT(Double value) { - if ((value < minValue) || (value > maxValue) || (value % 1 != 0)) { + if ((value < minValue) || (value > maxValue)) { throw new PlcInvalidTagException(String.format(VALUE_OUT_OF_RANGE, value, minValue, maxValue, this.getClass().getSimpleName())); } this.value = value.intValue(); diff --git a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/values/PlcDWORD.java b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/values/PlcDWORD.java index e33a6f9f25a..8277e1111ed 100644 --- a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/values/PlcDWORD.java +++ b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/values/PlcDWORD.java @@ -96,7 +96,7 @@ public PlcDWORD(Long value) { } public PlcDWORD(Float value) { - if ((value < minValue) || (value > maxValue) || (value % 1 != 0)) { + if ((value < minValue) || (value > maxValue)) { throw new PlcInvalidTagException(String.format(VALUE_OUT_OF_RANGE, value, minValue, maxValue, this.getClass().getSimpleName())); } this.value = value.longValue(); @@ -104,7 +104,7 @@ public PlcDWORD(Float value) { } public PlcDWORD(Double value) { - if ((value < minValue) || (value > maxValue) || (value % 1 != 0)) { + if ((value < minValue) || (value > maxValue)) { throw new PlcInvalidTagException(String.format(VALUE_OUT_OF_RANGE, value, minValue, maxValue, this.getClass().getSimpleName())); } this.value = value.longValue(); diff --git a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/values/PlcINT.java b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/values/PlcINT.java index 93caa2ce753..dc3e2ec0521 100644 --- a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/values/PlcINT.java +++ b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/values/PlcINT.java @@ -89,7 +89,7 @@ public PlcINT(Long value) { } public PlcINT(Float value) { - if ((value < minValue) || (value > maxValue) || (value % 1 != 0)) { + if ((value < minValue) || (value > maxValue)) { throw new PlcInvalidTagException(String.format(VALUE_OUT_OF_RANGE, value, minValue, maxValue, this.getClass().getSimpleName())); } this.value = value.shortValue(); @@ -97,7 +97,7 @@ public PlcINT(Float value) { } public PlcINT(Double value) { - if ((value < minValue) || (value > maxValue) || (value % 1 != 0)) { + if ((value < minValue) || (value > maxValue)) { throw new PlcInvalidTagException(String.format(VALUE_OUT_OF_RANGE, value, minValue, maxValue, this.getClass().getSimpleName())); } this.value = value.shortValue(); diff --git a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/values/PlcLINT.java b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/values/PlcLINT.java index 1e1ecfac0f9..92885d29b22 100644 --- a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/values/PlcLINT.java +++ b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/values/PlcLINT.java @@ -82,7 +82,7 @@ public PlcLINT(Long value) { } public PlcLINT(Float value) { - if ((value < minValue) || (value > maxValue) || (value % 1 != 0)) { + if ((value < minValue) || (value > maxValue)) { throw new PlcInvalidTagException(String.format(VALUE_OUT_OF_RANGE, value, minValue, maxValue, this.getClass().getSimpleName())); } this.value = value.longValue(); @@ -90,7 +90,7 @@ public PlcLINT(Float value) { } public PlcLINT(Double value) { - if ((value < minValue) || (value > maxValue) || (value % 1 != 0)) { + if ((value < minValue) || (value > maxValue)) { throw new PlcInvalidTagException(String.format(VALUE_OUT_OF_RANGE, value, minValue, maxValue, this.getClass().getSimpleName())); } this.value = value.longValue(); diff --git a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/values/PlcSINT.java b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/values/PlcSINT.java index 162f430caaf..d481bc68173 100644 --- a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/values/PlcSINT.java +++ b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/values/PlcSINT.java @@ -91,7 +91,7 @@ public PlcSINT(Long value) { } public PlcSINT(Float value) { - if ((value < minValue) || (value > maxValue) || (value % 1 != 0)) { + if ((value < minValue) || (value > maxValue)) { throw new PlcInvalidTagException(String.format(VALUE_OUT_OF_RANGE, value, minValue, maxValue, this.getClass().getSimpleName())); } this.value = value.byteValue(); @@ -99,7 +99,7 @@ public PlcSINT(Float value) { } public PlcSINT(Double value) { - if ((value < minValue) || (value > maxValue) || (value % 1 != 0)) { + if ((value < minValue) || (value > maxValue)) { throw new PlcInvalidTagException(String.format(VALUE_OUT_OF_RANGE, value, minValue, maxValue, this.getClass().getSimpleName())); } this.value = value.byteValue(); diff --git a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/values/PlcUDINT.java b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/values/PlcUDINT.java index ede2fa8a038..bbd942a4c86 100644 --- a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/values/PlcUDINT.java +++ b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/values/PlcUDINT.java @@ -94,7 +94,7 @@ public PlcUDINT(Long value) { } public PlcUDINT(Float value) { - if ((value < minValue) || (value > maxValue) || (value % 1 != 0)) { + if ((value < minValue) || (value > maxValue)) { throw new PlcInvalidTagException(String.format(VALUE_OUT_OF_RANGE, value, minValue, maxValue, this.getClass().getSimpleName())); } this.value = value.longValue(); @@ -102,7 +102,7 @@ public PlcUDINT(Float value) { } public PlcUDINT(Double value) { - if ((value < minValue) || (value > maxValue) || (value % 1 != 0)) { + if ((value < minValue) || (value > maxValue)) { throw new PlcInvalidTagException(String.format(VALUE_OUT_OF_RANGE, value, minValue, maxValue, this.getClass().getSimpleName())); } this.value = value.longValue(); diff --git a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/values/PlcUINT.java b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/values/PlcUINT.java index ee7a66c4f5d..e535958fba8 100644 --- a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/values/PlcUINT.java +++ b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/values/PlcUINT.java @@ -91,7 +91,7 @@ public PlcUINT(Long value) { } public PlcUINT(Float value) { - if ((value < minValue) || (value > maxValue) || (value % 1 != 0)) { + if ((value < minValue) || (value > maxValue)) { throw new PlcInvalidTagException(String.format(VALUE_OUT_OF_RANGE, value, minValue, maxValue, this.getClass().getSimpleName())); } this.value = value.intValue(); @@ -99,7 +99,7 @@ public PlcUINT(Float value) { } public PlcUINT(Double value) { - if ((value < minValue) || (value > maxValue) || (value % 1 != 0)) { + if ((value < minValue) || (value > maxValue)) { throw new PlcInvalidTagException(String.format(VALUE_OUT_OF_RANGE, value, minValue, maxValue, this.getClass().getSimpleName())); } this.value = value.intValue(); diff --git a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/values/PlcUSINT.java b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/values/PlcUSINT.java index d6f16e8b2b7..c0937f05b6e 100644 --- a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/values/PlcUSINT.java +++ b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/values/PlcUSINT.java @@ -94,7 +94,7 @@ public PlcUSINT(Long value) { } public PlcUSINT(Float value) { - if ((value < minValue) || (value > maxValue) || (value % 1 != 0)) { + if ((value < minValue) || (value > maxValue)) { throw new PlcInvalidTagException(String.format(VALUE_OUT_OF_RANGE, value, minValue, maxValue, this.getClass().getSimpleName())); } this.value = value.shortValue(); @@ -102,7 +102,7 @@ public PlcUSINT(Float value) { } public PlcUSINT(Double value) { - if ((value < minValue) || (value > maxValue) || (value % 1 != 0)) { + if ((value < minValue) || (value > maxValue)) { throw new PlcInvalidTagException(String.format(VALUE_OUT_OF_RANGE, value, minValue, maxValue, this.getClass().getSimpleName())); } this.value = value.shortValue(); diff --git a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/values/PlcWORD.java b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/values/PlcWORD.java index 9003db77532..707aaefbb76 100644 --- a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/values/PlcWORD.java +++ b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/values/PlcWORD.java @@ -92,7 +92,7 @@ public PlcWORD(Long value) { } public PlcWORD(Float value) { - if ((value < minValue) || (value > maxValue) || (value % 1 != 0)) { + if ((value < minValue) || (value > maxValue)) { throw new PlcInvalidTagException(String.format(VALUE_OUT_OF_RANGE, value, minValue, maxValue, this.getClass().getSimpleName())); } this.value = value.intValue(); @@ -100,7 +100,7 @@ public PlcWORD(Float value) { } public PlcWORD(Double value) { - if ((value < minValue) || (value > maxValue) || (value % 1 != 0)) { + if ((value < minValue) || (value > maxValue)) { throw new PlcInvalidTagException(String.format(VALUE_OUT_OF_RANGE, value, minValue, maxValue, this.getClass().getSimpleName())); } this.value = value.intValue(); diff --git a/plc4j/spi/src/test/java/org/apache/plc4x/java/spi/values/DefaultPlcValueHandlerTest.java b/plc4j/spi/src/test/java/org/apache/plc4x/java/spi/values/DefaultPlcValueHandlerTest.java index 296a6466643..6b6d27c155f 100644 --- a/plc4j/spi/src/test/java/org/apache/plc4x/java/spi/values/DefaultPlcValueHandlerTest.java +++ b/plc4j/spi/src/test/java/org/apache/plc4x/java/spi/values/DefaultPlcValueHandlerTest.java @@ -78,45 +78,169 @@ private static Stream getSingleElementPlcValues() { Arguments.of(new MockTag("mock", PlcValueType.BYTE), BigInteger.TEN, new PlcBYTE(10)), Arguments.of(new MockTag("mock", PlcValueType.BYTE), BigDecimal.TEN, new PlcBYTE(10)), Arguments.of(new MockTag("mock", PlcValueType.BYTE), "42", new PlcBYTE(42)), + // TODO: Add some range tests (values above the max and below the min value) // WORD values - Arguments.of(new MockTag("mock", PlcValueType.WORD), 2, new PlcWORD(2)), + Arguments.of(new MockTag("mock", PlcValueType.WORD), true, new PlcWORD(1)), + Arguments.of(new MockTag("mock", PlcValueType.WORD), false, new PlcWORD(0)), + Arguments.of(new MockTag("mock", PlcValueType.WORD), (byte) 42, new PlcWORD(42)), + Arguments.of(new MockTag("mock", PlcValueType.WORD), (short) 42, new PlcWORD(42)), + Arguments.of(new MockTag("mock", PlcValueType.WORD), 42, new PlcWORD(42)), + Arguments.of(new MockTag("mock", PlcValueType.WORD), (long) 42, new PlcWORD(42)), + Arguments.of(new MockTag("mock", PlcValueType.WORD), (float) 42.34, new PlcWORD(42)), + Arguments.of(new MockTag("mock", PlcValueType.WORD), (double) 42.34, new PlcWORD(42)), + Arguments.of(new MockTag("mock", PlcValueType.WORD), BigInteger.TEN, new PlcWORD(10)), + Arguments.of(new MockTag("mock", PlcValueType.WORD), BigDecimal.TEN, new PlcWORD(10)), + Arguments.of(new MockTag("mock", PlcValueType.WORD), "42", new PlcWORD(42)), + // TODO: Add some range tests (values above the max and below the min value) // DWORD values - Arguments.of(new MockTag("mock", PlcValueType.DWORD), 3, new PlcDWORD(3)), + Arguments.of(new MockTag("mock", PlcValueType.DWORD), true, new PlcDWORD(1)), + Arguments.of(new MockTag("mock", PlcValueType.DWORD), false, new PlcDWORD(0)), + Arguments.of(new MockTag("mock", PlcValueType.DWORD), (byte) 42, new PlcDWORD(42)), + Arguments.of(new MockTag("mock", PlcValueType.DWORD), (short) 42, new PlcDWORD(42)), + Arguments.of(new MockTag("mock", PlcValueType.DWORD), 42, new PlcDWORD(42)), + Arguments.of(new MockTag("mock", PlcValueType.DWORD), (long) 42, new PlcDWORD(42)), + Arguments.of(new MockTag("mock", PlcValueType.DWORD), (float) 42.34, new PlcDWORD(42)), + Arguments.of(new MockTag("mock", PlcValueType.DWORD), (double) 42.34, new PlcDWORD(42)), + Arguments.of(new MockTag("mock", PlcValueType.DWORD), BigInteger.TEN, new PlcDWORD(10)), + Arguments.of(new MockTag("mock", PlcValueType.DWORD), BigDecimal.TEN, new PlcDWORD(10)), + Arguments.of(new MockTag("mock", PlcValueType.DWORD), "42", new PlcDWORD(42)), + // TODO: Add some range tests (values above the max and below the min value) // LWORD values - Arguments.of(new MockTag("mock", PlcValueType.LWORD), 4, new PlcLWORD(4)), + Arguments.of(new MockTag("mock", PlcValueType.LWORD), true, new PlcLWORD(1)), + Arguments.of(new MockTag("mock", PlcValueType.LWORD), false, new PlcLWORD(0)), + Arguments.of(new MockTag("mock", PlcValueType.LWORD), (byte) 42, new PlcLWORD(42)), + Arguments.of(new MockTag("mock", PlcValueType.LWORD), (short) 42, new PlcLWORD(42)), + Arguments.of(new MockTag("mock", PlcValueType.LWORD), 42, new PlcLWORD(42)), + Arguments.of(new MockTag("mock", PlcValueType.LWORD), (long) 42, new PlcLWORD(42)), + Arguments.of(new MockTag("mock", PlcValueType.LWORD), (float) 42.34, new PlcLWORD(42)), + Arguments.of(new MockTag("mock", PlcValueType.LWORD), (double) 42.34, new PlcLWORD(42)), + Arguments.of(new MockTag("mock", PlcValueType.LWORD), BigInteger.TEN, new PlcLWORD(10)), + Arguments.of(new MockTag("mock", PlcValueType.LWORD), BigDecimal.TEN, new PlcLWORD(10)), + Arguments.of(new MockTag("mock", PlcValueType.LWORD), "42", new PlcLWORD(42)), + // TODO: Add some range tests (values above the max and below the min value) // USINT values - Arguments.of(new MockTag("mock", PlcValueType.USINT), 5, new PlcUSINT(5)), + Arguments.of(new MockTag("mock", PlcValueType.USINT), true, new PlcUSINT(1)), + Arguments.of(new MockTag("mock", PlcValueType.USINT), false, new PlcUSINT(0)), + Arguments.of(new MockTag("mock", PlcValueType.USINT), (byte) 42, new PlcUSINT(42)), + Arguments.of(new MockTag("mock", PlcValueType.USINT), (short) 42, new PlcUSINT(42)), + Arguments.of(new MockTag("mock", PlcValueType.USINT), 42, new PlcUSINT(42)), + Arguments.of(new MockTag("mock", PlcValueType.USINT), (long) 42, new PlcUSINT(42)), + Arguments.of(new MockTag("mock", PlcValueType.USINT), (float) 42.34, new PlcUSINT(42)), + Arguments.of(new MockTag("mock", PlcValueType.USINT), (double) 42.34, new PlcUSINT(42)), + Arguments.of(new MockTag("mock", PlcValueType.USINT), BigInteger.TEN, new PlcUSINT(10)), + Arguments.of(new MockTag("mock", PlcValueType.USINT), BigDecimal.TEN, new PlcUSINT(10)), + Arguments.of(new MockTag("mock", PlcValueType.USINT), "42", new PlcUSINT(42)), + // TODO: Add some range tests (values above the max and below the min value) // UINT values - Arguments.of(new MockTag("mock", PlcValueType.UINT), 6, new PlcUINT(6)), + Arguments.of(new MockTag("mock", PlcValueType.UINT), true, new PlcUINT(1)), + Arguments.of(new MockTag("mock", PlcValueType.UINT), false, new PlcUINT(0)), + Arguments.of(new MockTag("mock", PlcValueType.UINT), (byte) 42, new PlcUINT(42)), + Arguments.of(new MockTag("mock", PlcValueType.UINT), (short) 42, new PlcUINT(42)), + Arguments.of(new MockTag("mock", PlcValueType.UINT), 42, new PlcUINT(42)), + Arguments.of(new MockTag("mock", PlcValueType.UINT), (long) 42, new PlcUINT(42)), + Arguments.of(new MockTag("mock", PlcValueType.UINT), (float) 42.34, new PlcUINT(42)), + Arguments.of(new MockTag("mock", PlcValueType.UINT), (double) 42.34, new PlcUINT(42)), + Arguments.of(new MockTag("mock", PlcValueType.UINT), BigInteger.TEN, new PlcUINT(10)), + Arguments.of(new MockTag("mock", PlcValueType.UINT), BigDecimal.TEN, new PlcUINT(10)), + Arguments.of(new MockTag("mock", PlcValueType.UINT), "42", new PlcUINT(42)), + // TODO: Add some range tests (values above the max and below the min value) // UDINT values - Arguments.of(new MockTag("mock", PlcValueType.UDINT), 7, new PlcUDINT(7)), + Arguments.of(new MockTag("mock", PlcValueType.UDINT), true, new PlcUDINT(1)), + Arguments.of(new MockTag("mock", PlcValueType.UDINT), false, new PlcUDINT(0)), + Arguments.of(new MockTag("mock", PlcValueType.UDINT), (byte) 42, new PlcUDINT(42)), + Arguments.of(new MockTag("mock", PlcValueType.UDINT), (short) 42, new PlcUDINT(42)), + Arguments.of(new MockTag("mock", PlcValueType.UDINT), 42, new PlcUDINT(42)), + Arguments.of(new MockTag("mock", PlcValueType.UDINT), (long) 42, new PlcUDINT(42)), + Arguments.of(new MockTag("mock", PlcValueType.UDINT), (float) 42.34, new PlcUDINT(42)), + Arguments.of(new MockTag("mock", PlcValueType.UDINT), (double) 42.34, new PlcUDINT(42)), + Arguments.of(new MockTag("mock", PlcValueType.UDINT), BigInteger.TEN, new PlcUDINT(10)), + Arguments.of(new MockTag("mock", PlcValueType.UDINT), BigDecimal.TEN, new PlcUDINT(10)), + Arguments.of(new MockTag("mock", PlcValueType.UDINT), "42", new PlcUDINT(42)), + // TODO: Add some range tests (values above the max and below the min value) // ULINT values - Arguments.of(new MockTag("mock", PlcValueType.ULINT), 8, new PlcULINT(8)), + Arguments.of(new MockTag("mock", PlcValueType.ULINT), true, new PlcULINT(1)), + Arguments.of(new MockTag("mock", PlcValueType.ULINT), false, new PlcULINT(0)), + Arguments.of(new MockTag("mock", PlcValueType.ULINT), (byte) 42, new PlcULINT(42)), + Arguments.of(new MockTag("mock", PlcValueType.ULINT), (short) 42, new PlcULINT(42)), + Arguments.of(new MockTag("mock", PlcValueType.ULINT), 42, new PlcULINT(42)), + Arguments.of(new MockTag("mock", PlcValueType.ULINT), (long) 42, new PlcULINT(42)), + Arguments.of(new MockTag("mock", PlcValueType.ULINT), (float) 42.34, new PlcULINT(42)), + Arguments.of(new MockTag("mock", PlcValueType.ULINT), (double) 42.34, new PlcULINT(42)), + Arguments.of(new MockTag("mock", PlcValueType.ULINT), BigInteger.TEN, new PlcULINT(10)), + Arguments.of(new MockTag("mock", PlcValueType.ULINT), BigDecimal.TEN, new PlcULINT(10)), + Arguments.of(new MockTag("mock", PlcValueType.ULINT), "42", new PlcULINT(42)), + // TODO: Add some range tests (values above the max and below the min value) // SINT values - Arguments.of(new MockTag("mock", PlcValueType.SINT), 9, new PlcSINT(9)), + Arguments.of(new MockTag("mock", PlcValueType.SINT), true, new PlcSINT(1)), + Arguments.of(new MockTag("mock", PlcValueType.SINT), false, new PlcSINT(0)), + Arguments.of(new MockTag("mock", PlcValueType.SINT), (byte) 42, new PlcSINT(42)), + Arguments.of(new MockTag("mock", PlcValueType.SINT), (short) 42, new PlcSINT(42)), + Arguments.of(new MockTag("mock", PlcValueType.SINT), 42, new PlcSINT(42)), + Arguments.of(new MockTag("mock", PlcValueType.SINT), (long) 42, new PlcSINT(42)), + Arguments.of(new MockTag("mock", PlcValueType.SINT), (float) 42.34, new PlcSINT(42)), + Arguments.of(new MockTag("mock", PlcValueType.SINT), (double) 42.34, new PlcSINT(42)), + Arguments.of(new MockTag("mock", PlcValueType.SINT), BigInteger.TEN, new PlcSINT(10)), + Arguments.of(new MockTag("mock", PlcValueType.SINT), BigDecimal.TEN, new PlcSINT(10)), + Arguments.of(new MockTag("mock", PlcValueType.SINT), "42", new PlcSINT(42)), + // TODO: Add some range tests (values above the max and below the min value) // INT values - Arguments.of(new MockTag("mock", PlcValueType.INT), 10, new PlcINT(10)), + Arguments.of(new MockTag("mock", PlcValueType.INT), true, new PlcINT(1)), + Arguments.of(new MockTag("mock", PlcValueType.INT), false, new PlcINT(0)), + Arguments.of(new MockTag("mock", PlcValueType.INT), (byte) 42, new PlcINT(42)), + Arguments.of(new MockTag("mock", PlcValueType.INT), (short) 42, new PlcINT(42)), + Arguments.of(new MockTag("mock", PlcValueType.INT), 42, new PlcINT(42)), + Arguments.of(new MockTag("mock", PlcValueType.INT), (long) 42, new PlcINT(42)), + Arguments.of(new MockTag("mock", PlcValueType.INT), (float) 42.34, new PlcINT(42)), + Arguments.of(new MockTag("mock", PlcValueType.INT), (double) 42.34, new PlcINT(42)), + Arguments.of(new MockTag("mock", PlcValueType.INT), BigInteger.TEN, new PlcINT(10)), + Arguments.of(new MockTag("mock", PlcValueType.INT), BigDecimal.TEN, new PlcINT(10)), + Arguments.of(new MockTag("mock", PlcValueType.INT), "42", new PlcINT(42)), + // TODO: Add some range tests (values above the max and below the min value) // DINT values - Arguments.of(new MockTag("mock", PlcValueType.DINT), 11, new PlcDINT(11)), + Arguments.of(new MockTag("mock", PlcValueType.DINT), true, new PlcDINT(1)), + Arguments.of(new MockTag("mock", PlcValueType.DINT), false, new PlcDINT(0)), + Arguments.of(new MockTag("mock", PlcValueType.DINT), (byte) 42, new PlcDINT(42)), + Arguments.of(new MockTag("mock", PlcValueType.DINT), (short) 42, new PlcDINT(42)), + Arguments.of(new MockTag("mock", PlcValueType.DINT), 42, new PlcDINT(42)), + Arguments.of(new MockTag("mock", PlcValueType.DINT), (long) 42, new PlcDINT(42)), + Arguments.of(new MockTag("mock", PlcValueType.DINT), (float) 42.34, new PlcDINT(42)), + Arguments.of(new MockTag("mock", PlcValueType.DINT), (double) 42.34, new PlcDINT(42)), + Arguments.of(new MockTag("mock", PlcValueType.DINT), BigInteger.TEN, new PlcDINT(10)), + Arguments.of(new MockTag("mock", PlcValueType.DINT), BigDecimal.TEN, new PlcDINT(10)), + Arguments.of(new MockTag("mock", PlcValueType.DINT), "42", new PlcDINT(42)), + // TODO: Add some range tests (values above the max and below the min value) // LINT values - Arguments.of(new MockTag("mock", PlcValueType.LINT), 12, new PlcLINT(12)), + Arguments.of(new MockTag("mock", PlcValueType.LINT), true, new PlcLINT(1)), + Arguments.of(new MockTag("mock", PlcValueType.LINT), false, new PlcLINT(0)), + Arguments.of(new MockTag("mock", PlcValueType.LINT), (byte) 42, new PlcLINT(42)), + Arguments.of(new MockTag("mock", PlcValueType.LINT), (short) 42, new PlcLINT(42)), + Arguments.of(new MockTag("mock", PlcValueType.LINT), 42, new PlcLINT(42)), + Arguments.of(new MockTag("mock", PlcValueType.LINT), (long) 42, new PlcLINT(42)), + Arguments.of(new MockTag("mock", PlcValueType.LINT), (float) 42.34, new PlcLINT(42)), + Arguments.of(new MockTag("mock", PlcValueType.LINT), (double) 42.34, new PlcLINT(42)), + Arguments.of(new MockTag("mock", PlcValueType.LINT), BigInteger.TEN, new PlcLINT(10)), + Arguments.of(new MockTag("mock", PlcValueType.LINT), BigDecimal.TEN, new PlcLINT(10)), + Arguments.of(new MockTag("mock", PlcValueType.LINT), "42", new PlcLINT(42)), + // TODO: Add some range tests (values above the max and below the min value) // REAL values Arguments.of(new MockTag("mock", PlcValueType.REAL), 1.3, new PlcREAL(1.3)), + // TODO: Add some range tests (values above the max and below the min value) // LREAL values Arguments.of(new MockTag("mock", PlcValueType.LREAL), 1.4, new PlcLREAL(1.4)), + // TODO: Add some range tests (values above the max and below the min value) // CHAR values Arguments.of(new MockTag("mock", PlcValueType.CHAR), "A", new PlcCHAR("A")),