コード例 #1
0
        public void Indekser_Stos()
        {
            stos = new StosWTablicy <char>();
            stos.Push('a');
            stos.Push('b');
            stos.Push('c');

            Assert.AreEqual('b', stos[1]);
        }
コード例 #2
0
        public void Indexer()
        {
            stos = new StosWLiscie <char>();
            stos.Push(RandomElement);
            stos.Push(RandomElement);
            stos.Push(RandomElement);
            stos.Push(RandomElement);

            for (int i = 0; i < stos.Count; i++)
            {
                Console.WriteLine(stos[i]);
            }
        }
コード例 #3
0
        public void TrimExcess()
        {
            stos = new StosWTablicy <char>();

            stos.Push(RandomElement);
            stos.Push(RandomElement);
            stos.Push(RandomElement);
            stos.Push(RandomElement);

            stos.Clear();
            stos.TrimExcess();

            Assert.AreEqual(0, stos.Count);
        }
コード例 #4
0
        public void IndexerCzyZwracaOdpowiednielement()
        {
            stos = new StosWTablicy <char>();
            stos.Push(RandomElement);
            stos.Push(RandomElement);
            stos.Push(RandomElement);
            stos.Push(RandomElement);

            char[] tab = stos.ToArray();

            for (int i = 0; i < 4; i++)
            {
                Assert.AreEqual(stos[i], tab[i]);
            }
        }
コード例 #5
0
        public void StackUpdatingToTheSameState()
        {
            stack = new StosWTablicy <char>();
            stack.Push(RandomChar);
            stack.Push(RandomChar);

            char[] tab1 = stack.ToArray();
            char   e    = RandomChar;

            stack.Push(e);
            stack.Pop();
            char[] tab2 = stack.ToArray();

            CollectionAssert.AreEqual(tab1, tab2);
        }
コード例 #6
0
        public void PushPop_StosSieNieZmienia()
        {
            stos = new StosWTablicy <char>();
            stos.Push(RandomElement);
            stos.Push(RandomElement);

            char[] tabPrzed = stos.ToArray();
            char   e        = RandomElement;

            stos.Push(e);
            stos.Pop();
            char[] tabPo = stos.ToArray();

            CollectionAssert.AreEqual(tabPrzed, tabPo);
        }
コード例 #7
0
        public void TrimExceptionCzyZmieniarozmiarTablicy()
        {
            stos = new StosWTablicy <char>(2);
            char e = RandomElement;


            stos.Push(e);
            stos.Push(e);
            ((StosWTablicy <char>)stos).TrimExcess();
            stos.Push(e);

            ((StosWTablicy <char>)stos).TrimExcess();
            int temp = ((StosWTablicy <char>)stos).Capacity;

            Assert.IsTrue(temp == 4);
        }
コード例 #8
0
        public void Indexer_Test_Tablica()
        {
            stos = new StosWTablicy <char>();
            var element = RandomElement;

            stos.Push(element);
            Assert.AreEqual(stos[0], element);
        }
コード例 #9
0
        public void Indekser_Test_Lista()
        {
            stos = new StosWLiscie <char>();
            var element = RandomElement;

            stos.Push(element);
            Assert.AreEqual(stos[0], element);
        }
コード例 #10
0
        public void Peek_ZwracaOstatnioWstawionyElement()
        {
            stos = new StosWTablicy <char>();
            char e = RandomElement;

            stos.Push(e);

            Assert.AreEqual(stos.Peek, e);
        }
コード例 #11
0
        public void IndexerWTablicy()
        {
            stos = new StosWTablicy <char>();
            var el = RandomElement;

            stos.Push(el);

            Assert.AreEqual(stos[0], el);
        }
コード例 #12
0
        public void StackPeek()
        {
            stack = new StosWTablicy <char>();
            char e = RandomChar;

            stack.Push(e);

            Assert.AreEqual(stack.Peek, e);
        }
コード例 #13
0
        public void StosIEnumeratorCzyEnumeruje()
        {
            stos = new StosWTablicy <char>();
            stos.Push(RandomElement);
            stos.Push(RandomElement);
            stos.Push(RandomElement);
            stos.Push(RandomElement);

            char[] tab = stos.ToArray();
            int    i   = 0;

            var enumerator = stos.ToArray().GetEnumerator();

            while (enumerator.MoveNext())
            {
                char s = (char)enumerator.Current;
                Assert.AreEqual(s, tab[i]);
                i++;
            }
        }
コード例 #14
0
        public void TrimExcess(int d)
        {
            stos = new StosWTablicy <char>();
            for (int i = 0; i < d; i++)
            {
                stos.Push(RandomElement);
            }
            stos.TrimExcess();
            int l = stos.Count + (int)Math.Floor(stos.Count * 0.1);

            Assert.AreEqual(stos.Lenght, l);
        }
コード例 #15
0
        public void TrimExcess_Usunięcie10p_Komórek()
        {
            stos = new StosWTablicy <char>();
            for (int i = 0; i < 100; i++)
            {
                stos.Push(RandomElement);
            }
            stos.TrimExcess();
            int ss = stos.Count;

            Assert.AreEqual(90, ss);
        }
コード例 #16
0
        public void TrimExcessWTablicy()
        {
            stos = new StosWTablicy <char>();

            for (int i = 0; i < 142; i++)
            {
                stos.Push(RandomElement);
            }

            stos.TrimExcess();

            Assert.AreEqual(127, stos.Count);
        }
コード例 #17
0
 public void IsEmpty_PoUtworzeniuIDodaniuElementuStosNieJestPusty()
 {
     stos = new StosWTablicy <char>();
     stos.Push(RandomElement);
     Assert.IsFalse(stos.IsEmpty);
 }
コード例 #18
0
 public void StackNotEmpty()
 {
     stack = new StosWTablicy <char>();
     stack.Push(RandomChar);
     Assert.IsTrue(!stack.IsEmpty);
 }