summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.test/tst
diff options
context:
space:
mode:
authorHan-Wen Nienhuys <hanwen@google.com>2017-07-27 13:49:39 +0200
committerHan-Wen Nienhuys <hanwen@google.com>2017-07-27 13:49:39 +0200
commitab0eedcead5b38e446e7a022de1c749c5e37f115 (patch)
treee25d61e79e1fc9c162485bf613f2ba0f4c4b8147 /org.eclipse.jgit.test/tst
parent5b84e25fa3afe66bbfa7eb953ea0bd332c745ecd (diff)
downloadjgit-ab0eedcead5b38e446e7a022de1c749c5e37f115.tar.gz
jgit-ab0eedcead5b38e446e7a022de1c749c5e37f115.zip
Trim boilerplate in RawParseUtils_LineMapTest.
Signed-off-by: Han-Wen Nienhuys <hanwen@google.com> Change-Id: Ib003f7c8f2816dd57e941799a665e70ecd6645a2
Diffstat (limited to 'org.eclipse.jgit.test/tst')
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/util/RawParseUtils_LineMapTest.java41
1 files changed, 17 insertions, 24 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/RawParseUtils_LineMapTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/RawParseUtils_LineMapTest.java
index 593971478d..e8e191d781 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/RawParseUtils_LineMapTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/RawParseUtils_LineMapTest.java
@@ -43,6 +43,7 @@
package org.eclipse.jgit.util;
+import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
@@ -55,52 +56,44 @@ public class RawParseUtils_LineMapTest {
public void testEmpty() {
final IntList map = RawParseUtils.lineMap(new byte[] {}, 0, 0);
assertNotNull(map);
- assertEquals(2, map.size());
- assertEquals(Integer.MIN_VALUE, map.get(0));
- assertEquals(0, map.get(1));
+ assertArrayEquals(new int[]{Integer.MIN_VALUE, 0}, asInts(map));
}
@Test
public void testOneBlankLine() {
final IntList map = RawParseUtils.lineMap(new byte[] { '\n' }, 0, 1);
- assertEquals(3, map.size());
- assertEquals(Integer.MIN_VALUE, map.get(0));
- assertEquals(0, map.get(1));
- assertEquals(1, map.get(2));
+ assertArrayEquals(new int[]{Integer.MIN_VALUE, 0, 1}, asInts(map));
}
@Test
public void testTwoLineFooBar() throws UnsupportedEncodingException {
final byte[] buf = "foo\nbar\n".getBytes("ISO-8859-1");
final IntList map = RawParseUtils.lineMap(buf, 0, buf.length);
- assertEquals(4, map.size());
- assertEquals(Integer.MIN_VALUE, map.get(0));
- assertEquals(0, map.get(1));
- assertEquals(4, map.get(2));
- assertEquals(buf.length, map.get(3));
+ assertArrayEquals(new int[]{Integer.MIN_VALUE, 0, 4, buf.length}, asInts(map));
}
@Test
public void testTwoLineNoLF() throws UnsupportedEncodingException {
final byte[] buf = "foo\nbar".getBytes("ISO-8859-1");
final IntList map = RawParseUtils.lineMap(buf, 0, buf.length);
- assertEquals(4, map.size());
- assertEquals(Integer.MIN_VALUE, map.get(0));
- assertEquals(0, map.get(1));
- assertEquals(4, map.get(2));
- assertEquals(buf.length, map.get(3));
+ assertArrayEquals(new int[]{Integer.MIN_VALUE, 0, 4, buf.length}, asInts(map));
}
@Test
public void testFourLineBlanks() throws UnsupportedEncodingException {
final byte[] buf = "foo\n\n\nbar\n".getBytes("ISO-8859-1");
final IntList map = RawParseUtils.lineMap(buf, 0, buf.length);
- assertEquals(6, map.size());
- assertEquals(Integer.MIN_VALUE, map.get(0));
- assertEquals(0, map.get(1));
- assertEquals(4, map.get(2));
- assertEquals(5, map.get(3));
- assertEquals(6, map.get(4));
- assertEquals(buf.length, map.get(5));
+
+ assertArrayEquals(new int[]{
+ Integer.MIN_VALUE, 0, 4, 5, 6, buf.length
+ }, asInts(map));
+ }
+
+ private int[] asInts(IntList l) {
+ int[] result = new int[l.size()];
+ for (int i = 0; i < l.size(); i++) {
+ result[i] = l.get(i);
+ }
+ return result;
}
}