Debian Codegraph @

minidns-core/src/test/java/org/minidns/Assert.java

raw
1 /*
2 * Copyright 2015-2020 the original author or authors
3 *
4 * This software is licensed under the Apache License, Version 2.0,
5 * the GNU Lesser General Public License version 2 or later ("LGPL")
6 * and the WTFPL.
7 * You may choose either license to govern your use of this software only
8 * upon the condition that you accept all of the terms of either
9 * the Apache License 2.0, the LGPL 2.1+ or the WTFPL.
10 */
11 package org.minidns;
12
13 import static org.junit.jupiter.api.Assertions.assertEquals;
14 import static org.junit.jupiter.api.Assertions.assertTrue;
15
16 import java.util.ArrayList;
17 import java.util.Arrays;
18 import java.util.Collection;
19 import java.util.List;
20
21 public class Assert {
22
23 public static void assertCsEquals(CharSequence expected, CharSequence actual) {
24 assertCsEquals(null, expected, actual);
25 }
26
27 public static void assertCsEquals(String message, CharSequence expected, CharSequence actual) {
28 if (expected != null && actual != null) {
29 assertEquals(expected.toString(), actual.toString(), message);
30 } else {
31 assertEquals(expected, actual, message);
32 }
33 }
34
35 public static <T> void assertArrayContentEquals(T[] expect, Collection<? extends T> value) {
36 assertEquals(expect.length, value.size());
37 List<T> list = new ArrayList<>(Arrays.asList(expect));
38 for (Object type : value) {
39 assertTrue(list.remove(type));
40 }
41 assertTrue(list.isEmpty());
42 }
43 }