示例#1
0
        public void Add()
        {
            using (var arr = new SwiftArray <uint> ()) {
                Assert.AreEqual(0, arr.Count, "Count 1");
                arr.Add(20);
                Assert.GreaterOrEqual(arr.Capacity, 1, "Capacity 1");
                Assert.AreEqual(1, arr.Count, "Count 2");
                Assert.AreEqual(20, arr [0], "Item 1");

                arr.Dispose();
                Assert.Throws <ObjectDisposedException> (() => arr.Add(3), "Add ODE");
            }
        }
示例#2
0
 public void DefaultConstructor()
 {
     using (var arr = new SwiftArray <int> ()) {
         arr.Add(1);
         Assert.AreEqual(1, arr.Count, "Count");
     }
 }
示例#3
0
        public void Constructor_Capacity()
        {
            using (var arr = new SwiftArray <byte> ((nint)20)) {
                Assert.AreEqual(0, arr.Count, "Count 1");
                Assert.GreaterOrEqual(arr.Capacity, 20, "Capacity 1");
                arr.Add(10);
                Assert.AreEqual(1, arr.Count, "Count 2");
                Assert.GreaterOrEqual(arr.Capacity, 20, "Capacity 2");
            }

            Assert.Throws <ArgumentOutOfRangeException> (() => new SwiftArray <long> (-1));
        }
示例#4
0
        public void Clear()
        {
            using (var arr = new SwiftArray <float> (1, 2, 3, 4, 5, 6, 7, 8, 9)) {
                arr.Clear();
                Assert.AreEqual(0, arr.Count, "Count 1");
                arr.Add(1);
                Assert.AreEqual(1, arr.Count, "Count 2");
                arr.Clear();
                Assert.AreEqual(0, arr.Count, "Count 3");

                arr.Dispose();
                Assert.Throws <ObjectDisposedException> (() => arr.Clear(), "Clear ODE");
            }
        }
示例#5
0
        public void Contains()
        {
            using (var arr = new SwiftArray <ulong> (1, 2, 3, 4, 5, 6, 7, 8, 9)) {
                Assert.IsTrue(arr.Contains(8), "Contains 1");
                Assert.IsFalse(arr.Contains(10), "Contains 2");
                arr.Clear();
                Assert.IsFalse(arr.Contains(8), "Contains 3");
                Assert.IsFalse(arr.Contains(10), "Contains 4");
                arr.Add(10);
                Assert.IsFalse(arr.Contains(8), "Contains 5");
                Assert.IsTrue(arr.Contains(10), "Contains 6");

                arr.Dispose();
                Assert.Throws <ObjectDisposedException> (() => arr.Contains(3), "Contains ODE");
            }
        }