summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.test/tst/org
diff options
context:
space:
mode:
authorMichael Dardis <git@md-5.net>2020-02-14 12:09:37 +1100
committerMatthias Sohn <matthias.sohn@sap.com>2020-02-22 00:12:20 +0100
commit67b9effc655d8ba75acb7db5e49687224d1c7a6a (patch)
treef8ea071da67ba38c900606a530361117ddd15b97 /org.eclipse.jgit.test/tst/org
parent40555223594005481cba95d09b32c4f6bb5dcff3 (diff)
downloadjgit-67b9effc655d8ba75acb7db5e49687224d1c7a6a.tar.gz
jgit-67b9effc655d8ba75acb7db5e49687224d1c7a6a.zip
Remove use of org.bouncycastle.util.encoders.Hex
Change-Id: I5c1ed0397ef99eb5d4f120da331b66c2d0f1707a Signed-off-by: Michael Dardis <git@md-5.net> Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Diffstat (limited to 'org.eclipse.jgit.test/tst/org')
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/util/HexTest.java49
1 files changed, 49 insertions, 0 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/HexTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/HexTest.java
new file mode 100644
index 0000000000..32af07f259
--- /dev/null
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/HexTest.java
@@ -0,0 +1,49 @@
+/*
+ * Copyright (C) 2010, Google Inc.
+ * Copyright (C) 2020 Michael Dardis and others
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Distribution License v. 1.0 which is available at
+ * https://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+package org.eclipse.jgit.util;
+
+import static org.eclipse.jgit.util.Hex.decode;
+import static org.eclipse.jgit.util.Hex.toHexString;
+import static org.junit.Assert.assertEquals;
+
+import org.eclipse.jgit.junit.JGitTestUtil;
+import org.eclipse.jgit.lib.Constants;
+import org.junit.Test;
+
+public class HexTest {
+ @Test
+ public void testEncode() {
+ assertEquals("68690a", toHexString(b("hi\n")));
+ assertEquals("0001020d0a0971", toHexString(b("\0\1\2\r\n\tq")));
+ }
+
+ @Test
+ public void testDecode() {
+ JGitTestUtil.assertEquals(b("hi\n"), decode("68690a"));
+ JGitTestUtil.assertEquals(b("\0\1\2\r\n\tq"), decode("0001020d0a0971"));
+ JGitTestUtil.assertEquals(b("\u000EB"), decode("0E42"));
+ }
+
+ @Test
+ public void testEncodeMatchesDecode() {
+ String[] testStrings = { "", "cow", "a", "a secret string",
+ "\0\1\2\r\n\t" };
+ for (String e : testStrings) {
+ JGitTestUtil.assertEquals(b(e), decode(toHexString(b(e))));
+ }
+ }
+
+ private static byte[] b(String str) {
+ return Constants.encode(str);
+ }
+
+}