Exemple #1
0
        public virtual void TestFillTo0()
        {
            IntList i = new IntList();

            i.FillTo(0, int.MinValue);
            NUnit.Framework.Assert.AreEqual(0, i.Size());
        }
Exemple #2
0
        public virtual void TestAdd_ZeroCapacity()
        {
            IntList i = new IntList(0);

            NUnit.Framework.Assert.AreEqual(0, i.Size());
            i.Add(1);
            NUnit.Framework.Assert.AreEqual(1, i.Get(0));
        }
        public virtual void TestOneBlankLine()
        {
            IntList map = RawParseUtils.LineMap(new byte[] { (byte)('\n') }, 0, 1);

            NUnit.Framework.Assert.AreEqual(3, map.Size());
            NUnit.Framework.Assert.AreEqual(int.MinValue, map.Get(0));
            NUnit.Framework.Assert.AreEqual(0, map.Get(1));
            NUnit.Framework.Assert.AreEqual(1, map.Get(2));
        }
        public virtual void TestEmpty()
        {
            IntList map = RawParseUtils.LineMap(new byte[] {  }, 0, 0);

            NUnit.Framework.Assert.IsNotNull(map);
            NUnit.Framework.Assert.AreEqual(2, map.Size());
            NUnit.Framework.Assert.AreEqual(int.MinValue, map.Get(0));
            NUnit.Framework.Assert.AreEqual(0, map.Get(1));
        }
Exemple #5
0
        public virtual void TestFillTo100()
        {
            IntList i = new IntList();

            i.FillTo(100, int.MinValue);
            NUnit.Framework.Assert.AreEqual(100, i.Size());
            i.Add(3);
            NUnit.Framework.Assert.AreEqual(int.MinValue, i.Get(99));
            NUnit.Framework.Assert.AreEqual(3, i.Get(100));
        }
        public virtual void TestTwoLineNoLF()
        {
            byte[]  buf = Sharpen.Runtime.GetBytesForString("foo\nbar", "ISO-8859-1");
            IntList map = RawParseUtils.LineMap(buf, 0, buf.Length);

            NUnit.Framework.Assert.AreEqual(4, map.Size());
            NUnit.Framework.Assert.AreEqual(int.MinValue, map.Get(0));
            NUnit.Framework.Assert.AreEqual(0, map.Get(1));
            NUnit.Framework.Assert.AreEqual(4, map.Get(2));
            NUnit.Framework.Assert.AreEqual(buf.Length, map.Get(3));
        }
Exemple #7
0
        public virtual void TestClear()
        {
            IntList i = new IntList();
            int     n = 5;

            for (int v = 0; v < n; v++)
            {
                i.Add(10 + v);
            }
            NUnit.Framework.Assert.AreEqual(n, i.Size());
            i.Clear();
            NUnit.Framework.Assert.AreEqual(0, i.Size());
            try
            {
                i.Get(0);
                NUnit.Framework.Assert.Fail("Accepted 0 index on empty list");
            }
            catch (IndexOutOfRangeException)
            {
                NUnit.Framework.Assert.IsTrue(true);
            }
        }
Exemple #8
0
        public virtual void TestSet()
        {
            IntList i = new IntList();

            i.Add(1);
            NUnit.Framework.Assert.AreEqual(1, i.Size());
            NUnit.Framework.Assert.AreEqual(1, i.Get(0));
            i.Set(0, 5);
            NUnit.Framework.Assert.AreEqual(5, i.Get(0));
            try
            {
                i.Set(5, 5);
                NUnit.Framework.Assert.Fail("accepted set of 5 beyond end of list");
            }
            catch (IndexOutOfRangeException)
            {
                NUnit.Framework.Assert.IsTrue(true);
            }
            i.Set(1, 2);
            NUnit.Framework.Assert.AreEqual(2, i.Size());
            NUnit.Framework.Assert.AreEqual(2, i.Get(1));
        }
Exemple #9
0
		public virtual void TestEmpty_SpecificCapacity()
		{
			IntList i = new IntList(5);
			NUnit.Framework.Assert.AreEqual(0, i.Size());
			try
			{
				i.Get(0);
				NUnit.Framework.Assert.Fail("Accepted 0 index on empty list");
			}
			catch (IndexOutOfRangeException)
			{
				NUnit.Framework.Assert.IsTrue(true);
			}
		}
Exemple #10
0
        public virtual void TestEmpty_SpecificCapacity()
        {
            IntList i = new IntList(5);

            NUnit.Framework.Assert.AreEqual(0, i.Size());
            try
            {
                i.Get(0);
                NUnit.Framework.Assert.Fail("Accepted 0 index on empty list");
            }
            catch (IndexOutOfRangeException)
            {
                NUnit.Framework.Assert.IsTrue(true);
            }
        }
Exemple #11
0
        public virtual void TestAdd_SmallGroup()
        {
            IntList i = new IntList();
            int     n = 5;

            for (int v = 0; v < n; v++)
            {
                i.Add(10 + v);
            }
            NUnit.Framework.Assert.AreEqual(n, i.Size());
            for (int v_1 = 0; v_1 < n; v_1++)
            {
                NUnit.Framework.Assert.AreEqual(10 + v_1, i.Get(v_1));
            }
            try
            {
                i.Get(n);
                NUnit.Framework.Assert.Fail("Accepted out of bound index on list");
            }
            catch (IndexOutOfRangeException)
            {
                NUnit.Framework.Assert.IsTrue(true);
            }
        }
Exemple #12
0
		public virtual void TestAdd_ZeroCapacity()
		{
			IntList i = new IntList(0);
			NUnit.Framework.Assert.AreEqual(0, i.Size());
			i.Add(1);
			NUnit.Framework.Assert.AreEqual(1, i.Get(0));
		}
Exemple #13
0
		public virtual void TestFillTo0()
		{
			IntList i = new IntList();
			i.FillTo(0, int.MinValue);
			NUnit.Framework.Assert.AreEqual(0, i.Size());
		}
Exemple #14
0
		public virtual void TestFillTo100()
		{
			IntList i = new IntList();
			i.FillTo(100, int.MinValue);
			NUnit.Framework.Assert.AreEqual(100, i.Size());
			i.Add(3);
			NUnit.Framework.Assert.AreEqual(int.MinValue, i.Get(99));
			NUnit.Framework.Assert.AreEqual(3, i.Get(100));
		}
Exemple #15
0
		public virtual void TestClear()
		{
			IntList i = new IntList();
			int n = 5;
			for (int v = 0; v < n; v++)
			{
				i.Add(10 + v);
			}
			NUnit.Framework.Assert.AreEqual(n, i.Size());
			i.Clear();
			NUnit.Framework.Assert.AreEqual(0, i.Size());
			try
			{
				i.Get(0);
				NUnit.Framework.Assert.Fail("Accepted 0 index on empty list");
			}
			catch (IndexOutOfRangeException)
			{
				NUnit.Framework.Assert.IsTrue(true);
			}
		}
Exemple #16
0
		public virtual void TestSet()
		{
			IntList i = new IntList();
			i.Add(1);
			NUnit.Framework.Assert.AreEqual(1, i.Size());
			NUnit.Framework.Assert.AreEqual(1, i.Get(0));
			i.Set(0, 5);
			NUnit.Framework.Assert.AreEqual(5, i.Get(0));
			try
			{
				i.Set(5, 5);
				NUnit.Framework.Assert.Fail("accepted set of 5 beyond end of list");
			}
			catch (IndexOutOfRangeException)
			{
				NUnit.Framework.Assert.IsTrue(true);
			}
			i.Set(1, 2);
			NUnit.Framework.Assert.AreEqual(2, i.Size());
			NUnit.Framework.Assert.AreEqual(2, i.Get(1));
		}
Exemple #17
0
		public virtual void TestAdd_SmallGroup()
		{
			IntList i = new IntList();
			int n = 5;
			for (int v = 0; v < n; v++)
			{
				i.Add(10 + v);
			}
			NUnit.Framework.Assert.AreEqual(n, i.Size());
			for (int v_1 = 0; v_1 < n; v_1++)
			{
				NUnit.Framework.Assert.AreEqual(10 + v_1, i.Get(v_1));
			}
			try
			{
				i.Get(n);
				NUnit.Framework.Assert.Fail("Accepted out of bound index on list");
			}
			catch (IndexOutOfRangeException)
			{
				NUnit.Framework.Assert.IsTrue(true);
			}
		}