diff --git a/Iced.UnitTests/Intel/InstructionTests/InstructionListTests.cs b/Iced.UnitTests/Intel/InstructionTests/InstructionListTests.cs index 39a1ab7d9..f127e1aed 100644 --- a/Iced.UnitTests/Intel/InstructionTests/InstructionListTests.cs +++ b/Iced.UnitTests/Intel/InstructionTests/InstructionListTests.cs @@ -23,6 +23,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #if !NO_ENCODER using System; +using System.Collections; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Linq; @@ -400,6 +401,8 @@ namespace Iced.UnitTests.Intel.InstructionTests { enum InsertRangeKind { IEnumerable, + Array, + IList, ReadOnlyList, InstructionList, @@ -456,9 +459,17 @@ namespace Iced.UnitTests.Intel.InstructionTests { // IEnumerable code path return array.AsEnumerable(); + case InsertRangeKind.Array: + // Instruction[] code path (none at the moment) + return array; + + case InsertRangeKind.IList: + // IList code path + return new IListImpl(array); + case InsertRangeKind.ReadOnlyList: // IReadOnlyList code path - return new ReadOnlyCollection(array); + return new IReadOnlyListImpl(array); case InsertRangeKind.InstructionList: // InstructionList code path @@ -470,6 +481,36 @@ namespace Iced.UnitTests.Intel.InstructionTests { } } + sealed class IListImpl : IList { + readonly T[] array; + public IListImpl(T[] array) => this.array = array; + public int Count => array.Length; + public T this[int index] { + get => array[index]; + set => throw new NotImplementedException(); + } + public bool IsReadOnly => throw new NotImplementedException(); + public int IndexOf(T item) => throw new NotImplementedException(); + public void Insert(int index, T item) => throw new NotImplementedException(); + public void RemoveAt(int index) => throw new NotImplementedException(); + public void Add(T item) => throw new NotImplementedException(); + public void Clear() => throw new NotImplementedException(); + public bool Contains(T item) => throw new NotImplementedException(); + public bool Remove(T item) => throw new NotImplementedException(); + public void CopyTo(T[] array, int arrayIndex) => throw new NotImplementedException(); + public IEnumerator GetEnumerator() => throw new NotImplementedException(); + IEnumerator IEnumerable.GetEnumerator() => throw new NotImplementedException(); + } + + sealed class IReadOnlyListImpl : IReadOnlyList { + readonly T[] array; + public IReadOnlyListImpl(T[] array) => this.array = array; + public int Count => array.Length; + public T this[int index] => array[index]; + public IEnumerator GetEnumerator() => throw new NotImplementedException(); + IEnumerator IEnumerable.GetEnumerator() => throw new NotImplementedException(); + } + [Theory] [MemberData(nameof(AddRange_works_Data))] void AddRange_works(InstructionList list, IEnumerable inserted, Instruction[] expected) {