예제 #1
0
 protected static IEnumerable <object[]> GetNonDecodedEncodeData(int codeSize)
 {
     foreach (var info in NonDecodedInstructions.GetTests())
     {
         if (codeSize != info.bitness)
         {
             continue;
         }
         ulong rip = 0;
         yield return(new object[] { info.bitness, info.instruction, info.hexBytes, rip });
     }
 }
예제 #2
0
        void Make_sure_all_Code_values_are_formatted()
        {
            int numCodeValues = -1;

            foreach (var f in typeof(Code).GetFields())
            {
                if (f.IsLiteral)
                {
                    int value = (int)f.GetValue(null);
                    Assert.Equal(numCodeValues + 1, value);
                    numCodeValues = value;
                }
            }
            numCodeValues++;
            var tested = new byte[numCodeValues];

            var types = GetType().Assembly.GetTypes().Where(a =>
                                                            a.Namespace == GetType().Namespace&&
                                                            (a.Name.StartsWith("InstructionInfos16_") || a.Name.StartsWith("InstructionInfos32_") || a.Name.StartsWith("InstructionInfos64_"))).ToArray();

            foreach (var type in types)
            {
                var fieldInfo = type.GetField("AllInfos");
                Assert.NotNull(fieldInfo);
                var infos = fieldInfo.GetValue(null) as InstructionInfo[];
                Assert.NotNull(infos);
                foreach (var info in infos)
                {
                    tested[(int)info.Code] = 1;
                }
            }
#if !NO_ENCODER
            foreach (var info in NonDecodedInstructions.GetTests())
            {
                tested[(int)info.instruction.Code] = 1;
            }
#endif

            var sb        = new StringBuilder();
            int missing   = 0;
            var codeNames = Enum.GetNames(typeof(Code));
            for (int i = 0; i < tested.Length; i++)
            {
                if (tested[i] != 1)
                {
                    sb.Append(codeNames[i] + " ");
                    missing++;
                }
            }
            Assert.Equal("Fmt: 0 ins ", $"Fmt: {missing} ins " + sb.ToString());
        }