private void doTest( Object value1, Object value2, Opcode opcode, String inputType, int cmpValue) { when(itemB.getValue()).thenReturn(value1); when(itemC.getValue()).thenReturn(value2); when(itemB.getType()).thenReturn(inputType); when(itemC.getType()).thenReturn(inputType); when(instruction.getOpcode()).thenReturn(opcode); op = (CmpOp) opFactory.create(instruction, ADDRESS); op.execute(node, mState); verify(mState, times(1)).assignRegister(eq(REGISTER_A), setItem.capture()); assertEquals(cmpValue, setItem.getValue().getValue()); assertEquals(CMP_TYPE, setItem.getValue().getType()); }
@Test public void testArg2IsUnknownReturnsUnknown() { long value1 = 1149239296L; Object value2 = new UnknownValue(); when(itemC.isUnknown()).thenReturn(true); when(itemB.getValue()).thenReturn(value1); when(itemC.getValue()).thenReturn(value2); when(itemB.getType()).thenReturn("J"); when(itemC.getType()).thenReturn("J"); when(instruction.getOpcode()).thenReturn(Opcode.CMP_LONG); op = (CmpOp) opFactory.create(instruction, ADDRESS); op.execute(node, mState); Object cmpValue = new UnknownValue(); verify(mState, times(1)).assignRegister(eq(REGISTER_A), setItem.capture()); assertEquals(cmpValue.getClass(), setItem.getValue().getValue().getClass()); assertEquals(CMP_TYPE, setItem.getValue().getType()); }