@Test public void testDatasetWithTwoValuesPasses() throws AssertionError { final int minValue = 0; final int maxValue = 1; dataset = datasetCreator.createDataset(DatasetType.BIT); DatasetCreator.fillWithRandomWholeNumbers(dataset, minValue, maxValue); final boolean result = (boolean) ij.op().run(DatasetIsBinary.class, dataset); assertTrue("A Dataset with two distinct values is binary", result); }
@Test public void testInvalidDatasetTypesFail() throws AssertionError { final Stream<DatasetType> allTypes = Arrays.stream(DatasetType.values()); allTypes .filter(t -> t != DatasetType.BIT) .forEach( type -> { dataset = datasetCreator.createDataset(type); final boolean result = (boolean) ij.op().run(DatasetIsBinary.class, dataset); final String typeClassName = dataset.getType().getClass().getName(); assertFalse("A Dataset of type " + typeClassName + " should not be binary", result); }); }
@BeforeClass public static void oneTimeSetup() { datasetCreator.setContext(ij.getContext()); }