use of tuwien.auto.calimero.dptxlator.DPT in project openhab1-addons by openhab.
the class KNXCoreTypeMapperTest method testTypeMapping8BitSigned_6_010.
/**
* KNXCoreTypeMapper tests method typeMapper.toType() for type “8-Bit Signed Value" KNX ID: 6.010
* DPT_VALUE_1_UCOUNT
*
* @throws KNXFormatException
*/
@Test
public void testTypeMapping8BitSigned_6_010() throws KNXFormatException {
DPT dpt = DPTXlator8BitSigned.DPT_VALUE_1_UCOUNT;
testToTypeClass(dpt, DecimalType.class);
// Use a too short byte array
assertNull("KNXCoreTypeMapper.toType() should return null (required data length too short)", testToType(dpt, new byte[] {}, DecimalType.class));
Type type = testToType(dpt, new byte[] { 0 }, DecimalType.class);
testToDPTValue(dpt, type, "0");
type = testToType(dpt, new byte[] { (byte) 0x7F }, DecimalType.class);
testToDPTValue(dpt, type, "127");
type = testToType(dpt, new byte[] { (byte) 0x80 }, DecimalType.class);
testToDPTValue(dpt, type, "-128");
type = testToType(dpt, new byte[] { (byte) 0xFF }, DecimalType.class);
testToDPTValue(dpt, type, "-1");
// Use a too long byte array expecting that additional bytes will be ignored
type = testToType(dpt, new byte[] { (byte) 0xFF, 0 }, DecimalType.class);
testToDPTValue(dpt, type, "-1");
}
use of tuwien.auto.calimero.dptxlator.DPT in project openhab1-addons by openhab.
the class KNXCoreTypeMapperTest method testTypeMappingTime_10_001_SecondsOutOfBounds.
/**
* KNXCoreTypeMapper tests method typeMapper.toType() for type “Time" KNX ID: 10.001 DPT_TIMEOFDAY
*
* Set day to Monday, 23 hours, 59 minutes and 60 seconds
*
* @throws KNXFormatException
*/
@Test
public void testTypeMappingTime_10_001_SecondsOutOfBounds() throws KNXFormatException {
DPT dpt = DPTXlatorTime.DPT_TIMEOFDAY;
testToTypeClass(dpt, DateTimeType.class);
assertNull("KNXCoreTypeMapper.toType() should return null", testToType(dpt, new byte[] { 0x37, 59, 60 }, DateTimeType.class));
}
use of tuwien.auto.calimero.dptxlator.DPT in project openhab1-addons by openhab.
the class KNXCoreTypeMapperTest method testTypeMappingDate_11_001_ZeroDay.
/**
* KNXCoreTypeMapper tests method typeMapper.toType() for type “Time" KNX ID: 11.001 DPT_DATE
*
* Test illegal data (day and month cannot be 0) This should throw an KNXIllegalArgumentException
*
* @throws KNXFormatException
*/
@Test
public void testTypeMappingDate_11_001_ZeroDay() throws KNXFormatException {
DPT dpt = DPTXlatorDate.DPT_DATE;
testToTypeClass(dpt, DateTimeType.class);
assertNull("KNXCoreTypeMapper.toType() should return null", testToType(dpt, new byte[] { 0x00, 0x00, 0x00 }, DateTimeType.class));
}
use of tuwien.auto.calimero.dptxlator.DPT in project openhab1-addons by openhab.
the class KNXCoreTypeMapperTest method testTypeMapping4ByteUnsigned_12_001.
/**
* KNXCoreTypeMapper tests method typeMapper.toType() for type “4-Octet Unsigned Value" KNX ID: 12.001
* DPT_VALUE_4_UCOUNT
*
* @throws KNXFormatException
*/
@Test
public void testTypeMapping4ByteUnsigned_12_001() throws KNXFormatException {
DPT dpt = DPTXlator4ByteUnsigned.DPT_VALUE_4_UCOUNT;
testToTypeClass(dpt, DecimalType.class);
// Use a too short byte array
assertNull("KNXCoreTypeMapper.toType() should return null (required data length too short)", testToType(dpt, new byte[] {}, DecimalType.class));
// Use a too long byte array expecting that additional bytes will be ignored
Type type = testToType(dpt, new byte[] { (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF }, DecimalType.class);
testToDPTValue(dpt, type, "4294967295");
type = testToType(dpt, new byte[] { 0x00, 0x00, 0x00, 0x00 }, DecimalType.class);
testToDPTValue(dpt, type, "0");
type = testToType(dpt, new byte[] { (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF }, DecimalType.class);
testToDPTValue(dpt, type, "4294967295");
}
use of tuwien.auto.calimero.dptxlator.DPT in project openhab1-addons by openhab.
the class KNXCoreTypeMapperTest method testTypeMapping2ByteUnsigned_7_003.
/**
* KNXCoreTypeMapper tests method typeMapper.toType() for type “2-Octet Unsigned Value" KNX ID: 7.003
* DPT_TIMEPERIOD_10
*
* @throws KNXFormatException
*/
@Test
public void testTypeMapping2ByteUnsigned_7_003() throws KNXFormatException {
DPT dpt = DPTXlator2ByteUnsigned.DPT_TIMEPERIOD_10;
testToTypeClass(dpt, DecimalType.class);
// Use a too short byte array
assertNull("KNXCoreTypeMapper.toType() should return null (required data length too short)", testToType(dpt, new byte[] {}, DecimalType.class));
Type type = testToType(dpt, new byte[] { 0x00, 0x00 }, DecimalType.class);
testToDPTValue(dpt, type, "0");
type = testToType(dpt, new byte[] { (byte) 0xFF, 0x00 }, DecimalType.class);
testToDPTValue(dpt, type, "652800");
type = testToType(dpt, new byte[] { (byte) 0xFF, (byte) 0xFF }, DecimalType.class);
testToDPTValue(dpt, type, "655350");
// Use a too long byte array expecting that additional bytes will be ignored
type = testToType(dpt, new byte[] { (byte) 0xFF, (byte) 0xFF, (byte) 0xFF }, DecimalType.class);
testToDPTValue(dpt, type, "655350");
}
Aggregations