Exemplo n.º 1
0
        void ToArray_works(Instruction[] instructions, bool addExtraElem)
        {
            var list = new InstructionList(instructions);

            if (addExtraElem)
            {
                var instr = Instruction.Create(Code.Nopw);
                list.Add(instr);
                Array.Resize(ref instructions, instructions.Length + 1);
                instructions[instructions.Length - 1] = instr;
            }
            Assert.Equal(instructions.Length, list.Count);
            Assert.True(instructions.Length <= list.Capacity);
            var array = list.ToArray();

            Assert.Equal(list.Count, array.Length);
            AssertEqual(instructions, array);
        }