@Test public void emptyFloatInterval() throws InvalidConstrainingFacetException, InvalidLiteralException, UnrecognizedDatatypeException { final ATermAppl emptyFloatRestriction = restrict(FLOAT, minExclusive(literal(Float.intBitsToFloat(0x00000000))), maxExclusive(literal(Float.intBitsToFloat(0x00000001)))); assertFalse(reasoner.isSatisfiable(Collections.singleton(emptyFloatRestriction))); }
@Test public void floatRestrictionWithSevenValues() throws InvalidConstrainingFacetException, InvalidLiteralException, UnrecognizedDatatypeException { final ATermAppl floatRestrictionWithSevenValues = restrict(FLOAT, minExclusive(literal(Float.intBitsToFloat(0x00000000))), maxExclusive(literal(Float.intBitsToFloat(0x00000008)))); assertTrue(reasoner.isSatisfiable(Collections.singleton(floatRestrictionWithSevenValues))); assertTrue(reasoner.containsAtLeast(7, Collections.singleton(floatRestrictionWithSevenValues))); assertFalse(reasoner.containsAtLeast(8, Collections.singleton(floatRestrictionWithSevenValues))); }
@Test public void floatExclusiveRandom() throws InvalidConstrainingFacetException, InvalidLiteralException, UnrecognizedDatatypeException { final long seed = System.currentTimeMillis(); final Random rand = new Random(seed); try { float high, low; high = rand.nextFloat(); low = rand.nextFloat(); if (low > high) { final float tmp = low; low = high; high = tmp; } final ATermAppl floatExclusiveRandom = restrict(FLOAT, minExclusive(literal(Float.valueOf(low))), maxExclusive(literal(Float.valueOf(high)))); // Both floats are known to be in (0,1) so this will work final int size = Float.floatToIntBits(high) - Float.floatToIntBits(low) - 1; assertTrue(reasoner.isSatisfiable(Collections.singleton(floatExclusiveRandom))); assertTrue(reasoner.containsAtLeast(size, Collections.singleton(floatExclusiveRandom))); assertFalse(reasoner.containsAtLeast(size + 1, Collections.singleton(floatExclusiveRandom))); } catch (final AssertionError e) { System.err.println("Random seed: " + seed); throw e; } }
@Test public void integerExclusiveRandom() throws InvalidConstrainingFacetException, InvalidLiteralException, UnrecognizedDatatypeException { final long seed = System.currentTimeMillis(); final Random rand = new Random(seed); try { int high, low; high = rand.nextInt(); do { low = rand.nextInt(); if (low > high) { final int tmp = low; low = high; high = tmp; } } while (Long.valueOf(high) - Long.valueOf(low) > Integer.MAX_VALUE); final ATermAppl integerExclusiveInterval = restrict(INTEGER, minExclusive(literal(low)), maxExclusive(literal(high))); assertTrue(reasoner.isSatisfiable(Collections.singleton(integerExclusiveInterval))); assertTrue(reasoner.containsAtLeast(high - low - 1, Collections.singleton(integerExclusiveInterval))); assertFalse(reasoner.containsAtLeast(high - low, Collections.singleton(integerExclusiveInterval))); } catch (final AssertionError e) { System.err.println("Random seed: " + seed); throw e; } }
public void integerExclusiveIntervalOverflow() throws InvalidConstrainingFacetException, InvalidLiteralException, UnrecognizedDatatypeException { final ATermAppl integerExclusiveInterval = restrict(INTEGER, minExclusive(literal(Integer.MIN_VALUE)), maxExclusive(literal(Integer.MAX_VALUE))); assertTrue(reasoner.isSatisfiable(Collections.singleton(integerExclusiveInterval))); assertTrue(reasoner.containsAtLeast(Integer.MAX_VALUE, Collections.singleton(integerExclusiveInterval))); }
@Test public void integerTwoValues() throws InvalidConstrainingFacetException, InvalidLiteralException, UnrecognizedDatatypeException { final ATermAppl integerExclusiveInterval = restrict(INTEGER, minExclusive(literal(-1)), maxExclusive(literal(1))); assertTrue(reasoner.isSatisfiable(Collections.singleton(integerExclusiveInterval))); assertTrue(reasoner.containsAtLeast(1, Collections.singleton(integerExclusiveInterval))); assertFalse(reasoner.containsAtLeast(2, Collections.singleton(integerExclusiveInterval))); }
@Test public void floatTwoZeros() throws InvalidConstrainingFacetException, InvalidLiteralException, UnrecognizedDatatypeException { final ATermAppl floatTwoZeros = restrict(FLOAT, minExclusive(literal(-Float.MIN_VALUE)), maxExclusive(literal(Float.MIN_VALUE))); assertTrue(reasoner.isSatisfiable(Collections.singleton(floatTwoZeros))); assertTrue(reasoner.containsAtLeast(2, Collections.singleton(floatTwoZeros))); assertFalse(reasoner.containsAtLeast(3, Collections.singleton(floatTwoZeros))); }
@Test public void emptyIntegerInterval() throws InvalidConstrainingFacetException, InvalidLiteralException, UnrecognizedDatatypeException { final ATermAppl integerExclusiveInterval = restrict(INTEGER, minExclusive(literal(0)), maxExclusive(literal(1))); assertFalse(reasoner.isSatisfiable(Collections.singleton(integerExclusiveInterval))); }
@Test public void integerExclusiveIntervalExtreme() throws InvalidConstrainingFacetException, InvalidLiteralException, UnrecognizedDatatypeException { final ATermAppl integerExclusiveInterval = restrict(INTEGER, minExclusive(literal(0)), maxExclusive(literal(Integer.MAX_VALUE))); assertTrue(reasoner.isSatisfiable(Collections.singleton(integerExclusiveInterval))); assertTrue(reasoner.containsAtLeast(Integer.MAX_VALUE - 1, Collections.singleton(integerExclusiveInterval))); assertFalse(reasoner.containsAtLeast(Integer.MAX_VALUE, Collections.singleton(integerExclusiveInterval))); }
@Test public void floatInterval() throws InvalidConstrainingFacetException, InvalidLiteralException, UnrecognizedDatatypeException { final ATermAppl floatInterval = restrict(FLOAT, minInclusive(literal(1.0f)), maxExclusive(literal(2.0f))); assertFalse(reasoner.isSatisfiable(Collections.singleton(not(floatInterval)), 1.0f)); assertFalse(reasoner.isSatisfiable(Collections.singleton(not(floatInterval)), 1.5f)); assertTrue(reasoner.isSatisfiable(Collections.singleton(not(floatInterval)), 2.0f)); }
@Test public void test370() { // test case for issue #370. dataProperties(_p); individuals(_a); final ATermAppl dt = restrict(Datatypes.DECIMAL, minExclusive(literal("0.99", Datatypes.DECIMAL)), maxExclusive(literal("1.01", Datatypes.DECIMAL))); _kb.addType(_a, min(_p, 3, dt)); assertTrue(_kb.isConsistent()); }
@Test public void test484() { dataProperties(_p); individuals(_a); final ATermAppl dt = restrict(Datatypes.INTEGER, minExclusive(literal(0)), maxExclusive(literal(0))); _kb.addType(_a, some(_p, dt)); assertFalse(_kb.isConsistent()); assertEquals(Clash.ClashType.EMPTY_DATATYPE, _kb.getABox().getLastClash().getType()); }
final ATermAppl def = restrict(Datatypes.FLOAT, minInclusive(literal(lower)), maxExclusive(literal(upper))); _kb.addDatatypeDefinition(dt, def);