use of org.sirix.service.xml.xpath.expr.LiteralExpr in project sirix by sirixdb.
the class ModOpAxisTest method testOperate.
@Test
public final void testOperate() throws SirixException {
AtomicValue item1 = new AtomicValue(3.0, Type.DOUBLE);
AtomicValue item2 = new AtomicValue(2.0, Type.DOUBLE);
AbstractAxis op1 = new LiteralExpr(holder.getReader(), holder.getReader().getItemList().addItem(item1));
AbstractAxis op2 = new LiteralExpr(holder.getReader(), holder.getReader().getItemList().addItem(item2));
AbstractObAxis axis = new ModOpAxis(holder.getReader(), op1, op2);
assertEquals(true, axis.hasNext());
axis.next();
assertThat(1.0, is(Double.parseDouble(holder.getReader().getValue())));
assertEquals(holder.getReader().keyForName("xs:double"), holder.getReader().getTypeKey());
assertEquals(false, axis.hasNext());
}
use of org.sirix.service.xml.xpath.expr.LiteralExpr in project sirix by sirixdb.
the class NodeCompTest method testAtomize.
@Test
public void testAtomize() throws SirixXPathException {
Axis axis = new LiteralExpr(holder.getReader(), -2);
axis.hasNext();
axis.next();
AtomicValue[] value = comparator.atomize(axis);
assertEquals(value.length, 1);
assertEquals(holder.getReader().getNodeKey(), value[0].getNodeKey());
assertEquals("xs:integer", value[0].getType());
try {
axis = new DescendantAxis(holder.getReader());
axis.hasNext();
comparator.atomize(axis);
} catch (SirixXPathException e) {
assertEquals("err:XPTY0004 The type is not appropriate the expression or" + " the typedoes not match a required type as specified by the " + "matching rules.", e.getMessage());
}
}
use of org.sirix.service.xml.xpath.expr.LiteralExpr in project sirix by sirixdb.
the class AbsOpAxisTest method testHasNext.
@Test
public final void testHasNext() throws SirixException {
final AtomicValue item1 = new AtomicValue(1.0, Type.DOUBLE);
final AtomicValue item2 = new AtomicValue(2.0, Type.DOUBLE);
AbstractAxis op1 = new LiteralExpr(holder.getReader(), holder.getReader().getItemList().addItem(item1));
AbstractAxis op2 = new LiteralExpr(holder.getReader(), holder.getReader().getItemList().addItem(item2));
AbstractObAxis axis = new DivOpAxis(holder.getReader(), op1, op2);
assertEquals(true, axis.hasNext());
assertEquals(holder.getReader().keyForName("xs:double"), holder.getReader().getTypeKey());
assertEquals(false, axis.hasNext());
// here both operands are the empty sequence
axis = new DivOpAxis(holder.getReader(), op1, op2);
assertEquals(true, axis.hasNext());
axis.next();
assertThat(Double.NaN, is(Double.parseDouble(holder.getReader().getValue())));
assertEquals(holder.getReader().keyForName("xs:double"), holder.getReader().getTypeKey());
assertEquals(false, axis.hasNext());
}
use of org.sirix.service.xml.xpath.expr.LiteralExpr in project sirix by sirixdb.
the class AddOpAxisTest method testOperate.
@Test
public final void testOperate() throws SirixException {
AtomicValue item1 = new AtomicValue(1.0, Type.DOUBLE);
AtomicValue item2 = new AtomicValue(2.0, Type.DOUBLE);
AbstractAxis op1 = new LiteralExpr(holder.getReader(), holder.getReader().getItemList().addItem(item1));
AbstractAxis op2 = new LiteralExpr(holder.getReader(), holder.getReader().getItemList().addItem(item2));
AbstractObAxis axis = new AddOpAxis(holder.getReader(), op1, op2);
assertEquals(true, axis.hasNext());
axis.next();
assertThat(3.0, is(Double.parseDouble(holder.getReader().getValue())));
assertEquals(holder.getReader().keyForName("xs:double"), holder.getReader().getTypeKey());
assertEquals(false, axis.hasNext());
}
use of org.sirix.service.xml.xpath.expr.LiteralExpr in project sirix by sirixdb.
the class MulOpAxisTest method testOperate.
@Test
public final void testOperate() throws SirixException {
AtomicValue item1 = new AtomicValue(3.0, Type.DOUBLE);
AtomicValue item2 = new AtomicValue(2.0, Type.DOUBLE);
AbstractAxis op1 = new LiteralExpr(holder.getReader(), holder.getReader().getItemList().addItem(item1));
AbstractAxis op2 = new LiteralExpr(holder.getReader(), holder.getReader().getItemList().addItem(item2));
AbstractObAxis axis = new MulOpAxis(holder.getReader(), op1, op2);
assertEquals(true, axis.hasNext());
axis.next();
assertThat(6.0, is(Double.parseDouble(holder.getReader().getValue())));
assertEquals(holder.getReader().keyForName("xs:double"), holder.getReader().getTypeKey());
assertEquals(false, axis.hasNext());
}
Aggregations