/// <summary> /// Tests if all the possible opcodes (0-65535) have exact one type. /// </summary> /// <param name="formula">The specific formula.</param> private void Test_FormulaChecker(Base_Formula formula) { for (UInt16 opcode = 0; opcode < UInt16.MaxValue; ++opcode) { // assert if both methods are true if (formula.FormulaChecker_JAMC(opcode) && formula.FormulaChecker_JAMCC(opcode)) Assert.Inconclusive("Opcode 0x{0:X4} has more than one type, formula: {1}", opcode, formula.GetType().ToString()); } }
/// <summary> /// Tests if a switch case (JAMCC) belongs to more than one opcodes /// </summary> /// <param name="formula">The specific formula.</param> private void Test_Formula_JAMCC(Base_Formula formula) { // contains all the results List<UInt16> resultList = new List<UInt16>(); for (UInt16 opcode = 0; opcode < UInt16.MaxValue; ++opcode) { // bad type opcode if (!formula.FormulaChecker_JAMCC(opcode)) continue; // calculate the switch case UInt16 switchCase = formula.Formula_JAMCC(opcode); UInt16 alreadyHaveThis = resultList.Find( delegate(UInt16 x) { return x == switchCase; } ); // assert if already contains that switch case Assert.IsNotNull(alreadyHaveThis, "More than one opcode belong to this switch case: 0x{0:X4}, formula: {1}", switchCase, formula.GetType().ToString()); resultList.Add(switchCase); } }