assertNull("KNXCoreTypeMapper.toType() should return null (required data length too short)",
testToType(dpt, new byte[] { }, DecimalType.class));
try {
// Use a too long byte array expecting that additional bytes will be ignored
Type type=testToType(dpt, new byte[] { (byte) 0x7F, (byte) 0x7F, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF }, DecimalType.class);
testToDPTValue(dpt, type, "340282000000000000000000000000000000000");
}
catch (NumberFormatException nfe) {
fail("DptId: "+dpt.getID()+", locale: "+locale+", NumberFormatException. Expecting 0.0");
}
try {
Type type=testToType(dpt, new byte[] { 0x00, 0x00, 0x00, 0x00 }, DecimalType.class);
testToDPTValue(dpt, type, "0.0");
}
catch (NumberFormatException nfe) {
fail("DptId: "+dpt.getID()+", locale: "+locale+", NumberFormatException. Expecting 0.0");
}
try {
// Test the smallest positive value
Type type=testToType(dpt, new byte[] { 0x00, 0x00, 0x00, 0x01 }, DecimalType.class);
testToDPTValue(dpt, type, "0.0000000000000000000000000000000000000000000014");
}
catch (NumberFormatException nfe) {
fail("DptId: "+dpt.getID()+", locale: "+locale+", NumberFormatException. Expecting 0.0000000000000000000000000000000000000000000014");
}
try {
// Test the smallest negative value
Type type=testToType(dpt, new byte[] { (byte)0x80, 0x00, 0x00, 0x01 }, DecimalType.class);
testToDPTValue(dpt, type, "-0.0000000000000000000000000000000000000000000014");
}
catch (NumberFormatException nfe) {
fail("DptId: "+dpt.getID()+", locale: "+locale+", NumberFormatException. Expecting -0.0000000000000000000000000000000000000000000014");
}
try {
// Test the maximum positive value
Type type=testToType(dpt, new byte[] { (byte) 0x7F, (byte) 0x7F, (byte) 0xFF, (byte) 0xFF }, DecimalType.class);
testToDPTValue(dpt, type, "340282000000000000000000000000000000000");
}
catch (NumberFormatException nfe) {
fail("DptId: "+dpt.getID()+", locale: "+locale+", NumberFormatException. Expecting 340282000000000000000000000000000000000");
}
try {
// Test the maximum negative value
Type type=testToType(dpt, new byte[] { (byte) 0xFF, (byte) 0x7F, (byte) 0xFF, (byte) 0xFF }, DecimalType.class);
testToDPTValue(dpt, type, "-340282000000000000000000000000000000000");
}
catch (NumberFormatException nfe) {
fail("DptId: "+dpt.getID()+", locale: "+locale+", NumberFormatException. Expecting -340282000000000000000000000000000000000");
}