1
2
3
4
5
6
7
8
9
10
11 package org.eclipse.jgit.util;
12
13 import static org.junit.Assert.assertEquals;
14
15 import java.io.UnsupportedEncodingException;
16
17 import org.junit.Test;
18
19 public class RawParseUtils_FormatTest {
20 @Test
21 public void testFormatBase10() throws UnsupportedEncodingException {
22 byte[] b = new byte[64];
23 int p;
24
25 p = RawParseUtils.formatBase10(b, b.length, 0);
26 assertEquals("0", new String(b, p, b.length - p, "UTF-8"));
27
28 p = RawParseUtils.formatBase10(b, b.length, 42);
29 assertEquals("42", new String(b, p, b.length - p, "UTF-8"));
30
31 p = RawParseUtils.formatBase10(b, b.length, 1234);
32 assertEquals("1234", new String(b, p, b.length - p, "UTF-8"));
33
34 p = RawParseUtils.formatBase10(b, b.length, -9876);
35 assertEquals("-9876", new String(b, p, b.length - p, "UTF-8"));
36
37 p = RawParseUtils.formatBase10(b, b.length, 123456789);
38 assertEquals("123456789", new String(b, p, b.length - p, "UTF-8"));
39 }
40 }