/// <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 (JAMC) belongs to more than one opcode.
        /// </summary>
        /// <param name="formula">The specific formula.</param>
        private void Test_Formula_JAMC(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_JAMC(opcode))
                    continue;
                // calculate the switch case
                UInt16 switchCase = formula.Formula_JAMC(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);
            }
        }
Exemplo n.º 3
0
 /// <summary>
 /// Concrete formula registration: add to the formula list.
 /// </summary>
 /// <param name="formula">The formula which should be stored.</param>
 private static void RegisterFormula(Base_Formula formula)
 {
     formulas.Add(formula);
 }