@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 validLiteralRestrictedDatatype() { dataProperties(_p); individuals(_a); final ATermAppl uri = term("http//example.com/datatype"); _kb.addRange(_p, INTEGER); _kb.addDatatypeDefinition(uri, restrict(INTEGER, minExclusive(literal(0)))); _kb.addPropertyValue(_p, _a, literal("1", uri)); assertTrue(_kb.isConsistent()); }
@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 invalidLiteralRestrictedDatatype() { dataProperties(_p); individuals(_a); final ATermAppl uri = term("http//example.com/datatype"); _kb.addRange(_p, INTEGER); _kb.addDatatypeDefinition(uri, restrict(INTEGER, minExclusive(literal(0)))); _kb.addPropertyValue(_p, _a, literal("-1", uri)); assertFalse(_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()); }
@Test public void test375() { // test case for issue #375. classes(_A, _B, _C); dataProperties(_p); final ATermAppl dt = restrict(Datatypes.INTEGER, minExclusive(literal(1))); _kb.addRange(_p, XSDInteger.getInstance().getName()); _kb.addSubClass(_A, _C); _kb.addEquivalentClass(_A, some(_p, dt)); _kb.addSubClass(_B, _C); _kb.addEquivalentClass(_B, hasValue(_p, literal(2))); assertTrue(_kb.isConsistent()); assertSubClass(_kb, _B, _A); _kb.classify(); _kb.printClassTree(); assertSubClass(_kb, _B, _A); }