commit | author | age
|
c89745
|
1 |
/*
|
JM |
2 |
* Copyright 2012 gitblit.com.
|
|
3 |
*
|
|
4 |
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5 |
* you may not use this file except in compliance with the License.
|
|
6 |
* You may obtain a copy of the License at
|
|
7 |
*
|
|
8 |
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9 |
*
|
|
10 |
* Unless required by applicable law or agreed to in writing, software
|
|
11 |
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12 |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13 |
* See the License for the specific language governing permissions and
|
|
14 |
* limitations under the License.
|
|
15 |
*/
|
|
16 |
package com.gitblit.tests;
|
|
17 |
|
|
18 |
import static org.junit.Assert.assertFalse;
|
|
19 |
import static org.junit.Assert.assertTrue;
|
|
20 |
|
|
21 |
import java.util.ArrayList;
|
|
22 |
import java.util.Arrays;
|
|
23 |
import java.util.HashSet;
|
|
24 |
import java.util.List;
|
|
25 |
import java.util.Set;
|
|
26 |
|
|
27 |
import org.junit.Test;
|
|
28 |
|
|
29 |
import com.gitblit.utils.ArrayUtils;
|
|
30 |
|
|
31 |
public class ArrayUtilsTest {
|
|
32 |
|
|
33 |
@Test
|
|
34 |
public void testArrays() {
|
|
35 |
Object [] nullArray = null;
|
|
36 |
assertTrue(ArrayUtils.isEmpty(nullArray));
|
|
37 |
|
|
38 |
Object [] emptyArray = new Object[0];
|
|
39 |
assertTrue(ArrayUtils.isEmpty(emptyArray));
|
|
40 |
|
|
41 |
assertFalse(ArrayUtils.isEmpty(new String [] { "" }));
|
|
42 |
}
|
|
43 |
|
|
44 |
@Test
|
|
45 |
public void testLists() {
|
|
46 |
List<?> nullList = null;
|
|
47 |
assertTrue(ArrayUtils.isEmpty(nullList));
|
|
48 |
|
|
49 |
List<?> emptyList = new ArrayList<Object>();
|
|
50 |
assertTrue(ArrayUtils.isEmpty(emptyList));
|
|
51 |
|
|
52 |
List<?> list = Arrays.asList("");
|
|
53 |
assertFalse(ArrayUtils.isEmpty(list));
|
|
54 |
}
|
|
55 |
|
|
56 |
@Test
|
|
57 |
public void testSets() {
|
|
58 |
Set<?> nullSet = null;
|
|
59 |
assertTrue(ArrayUtils.isEmpty(nullSet));
|
|
60 |
|
|
61 |
Set<?> emptySet = new HashSet<Object>();
|
|
62 |
assertTrue(ArrayUtils.isEmpty(emptySet));
|
|
63 |
|
|
64 |
Set<?> set = new HashSet<Object>(Arrays.asList(""));
|
|
65 |
assertFalse(ArrayUtils.isEmpty(set));
|
|
66 |
}
|
|
67 |
} |