You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

RawParseUtils_FormatTest.java 1.2KB

12345678910111213141516171819202122232425262728293031323334353637383940
  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. package org.eclipse.jgit.util;
  11. import static org.junit.Assert.assertEquals;
  12. import java.io.UnsupportedEncodingException;
  13. import org.junit.Test;
  14. public class RawParseUtils_FormatTest {
  15. @Test
  16. public void testFormatBase10() throws UnsupportedEncodingException {
  17. byte[] b = new byte[64];
  18. int p;
  19. p = RawParseUtils.formatBase10(b, b.length, 0);
  20. assertEquals("0", new String(b, p, b.length - p, "UTF-8"));
  21. p = RawParseUtils.formatBase10(b, b.length, 42);
  22. assertEquals("42", new String(b, p, b.length - p, "UTF-8"));
  23. p = RawParseUtils.formatBase10(b, b.length, 1234);
  24. assertEquals("1234", new String(b, p, b.length - p, "UTF-8"));
  25. p = RawParseUtils.formatBase10(b, b.length, -9876);
  26. assertEquals("-9876", new String(b, p, b.length - p, "UTF-8"));
  27. p = RawParseUtils.formatBase10(b, b.length, 123456789);
  28. assertEquals("123456789", new String(b, p, b.length - p, "UTF-8"));
  29. }
  30. }