]> git.basschouten.com Git - openhab-addons.git/blob
e0926b21d92c70f5f73696217599424e7f2995ec
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2023 Contributors to the openHAB project
3  *
4  * See the NOTICE file(s) distributed with this work for additional
5  * information.
6  *
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
10  *
11  * SPDX-License-Identifier: EPL-2.0
12  */
13 package org.openhab.binding.paradoxalarm.internal;
14
15 import static org.junit.jupiter.api.Assertions.assertArrayEquals;
16
17 import org.eclipse.jdt.annotation.NonNullByDefault;
18 import org.junit.jupiter.api.Test;
19 import org.openhab.binding.paradoxalarm.internal.util.ParadoxUtil;
20
21 /**
22  * The {@link TestParadoxUtil} This test tests various functions from ParadoxUtils class
23  *
24  * @author Konstantin Polihronov - Initial contribution
25  */
26 @NonNullByDefault
27 public class TestParadoxUtil {
28
29     @Test
30     public void testExtendArray() {
31         byte[] arrayToExtend = { 0x0A, 0x50, 0x08, 0x00, 0x00, 0x01, 0x00, 0x00, 0x59 };
32         final int rate = 16;
33         byte[] extendedArray = ParadoxUtil.extendArray(arrayToExtend, rate);
34
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); //
38     }
39
40     @Test
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);
46
47         final byte[] expectedResult = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09 };
48         assertArrayEquals(expectedResult, mergedArrays);
49     }
50 }