Search in sources :

Example 16 with org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Integer

use of org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Integer in project packages-jpl by SWI-Prolog.

the class Tests method testWouter1.

@Test
public void testWouter1() {
    // Wouter says this fails under OS X Mavericks
    // 10.9 x86-64
    // too big for an int
    long n = 7381783232223l;
    Compound term = new Compound("is", new Term[] { new Variable("X"), new Integer(n) });
    Map<String, Term>[] solutions = new Query(term).allSolutions();
    assertEquals(1, solutions.length);
    Map<String, Term> solution = solutions[0];
    assertTrue(solution.containsKey("X"));
    Object result = solution.get("X");
    assertTrue(result instanceof Integer);
    assertEquals(n, ((Integer) result).longValue());
}
Also used : Integer(org.jpl7.Integer) Map(java.util.Map) Test(org.junit.Test)

Example 17 with org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Integer

use of org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Integer in project packages-jpl by SWI-Prolog.

the class Test_Integer method testBigInteger2.

@Test
public void testBigInteger2() {
    BigInteger b = new BigInteger("12345678901234567890123456789");
    // too big for a long
    Term i = new Integer(b);
    Term g = new Compound("is", new Term[] { new Variable("X"), i });
    Term x = Query.oneSolution(g).get("X");
    assertTrue("X is an org.jpl7.Integer", x.isInteger());
    assertTrue("X is a big org.jpl7.Integer", x.isBigInteger());
    assertEquals("X's value is as expected", x.bigValue(), b);
}
Also used : Integer(org.jpl7.Integer) BigInteger(java.math.BigInteger) BigInteger(java.math.BigInteger) Test(org.junit.Test)

Example 18 with org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Integer

use of org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Integer in project packages-jpl by SWI-Prolog.

the class Test_Integer method testIntegerFromByte1.

// /////////////////////////////////////////////////////////////////////////////
// SUPPORTING CODE
// /////////////////////////////////////////////////////////////////////////////
// /////////////////////////////////////////////////////////////////////////////
// TESTS
// /////////////////////////////////////////////////////////////////////////////
@Test
public void testIntegerFromByte1() {
    // -128..127
    byte b = (byte) 127;
    Integer i = new Integer(b);
    assertEquals(i.intValue(), b);
}
Also used : Integer(org.jpl7.Integer) BigInteger(java.math.BigInteger) Test(org.junit.Test)

Example 19 with org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Integer

use of org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Integer in project packages-jpl by SWI-Prolog.

the class Test_JRef method testJRef2.

@Test
public void testJRef2() {
    int i = 76543;
    Integer I = new Integer(i);
    Query q = new Query("jpl_call(?,intValue,[],I2)", JPL.newJRef(I));
    Term I2 = q.oneSolution().get("I2");
    assertTrue(I2.isInteger() && I2.intValue() == i);
}
Also used : Integer(org.jpl7.Integer) Test(org.junit.Test)

Example 20 with org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Integer

use of org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Integer in project packages-jpl by SWI-Prolog.

the class Test_JRef method testJRef1.

// /////////////////////////////////////////////////////////////////////////////
// SUPPORTING CODE
// /////////////////////////////////////////////////////////////////////////////
// /////////////////////////////////////////////////////////////////////////////
// TESTS
// /////////////////////////////////////////////////////////////////////////////
@Test
public void testJRef1() {
    int i = 76543;
    Integer I = new Integer(i);
    Query q = new Query("jpl_call(?,intValue,[],I2)", new Term[] { JPL.newJRef(I) });
    Term I2 = q.oneSolution().get("I2");
    assertTrue(I2.isInteger() && I2.intValue() == i);
}
Also used : Integer(org.jpl7.Integer) Test(org.junit.Test)

Aggregations

Integer (org.jpl7.Integer)19 INTEGER (org.mozilla.jss.asn1.INTEGER)15 BigInteger (java.math.BigInteger)11 Test (org.junit.Test)10 org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Integer (org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Integer)9 org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Column (org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Column)8 org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Bigint (org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Bigint)7 org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Boolean (org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Boolean)7 org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Char (org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Char)7 org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Decimal (org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Decimal)7 org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Double (org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Double)7 org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Float (org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Float)7 org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Smallint (org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Smallint)7 Map (java.util.Map)6 org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Binary (org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Binary)6 org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Blob (org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Blob)6 org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Clob (org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Clob)6 org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Date (org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Date)6 org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Datetime (org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Datetime)6 org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Time (org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Time)6