Skip to content

Commit

Permalink
refactor: Added more testcases to the PlcValueHandler tests
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisdutz committed Sep 25, 2024
1 parent 7b55736 commit 3884549
Show file tree
Hide file tree
Showing 10 changed files with 153 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -85,15 +85,15 @@ 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();
this.isNullable = false;
}

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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,15 +96,15 @@ 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();
this.isNullable = false;
}

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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,15 +89,15 @@ 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();
this.isNullable = false;
}

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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,15 +82,15 @@ 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();
this.isNullable = false;
}

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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,15 +91,15 @@ 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();
this.isNullable = false;
}

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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,15 +94,15 @@ 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();
this.isNullable = false;
}

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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,15 +91,15 @@ 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();
this.isNullable = false;
}

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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,15 +94,15 @@ 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();
this.isNullable = false;
}

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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,15 +92,15 @@ 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();
this.isNullable = false;
}

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();
Expand Down
Loading

0 comments on commit 3884549

Please sign in to comment.