View Javadoc
1   /*
2    * Copyright (C) 2010, Google Inc. and others
3    *
4    * This program and the accompanying materials are made available under the
5    * terms of the Eclipse Distribution License v. 1.0 which is available at
6    * https://www.eclipse.org/org/documents/edl-v10.php.
7    *
8    * SPDX-License-Identifier: BSD-3-Clause
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  }