@Test public void testEqualForBooleans() { Context c = new Context(); DataFactory factory = new DataFactory(); IVPBoolean a = factory.createIVPBoolean(); IVPBoolean b = factory.createIVPBoolean(); NotEqualTo neq = factory.createNotEqualTo(); neq.setExpressionA(a.getUniqueID()); neq.setExpressionB(b.getUniqueID()); a.setValueType(IVPValue.BOOLEAN_TYPE); b.setValueType(IVPValue.BOOLEAN_TYPE); c.addBoolean(a.getUniqueID(), new Boolean(true)); c.addBoolean(b.getUniqueID(), new Boolean(false)); HashMap map = new HashMap(); map.put(a.getUniqueID(), a); map.put(b.getUniqueID(), b); map.put(neq.getUniqueID(), neq); IVPBoolean result = (IVPBoolean) neq.evaluate(c, map, factory); assertTrue(c.getBoolean(result.getUniqueID())); b.updateValue(c, new Boolean(true)); result = (IVPBoolean) neq.evaluate(c, map, factory); assertFalse(c.getBoolean(result.getUniqueID())); }
@Test public void testEqualForStrings() { Context c = new Context(); DataFactory factory = new DataFactory(); IVPString a = factory.createIVPString(); IVPString b = factory.createIVPString(); NotEqualTo neq = factory.createNotEqualTo(); neq.setExpressionA(a.getUniqueID()); neq.setExpressionB(b.getUniqueID()); a.setValueType(IVPValue.STRING_TYPE); b.setValueType(IVPValue.STRING_TYPE); c.addString(a.getUniqueID(), "hello"); c.addString(b.getUniqueID(), "hello1"); HashMap map = new HashMap(); map.put(a.getUniqueID(), a); map.put(b.getUniqueID(), b); map.put(neq.getUniqueID(), neq); IVPBoolean result = (IVPBoolean) neq.evaluate(c, map, factory); assertTrue(c.getBoolean(result.getUniqueID())); b.updateValue(c, "hello"); result = (IVPBoolean) neq.evaluate(c, map, factory); assertFalse(c.getBoolean(result.getUniqueID())); }
@Test public void testEqualForIntAndDouble() { Context c = new Context(); DataFactory factory = new DataFactory(); IVPNumber a = factory.createIVPNumber(); IVPNumber b = factory.createIVPNumber(); NotEqualTo neq = factory.createNotEqualTo(); neq.setExpressionA(a.getUniqueID()); neq.setExpressionB(b.getUniqueID()); a.setValueType(IVPValue.DOUBLE_TYPE); b.setValueType(IVPValue.INTEGER_TYPE); c.addDouble(a.getUniqueID(), 3.0001); c.addInt(b.getUniqueID(), 3); HashMap map = new HashMap(); map.put(a.getUniqueID(), a); map.put(b.getUniqueID(), b); map.put(neq.getUniqueID(), neq); IVPBoolean result = (IVPBoolean) neq.evaluate(c, map, factory); assertTrue(c.getBoolean(result.getUniqueID())); }