2 * Copyright (c) 2010-2023 Contributors to the openHAB project
4 * See the NOTICE file(s) distributed with this work for additional
7 * This program and the accompanying materials are made available under the
8 * terms of the Eclipse Public License 2.0 which is available at
9 * http://www.eclipse.org/legal/epl-2.0
11 * SPDX-License-Identifier: EPL-2.0
13 package org.openhab.binding.paradoxalarm.internal;
15 import static org.junit.jupiter.api.Assertions.assertArrayEquals;
17 import org.eclipse.jdt.annotation.NonNullByDefault;
18 import org.junit.jupiter.api.Test;
19 import org.openhab.binding.paradoxalarm.internal.util.ParadoxUtil;
22 * The {@link TestParadoxUtil} This test tests various functions from ParadoxUtils class
24 * @author Konstantin Polihronov - Initial contribution
27 public class TestParadoxUtil {
30 public void testExtendArray() {
31 byte[] arrayToExtend = { 0x0A, 0x50, 0x08, 0x00, 0x00, 0x01, 0x00, 0x00, 0x59 };
33 byte[] extendedArray = ParadoxUtil.extendArray(arrayToExtend, rate);
35 final byte[] expectedResult = { 0x0A, 0x50, 0x08, 0x00, 0x00, 0x01, 0x00, 0x00, 0x59, (byte) 0xEE, (byte) 0xEE,
36 (byte) 0xEE, (byte) 0xEE, (byte) 0xEE, (byte) 0xEE, (byte) 0xEE };
37 assertArrayEquals(expectedResult, extendedArray); //
41 public void testMergeArrays() {
42 final byte[] arr1 = { 0x01, 0x02, 0x03 };
43 final byte[] arr2 = { 0x04, 0x05, 0x06 };
44 final byte[] arr3 = { 0x07, 0x08, 0x09 };
45 byte[] mergedArrays = ParadoxUtil.mergeByteArrays(arr1, arr2, arr3);
47 final byte[] expectedResult = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09 };
48 assertArrayEquals(expectedResult, mergedArrays);