예제 #1
0
        public void testEmptyBuilder()
        {
            RefList <global::GitSharp.Core.Ref> list = new RefList <global::GitSharp.Core.Ref> .Builder <global::GitSharp.Core.Ref>().toRefList();

            Assert.AreEqual(0, list.size());
            Assert.IsFalse(list.iterator().hasNext());
            Assert.AreEqual(-1, list.find("a"));
            Assert.AreEqual(-1, list.find("z"));
            Assert.IsFalse(list.contains("a"));
            Assert.IsNull(list.get("a"));
            Assert.IsTrue(list.asList().Count == 0);
            Assert.AreEqual("[]", list.ToString());

            // default array capacity should be 16, with no bounds checking.
            Assert.IsNull(list.get(16 - 1));
            try
            {
                list.get(16);
                Assert.Fail("default RefList should have 16 element array");
            }
            catch (IndexOutOfRangeException)
            {
                // expected
            }
        }
예제 #2
0
        public void testEmpty()
        {
            RefList <global::GitSharp.Core.Ref> list = RefList <global::GitSharp.Core.Ref> .emptyList();

            Assert.AreEqual(0, list.size());
            Assert.IsTrue(list.isEmpty());
            Assert.IsFalse(list.iterator().hasNext());
            Assert.AreEqual(-1, list.find("a"));
            Assert.AreEqual(-1, list.find("z"));
            Assert.IsFalse(list.contains("a"));
            Assert.IsNull(list.get("a"));
            try
            {
                list.get(0);
                Assert.Fail("RefList.emptyList should have 0 element array");
            }
            catch (IndexOutOfRangeException)
            {
                // expected
            }
        }
예제 #3
0
        public void testIterable()
        {
            RefList <global::GitSharp.Core.Ref> list = toList(REF_A, REF_B, REF_c);

            int idx = 0;

            foreach (global::GitSharp.Core.Ref @ref in list)
            {
                Assert.AreSame(list.get(idx++), @ref);
            }
            Assert.AreEqual(3, idx);

            var i = RefList <global::GitSharp.Core.Ref> .emptyList().iterator();

            try
            {
                i.next();
                Assert.Fail("did not throw NoSuchElementException");
            }
            catch (IndexOutOfRangeException)
            {
                // expected
            }

            i = list.iterator();
            Assert.IsTrue(i.hasNext());
            Assert.AreSame(REF_A, i.next());
            try
            {
                i.remove();
                Assert.Fail("did not throw UnsupportedOperationException");
            }
            catch (NotSupportedException)
            {
                // expected
            }
        }
예제 #4
0
        public void testEmptyBuilder()
        {
            RefList<global::GitSharp.Core.Ref> list = new RefList<global::GitSharp.Core.Ref>.Builder<global::GitSharp.Core.Ref>().toRefList();
            Assert.AreEqual(0, list.size());
            Assert.IsFalse(list.iterator().hasNext());
            Assert.AreEqual(-1, list.find("a"));
            Assert.AreEqual(-1, list.find("z"));
            Assert.IsFalse(list.contains("a"));
            Assert.IsNull(list.get("a"));
            Assert.IsTrue(list.asList().Count == 0);
            Assert.AreEqual("[]", list.ToString());

            // default array capacity should be 16, with no bounds checking.
            Assert.IsNull(list.get(16 - 1));
            try
            {
                list.get(16);
                Assert.Fail("default RefList should have 16 element array");
            }
            catch (IndexOutOfRangeException)
            {
                // expected
            }
        }