From 6913aa3d6dce6566715c12ffdca4f7863691ba7d Mon Sep 17 00:00:00 2001 From: Paul Schaub Date: Fri, 25 Nov 2022 15:41:56 +0100 Subject: [PATCH] Add more tests for RevocationState --- .../pgpainless/algorithm/RevocationStateTest.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/pgpainless-core/src/test/java/org/pgpainless/algorithm/RevocationStateTest.java b/pgpainless-core/src/test/java/org/pgpainless/algorithm/RevocationStateTest.java index c1e45413..e23d92d3 100644 --- a/pgpainless-core/src/test/java/org/pgpainless/algorithm/RevocationStateTest.java +++ b/pgpainless-core/src/test/java/org/pgpainless/algorithm/RevocationStateTest.java @@ -72,6 +72,8 @@ public class RevocationStateTest { Date now = new Date(); assertEquals(RevocationState.softRevoked(now), RevocationState.softRevoked(now)); + assertEquals(1, RevocationState.softRevoked(now).compareTo(RevocationState.notRevoked())); + assertEquals(0, RevocationState.notRevoked().compareTo(RevocationState.notRevoked())); assertEquals(0, RevocationState.hardRevoked().compareTo(RevocationState.hardRevoked())); assertTrue(RevocationState.hardRevoked().compareTo(RevocationState.notRevoked()) > 0); @@ -93,4 +95,15 @@ public class RevocationStateTest { assertEquals(states, Arrays.asList(not, not2, laterSoft, earlySoft, hard)); } + + @SuppressWarnings({"SimplifiableAssertion", "ConstantConditions", "EqualsWithItself", "EqualsBetweenInconvertibleTypes"}) + @Test + public void equalsTest() { + RevocationState rev = RevocationState.hardRevoked(); + assertFalse(rev.equals(null)); + assertTrue(rev.equals(rev)); + assertFalse(rev.equals("not a revocation")); + RevocationState other = RevocationState.notRevoked(); + assertFalse(rev.equals(other)); + } }