private void PostTests(int ip, IOrganismo org) { Pilha p = org.GetPilha(); int sizeStack = p.Size(); int val; switch (ip) { case 4: //zero c Assert.IsTrue(org.getReg(R_C) == 0); ValidateIP(ip, org.ip, 2); break; case 6: //or c Assert.IsTrue(org.getReg(R_C) == 1); ValidateIP(ip, org.ip, 2); break; case 8: //SHL C Assert.IsTrue(org.getReg(R_C) == 2); ValidateIP(ip, org.ip, 2); break; case 10: //SHL C Assert.IsTrue(org.getReg(R_C) == 4); ValidateIP(ip, org.ip, 2); break; case 12: //ADRB A Assert.IsTrue(org.getReg(R_C) == 4); ValidateIP(ip, org.ip, 2); break; case 18: //SUB A,C,A - pega a posição inicial do programa e coloca em C ValidateIP(ip, org.ip, 4); Assert.IsTrue(org.getReg(R_A) == startP + 0, org.getReg(R_A) + "<>" + startP + 0); break; case 22: //MOV A,B - B = A ValidateIP(ip, org.ip, 3); Assert.IsTrue(org.getReg(R_A) == org.getReg(R_B), org.getReg(R_A) + "<>" + org.getReg(R_B)); break; case 25: //ADRF A ValidateIP(ip, org.ip, 2); Assert.IsTrue(org.getReg(R_A) == startP + 109); break; case 31: //INC A ValidateIP(ip, org.ip, 2); Assert.IsTrue(org.getReg(R_A) == tmp1 + 1); break; case 33: //SUB A,B,C ValidateIP(ip, org.ip, 4); Assert.IsTrue(org.getReg(R_C) == (org.getReg(R_A) - org.getReg(R_B))); Assert.IsTrue(org.getReg(R_C) == ORG_SIZE, org.getReg(R_C) + " <> " + ORG_SIZE); break; case 41: //MAL C,A ValidateIP(ip, org.ip, 3); Assert.IsTrue(org.child != null); Assert.IsTrue(org.getReg(R_C) == ORG_SIZE, org.getReg(R_C) + " <> " + ORG_SIZE); break; case 44: //CALL Assert.IsTrue(sizeStack > 0); Assert.IsTrue(p.GetAtPos(sizeStack - 1) == ip + 1 + startP, p.GetAtPos(sizeStack - 1) + "<>" + ip + 1); Assert.IsTrue(org.ip == 61 + startP); break; case 50: //JMP Assert.IsTrue(org.ip == 41 + startP, org.ip + " <> " + (41 + startP)); break; case 61: //PUSH A ValidateIP(ip, org.ip, 2); val = p.GetAtPos(sizeStack - 1); Assert.IsTrue(val == org.getReg(R_A)); break; case 63: //PUSH B ValidateIP(ip, org.ip, 2); val = p.GetAtPos(sizeStack - 1); Assert.IsTrue(val == org.getReg(R_B)); break; case 65: //PUSH C ValidateIP(ip, org.ip, 2); val = p.GetAtPos(sizeStack - 1); Assert.IsTrue(val == org.getReg(R_C)); break; case 71: //MOVI B,A ValidateIP(ip, org.ip, 3); var mA = cpu.getMemory(org.getReg(R_A)); var mB = cpu.getMemory(org.getReg(R_A)); Assert.IsTrue(mA == mB); break; case 74: //DEC C ValidateIP(ip, org.ip, 2); Assert.IsTrue(org.getReg(R_C) == tmp1 - 1); break; case 76: //IFZ C tmp1 = org.getReg(R_C); if (tmp1 == 0) { ValidateIP(ip, org.ip, 2); } else { //pulou ValidateIP(ip, org.ip, 3); } break; case 78: //JMP Assert.IsTrue(org.ip == 98 + startP, org.ip + " <> " + (98 + startP)); break; case 87: //JMPB --volta pro inicio do loop de cópia Assert.IsTrue(org.ip == 71 + startP, org.ip + " <> " + (71 + startP)); break; } }