Examples of BinaryNode


Examples of com.fasterxml.jackson.databind.node.BinaryNode

    }

    public void testBinaryNode() throws Exception
    {
        byte[] inputBinary = new byte[] { 0, -5 };
        BinaryNode n = new BinaryNode(inputBinary);
        JsonParser jp = n.traverse();

        assertNull(jp.getCurrentToken());
        // exposed as POJO... not as VALUE_STRING
        assertToken(JsonToken.VALUE_EMBEDDED_OBJECT, jp.nextToken());
        byte[] data = jp.getBinaryValue();
View Full Code Here

Examples of org.jamesii.core.math.parsetree.BinaryNode

    return new MinusNode(left, right);
  }

  @Override
  public void testCalc() {
    BinaryNode node = new MinusNode(new ValueNode<>(2.), new ValueNode<>(1.));
    ValueNode<Double> res = node.calc(null);
    assertTrue(res.getValue().compareTo(1.) == 0);

    node = new MinusNode(new ValueNode<>(2), new ValueNode<>(1));
    ValueNode<Integer> res2 = node.calc(null);
    assertTrue(res2.getValue().compareTo(1) == 0);

    node = getInstance(new ValueNode<>(2), new ValueNode<>(3.));
    ValueNode<Double> res3 = node.calc(null);
    assertTrue(res3.getValue().compareTo(-1.) == 0);

    node =
        getInstance(getInstance(new ValueNode<>(1), new ValueNode<>(3.)),
            getInstance(new ValueNode<>(2), new ValueNode<>(3.)));
    ValueNode<Double> res4 = node.calc(null);
    assertTrue(res4.getValue().compareTo(-1.) == 0);

  }
View Full Code Here

Examples of org.jamesii.core.math.parsetree.BinaryNode

    return new IsGreaterOrEqualNode(left, right);
  }

  @Override
  public void testCalc() {
    BinaryNode b = getInstance(new ValueNode<>(0), new ValueNode<>(1));
    ValueNode<Boolean> result = b.calc(null);
    assertTrue(!result.getValue());

    b = getInstance(new ValueNode<>(5), new ValueNode<>(1));
    result = b.calc(null);
    assertTrue(result.getValue());

    b = getInstance(new ValueNode<>(5), new ValueNode<>(5));
    result = b.calc(null);
    assertTrue(result.getValue());

    b = getInstance(new ValueNode<>(2.), new ValueNode<>(7.));
    result = b.calc(null);
    assertTrue(!result.getValue());

    b = getInstance(new ValueNode<>(42.), new ValueNode<>(3.5));
    result = b.calc(null);
    assertTrue(result.getValue());

    // check sub tree handling
    b =
        getInstance(new AddNode(new ValueNode<>(5), new ValueNode<>(6)),
            new ValueNode<>(1));
    result = b.calc(null);
    assertTrue(result.getValue());

    b =
        getInstance(new ValueNode<>(1), new AddNode(new ValueNode<>(5),
            new ValueNode<>(6)));
    result = b.calc(null);
    assertTrue(!result.getValue());

    b =
        getInstance(new AddNode(new ValueNode<>(1), new ValueNode<>(1)),
            new AddNode(new ValueNode<>(5), new ValueNode<>(6)));
    result = b.calc(null);
    assertTrue(!result.getValue());
  }
View Full Code Here

Examples of org.jamesii.core.math.parsetree.BinaryNode

    return new AndNode(left, right);
  }

  @Override
  public void testCalc() {
    BinaryNode b = getInstance(new ValueNode<>(true), new ValueNode<>(false));
    ValueNode<Boolean> result = b.calc(null);
    assertTrue(!result.getValue());

    b = getInstance(new ValueNode<>(true), new ValueNode<>(true));
    result = b.calc(null);
    assertTrue(result.getValue());

    b = getInstance(new ValueNode<>(false), new ValueNode<>(true));
    result = b.calc(null);
    assertTrue(!result.getValue());

    b = getInstance(new ValueNode<>(false), new ValueNode<>(false));
    result = b.calc(null);
    assertTrue(!result.getValue());

    // check sub tree handling
    b =
        getInstance(new OrNode(new ValueNode<>(true), new ValueNode<>(true)),
            new ValueNode<>(false));
    result = b.calc(null);
    assertTrue(!result.getValue());

    b =
        getInstance(new ValueNode<>(false), new OrNode(new ValueNode<>(true),
            new ValueNode<>(false)));
    result = b.calc(null);
    assertTrue(!result.getValue());

    b =
        getInstance(new OrNode(new ValueNode<>(false), new ValueNode<>(true)),
            new AndNode(new ValueNode<>(true), new ValueNode<>(true)));
    result = b.calc(null);
    assertTrue(result.getValue());
  }
View Full Code Here

Examples of org.jamesii.core.math.parsetree.BinaryNode

    return new DivNode(left, right);
  }

  @Override
  public void testCalc() {
    BinaryNode node = getInstance(new ValueNode<>(2.), new ValueNode<>(1.));
    ValueNode<Double> res = node.calc(null);
    assertTrue(res.getValue().compareTo(2.) == 0);

    node = getInstance(new ValueNode<>(2), new ValueNode<>(1));
    ValueNode<Integer> res2 = node.calc(null);
    assertTrue(res2.getValue().compareTo(2) == 0);

    node = getInstance(new ValueNode<>(2), new ValueNode<>(4));
    res2 = node.calc(null);
    assertTrue(res2.getValue().compareTo(0) == 0);

    node = getInstance(new ValueNode<>(2), new ValueNode<>(3.));
    ValueNode<Double> res3 = node.calc(null);
    assertTrue(res3.getValue().compareTo(2. / 3.) == 0);

    node =
        getInstance(getInstance(new ValueNode<>(1), new ValueNode<>(3.)),
            getInstance(new ValueNode<>(2), new ValueNode<>(3.)));
    ValueNode<Double> res4 = node.calc(null);
    assertTrue(res4.getValue().compareTo((1. / 3.) / (2. / 3.)) == 0);

  }
View Full Code Here

Examples of org.jamesii.core.math.parsetree.BinaryNode

    return new IsNotEqualNode(left, right);
  }

  @Override
  public void testCalc() {
    BinaryNode b = getInstance(new ValueNode<>(0), new ValueNode<>(1));
    ValueNode<Boolean> result = b.calc(null);
    assertTrue(result.getValue());

    b = getInstance(new ValueNode<>(5), new ValueNode<>(1));
    result = b.calc(null);
    assertTrue(result.getValue());

    b = getInstance(new ValueNode<>(5), new ValueNode<>(5));
    result = b.calc(null);
    assertTrue(!result.getValue());

    b = getInstance(new ValueNode<>(2.), new ValueNode<>(7.));
    result = b.calc(null);
    assertTrue(result.getValue());

    b = getInstance(new ValueNode<>(42.), new ValueNode<>(3.5));
    result = b.calc(null);
    assertTrue(result.getValue());

    // check sub tree handling
    b =
        getInstance(new AddNode(new ValueNode<>(5), new ValueNode<>(6)),
            new ValueNode<>(1));
    result = b.calc(null);
    assertTrue(result.getValue());

    b =
        getInstance(new ValueNode<>(1), new AddNode(new ValueNode<>(5),
            new ValueNode<>(6)));
    result = b.calc(null);
    assertTrue(result.getValue());

    b =
        getInstance(new AddNode(new ValueNode<>(1), new ValueNode<>(1)),
            new AddNode(new ValueNode<>(5), new ValueNode<>(6)));
    result = b.calc(null);
    assertTrue(result.getValue());

    b =
        getInstance(new AddNode(new ValueNode<>(1), new ValueNode<>(1)),
            new AddNode(new ValueNode<>(1), new ValueNode<>(1)));
    result = b.calc(null);
    assertTrue(!result.getValue());
  }
View Full Code Here

Examples of org.jamesii.core.math.parsetree.BinaryNode

    return new IsLowerNode(left, right);
  }

  @Override
  public void testCalc() {
    BinaryNode b = getInstance(new ValueNode<>(0), new ValueNode<>(1));
    ValueNode<Boolean> result = b.calc(null);
    assertTrue(result.getValue());

    b = getInstance(new ValueNode<>(5), new ValueNode<>(1));
    result = b.calc(null);
    assertTrue(!result.getValue());

    b = getInstance(new ValueNode<>(5), new ValueNode<>(5));
    result = b.calc(null);
    assertTrue(!result.getValue());

    b = getInstance(new ValueNode<>(2.), new ValueNode<>(7.));
    result = b.calc(null);
    assertTrue(result.getValue());

    b = getInstance(new ValueNode<>(42.), new ValueNode<>(3.5));
    result = b.calc(null);
    assertTrue(!result.getValue());

    // check sub tree handling
    b =
        getInstance(new AddNode(new ValueNode<>(5), new ValueNode<>(6)),
            new ValueNode<>(1));
    result = b.calc(null);
    assertTrue(!result.getValue());

    b =
        getInstance(new ValueNode<>(1), new AddNode(new ValueNode<>(5),
            new ValueNode<>(6)));
    result = b.calc(null);
    assertTrue(result.getValue());

    b =
        getInstance(new AddNode(new ValueNode<>(1), new ValueNode<>(1)),
            new AddNode(new ValueNode<>(5), new ValueNode<>(6)));
    result = b.calc(null);
    assertTrue(result.getValue());
  }
View Full Code Here

Examples of org.jamesii.core.math.parsetree.BinaryNode

    return new ModNode(left, right);
  }

  @Override
  public void testCalc() {
    BinaryNode node = getInstance(new ValueNode<>(2), new ValueNode<>(1));
    ValueNode<Integer> res = node.calc(null);
    assertTrue(res.getValue().compareTo(0) == 0);

    node = getInstance(new ValueNode<>(3), new ValueNode<>(2));
    res = node.calc(null);
    assertTrue(res.getValue().compareTo(1) == 0);

  }
View Full Code Here

Examples of org.jamesii.core.math.parsetree.BinaryNode

   * Test get right.
   */
  public void testGetRight() {
    ValueNode<Integer> a = new ValueNode<>(2);
    ValueNode<Integer> b = new ValueNode<>(4);
    BinaryNode testNode = getInstance(a, b);
    assertTrue(testNode.getRight() == b);
  }
View Full Code Here

Examples of org.jamesii.core.math.parsetree.BinaryNode

   * Test get left.
   */
  public void testGetLeft() {
    ValueNode<Integer> a = new ValueNode<>(2);
    ValueNode<Integer> b = new ValueNode<>(4);
    BinaryNode testNode = getInstance(a, b);
    assertTrue(testNode.getLeft() == a);
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.