]> git.basschouten.com Git - openhab-addons.git/blob
d8bb9a06ed4daf4e3874c82c34920ae6bdebcdaf
[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
14 package org.openhab.binding.sensibo.internal.util;
15
16 import static org.junit.jupiter.api.Assertions.*;
17
18 import org.eclipse.jdt.annotation.NonNullByDefault;
19 import org.junit.jupiter.api.Test;
20
21 /**
22  * The {@link StringUtils} class defines some static string utility methods
23  *
24  * @author Leo Siepel - Initial contribution
25  */
26 @NonNullByDefault
27 public class StringUtilsTest {
28
29     @Test
30     public void splitByCharacterType() {
31         assertArrayEquals(new String[0], StringUtils.splitByCharacterType(null));
32         assertArrayEquals(new String[0], StringUtils.splitByCharacterType(""));
33         assertArrayEquals(new String[] { "ab", " ", "de", " ", "fg" }, StringUtils.splitByCharacterType("ab de fg"));
34         assertArrayEquals(new String[] { "ab", "   ", "de", " ", "fg" },
35                 StringUtils.splitByCharacterType("ab   de fg"));
36         assertArrayEquals(new String[] { "ab", ":", "cd", ":", "ef" }, StringUtils.splitByCharacterType("ab:cd:ef"));
37         assertArrayEquals(new String[] { "number", "5" }, StringUtils.splitByCharacterType("number5"));
38         assertArrayEquals(new String[] { "foo", "Bar" }, StringUtils.splitByCharacterType("fooBar"));
39         assertArrayEquals(new String[] { "foo", "200", "Bar" }, StringUtils.splitByCharacterType("foo200Bar"));
40         assertArrayEquals(new String[] { "ASF", "Rules" }, StringUtils.splitByCharacterType("ASFRules"));
41     }
42 }