forked from nus-cs2103-AY1718S2/addressbook-level2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
UtilsTest.java
46 lines (35 loc) · 1.19 KB
/
UtilsTest.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package seedu.addressbook.common;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import java.util.Arrays;
import java.util.List;
import org.junit.Test;
public class UtilsTest {
@Test
public void elementsAreUnique() throws Exception {
// empty list
assertAreUnique();
// only one object
assertAreUnique((Object) null);
assertAreUnique(1);
assertAreUnique("");
assertAreUnique("abc");
// all objects unique
assertAreUnique("abc", "ab", "a");
assertAreUnique(1, 2);
// some identical objects
assertNotUnique("abc", "abc");
assertNotUnique("abc", "", "abc", "ABC");
assertNotUnique("", "abc", "a", "abc");
assertNotUnique(1, new Integer(1));
assertNotUnique(null, 1, new Integer(1));
assertNotUnique(null, null);
assertNotUnique(null, "a", "b", null);
}
private void assertAreUnique(Object... objects) {
assertTrue(Utils.elementsAreUnique(Arrays.asList(objects)));
}
private void assertNotUnique(Object... objects) {
assertFalse(Utils.elementsAreUnique(Arrays.asList(objects)));
}
}