mirror of
https://github.com/pgpainless/pgpainless.git
synced 2025-09-14 20:59:39 +02:00
Annotate fromId(code) methods with Nullable and add Nonnull requireFromId(code) methods
This commit is contained in:
parent
16b0d0730e
commit
e8b03834cb
24 changed files with 278 additions and 42 deletions
|
@ -6,20 +6,37 @@ package org.pgpainless.algorithm;
|
|||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.NoSuchElementException;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
|
||||
public class FeatureTest {
|
||||
|
||||
@Test
|
||||
public void testAll() {
|
||||
for (Feature feature : Feature.values()) {
|
||||
assertEquals(feature, Feature.fromId(feature.getFeatureId()));
|
||||
assertEquals(feature, Feature.requireFromId(feature.getFeatureId()));
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testModificationDetection() {
|
||||
Feature modificationDetection = Feature.MODIFICATION_DETECTION;
|
||||
assertEquals(0x01, modificationDetection.getFeatureId());
|
||||
assertEquals(modificationDetection, Feature.fromId((byte) 0x01));
|
||||
assertEquals(modificationDetection, Feature.requireFromId((byte) 0x01));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFromInvalidIdIsNull() {
|
||||
assertNull(Feature.fromId((byte) 0x99));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRequireFromInvalidThrows() {
|
||||
assertThrows(NoSuchElementException.class, () -> Feature.requireFromId((byte) 0x99));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -64,7 +64,7 @@ public class SignatureStructureTest {
|
|||
|
||||
@Test
|
||||
public void testGetHashAlgorithm() {
|
||||
assertEquals(HashAlgorithm.SHA256, HashAlgorithm.fromId(signature.getHashAlgorithm()));
|
||||
assertEquals(HashAlgorithm.SHA256, HashAlgorithm.requireFromId(signature.getHashAlgorithm()));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue