From e7a6df5a876baa174c37e3ffaa25d814cd416a4c Mon Sep 17 00:00:00 2001 From: Paul Schaub Date: Tue, 24 Jul 2018 14:28:41 +0200 Subject: [PATCH] Improve OpenPgpV4FingerprintTests --- build.gradle | 4 ++-- .../java/org/pgpainless/OpenPgpV4FingerprintTest.java | 10 ++++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/build.gradle b/build.gradle index c6d15747..fcaaaea8 100644 --- a/build.gradle +++ b/build.gradle @@ -50,7 +50,7 @@ allprojects { mavenCentral() } - ext { + project.ext { junitVersion = 4.12 androidBootClasspath = getAndroidRuntimeJar(pgpainlessMinAndroidSdk) rootConfigDir = new File(rootDir, 'config') @@ -67,7 +67,7 @@ allprojects { version = version + '-SNAPSHOT' } - if (!ext.isSnapshot && !'git describe --exact-match HEAD'.execute().text.trim().equals(ext.shortVersion)) { + if (!project.ext.isSnapshot && !'git describe --exact-match HEAD'.execute().text.trim().equals(ext.shortVersion)) { throw new InvalidUserDataException('Untagged version detected! Please tag every release.') } if (!version.endsWith('-SNAPSHOT') && version != 'git tag --points-at HEAD'.execute().text.trim()) { diff --git a/pgpainless-core/src/test/java/org/pgpainless/OpenPgpV4FingerprintTest.java b/pgpainless-core/src/test/java/org/pgpainless/OpenPgpV4FingerprintTest.java index fe9f25de..0886dbf2 100644 --- a/pgpainless-core/src/test/java/org/pgpainless/OpenPgpV4FingerprintTest.java +++ b/pgpainless-core/src/test/java/org/pgpainless/OpenPgpV4FingerprintTest.java @@ -16,6 +16,7 @@ package org.pgpainless; import static junit.framework.TestCase.assertEquals; +import static org.junit.Assert.assertNotEquals; import java.io.IOException; @@ -42,6 +43,11 @@ public class OpenPgpV4FingerprintTest { String fp = "4A4F48414E4E53454E2049532041204E45524421"; OpenPgpV4Fingerprint finger = new OpenPgpV4Fingerprint(fp); assertEquals(fp, finger.toString()); + assertEquals(fp.length(), finger.length()); + for (int i = 0; i < finger.length(); i++) { + assertEquals(fp.charAt(i), finger.charAt(i)); + } + assertEquals("4A4F", finger.subSequence(0, 4)); } @Test @@ -55,6 +61,10 @@ public class OpenPgpV4FingerprintTest { public void equalsOtherFingerprintTest() { OpenPgpV4Fingerprint finger = new OpenPgpV4Fingerprint("5448452043414b452049532041204c4945212121"); assertEquals(finger, new OpenPgpV4Fingerprint("5448452043414B452049532041204C4945212121")); + assertEquals(0, finger.compareTo(new OpenPgpV4Fingerprint("5448452043414B452049532041204C4945212121"))); + assertNotEquals(finger, new OpenPgpV4Fingerprint("0000000000000000000000000000000000000000")); + assertNotEquals(finger, null); + assertNotEquals(finger, new Object()); } @Test