blob: e98d6c07aba6b986fa7207f056c0405dffffe4b3 (
plain)
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 com.vaadin.tests.util;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
import java.util.Iterator;
public class TestUtil {
public static void assertArrays(Object[] actualObjects,
Object[] expectedObjects) {
assertEquals(
"Actual contains a different number of values than was expected",
expectedObjects.length, actualObjects.length);
for (int i = 0; i < actualObjects.length; i++) {
Object actual = actualObjects[i];
Object expected = expectedObjects[i];
assertEquals("Item[" + i + "] does not match", expected, actual);
}
}
public static void assertIterableEquals(Iterable<?> iterable1,
Iterable<?> iterable2) {
Iterator<?> i1 = iterable1.iterator();
Iterator<?> i2 = iterable2.iterator();
while (i1.hasNext()) {
Object o1 = i1.next();
if (!i2.hasNext()) {
fail("The second iterable contains fewer items than the first. The object "
+ o1 + " has no match in the second iterable.");
}
Object o2 = i2.next();
assertEquals(o1, o2);
}
if (i2.hasNext()) {
fail("The second iterable contains more items than the first. The object "
+ i2.next() + " has no match in the first iterable.");
}
}
private TestUtil() {
}
}
|