40 lines
1.2 KiB
Java
40 lines
1.2 KiB
Java
package de.vanitasvitae.imi.codes;
|
|
|
|
import static junit.framework.TestCase.assertEquals;
|
|
import static junit.framework.TestCase.assertTrue;
|
|
|
|
import java.util.regex.Pattern;
|
|
|
|
import org.junit.Test;
|
|
|
|
/**
|
|
* Test functionality of the {@link SampleType} enum.
|
|
*/
|
|
public class SampleTypeTest {
|
|
|
|
private static final Pattern SAMPLE_TYPE_VALUE_PATTERN = Pattern.compile(InputValidator.ALPHABET);
|
|
|
|
/**
|
|
* Test, whether all {@link SampleType} names are of length 1 and from the alphabet [a-zA-Z0-9].
|
|
*/
|
|
@Test
|
|
public void testSampleTypeNames() {
|
|
for (SampleType t : SampleType.values()) {
|
|
assertTrue("SampleType value names must be one letter from the alphabet [a-zA-Z0-9].",
|
|
SAMPLE_TYPE_VALUE_PATTERN.matcher(t.toString()).matches());
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Test, whether {@link SampleType#getEnum(String)} correctly maps {@link SampleType#name} to the corresponding
|
|
* values.
|
|
*/
|
|
@Test
|
|
public void testGetEnum() {
|
|
for (SampleType t : SampleType.values()) {
|
|
assertEquals("getEnum must return the SampleType, which corresponds to the given name.",
|
|
t, SampleType.getEnum(t.toString()));
|
|
}
|
|
}
|
|
}
|