static void Main(string[] args)
        {
            StosWTablicy <string> s = new StosWTablicy <string>(2);

            s.Push("km");
            s.Push("aa");
            s.Push("xx");
            foreach (var x in s.ToArray())
            {
                Console.WriteLine(x);
            }

            Console.WriteLine();

            StosWLiscie <string> s2 = new StosWLiscie <string>();

            s2.Push("km");
            s2.Push("aa");
            s2.Push("xx");
            foreach (var x in s2.ToArray())
            {
                Console.WriteLine(x);
            }

            Console.WriteLine();
        }
        public void Indexer_Test_Exception_Greater_Than_Length()
        {
            StosWTablicy <char> stos = new StosWTablicy <char>();

            stos.Push('a');

            char x = stos[stos.Count + 2];
        }
        public void Indexer_Test_Exception_Less_Than_Zero()
        {
            StosWTablicy <char> stos = new StosWTablicy <char>();

            stos.Push('a');

            char x = stos[-1];
        }
        public void Indexer_Test()
        {
            StosWTablicy <char> stos = new StosWTablicy <char>();

            stos.Push('a');
            stos.Push('b');

            Assert.AreEqual('a', stos[0]);
            Assert.AreEqual('b', stos[stos.Count - 1]);
        }
Esempio n. 5
0
        public void Indexer_Valid(int[] array, int ind, int value)
        {
            var s = new StosWTablicy <int>();

            foreach (int i in array)
            {
                s.Push(i);
            }
            Assert.AreEqual(value, s[ind]);
        }
        public void TrimExcess_Test_Method(int elements)
        {
            var g = new StosWTablicy <int>(elements);

            for (int i = 0; i < elements; ++i)
            {
                g.Push(i);
            }
            g.TrimExcess();
            Assert.AreEqual(elements, (int)Math.Floor(g.GetTabLength() * 0.9));
        }
Esempio n. 7
0
        public void TrimExcessDlaPustegoStosu_Valid(int size)
        {
            var s = new StosWTablicy <int>(size);

            for (int i = 0; i < size; ++i)
            {
                s.Push(i);
            }
            s.TrimExcess();
            Assert.AreEqual(size, (int)Math.Floor(s.GetTabLength() * 0.9));
        }
Esempio n. 8
0
        public void CzyResizeDziala()
        {
            StosWTablicy <char> stos = new StosWTablicy <char>(2);

            stos.Push('a');
            stos.Push('b');
            stos.Push('c');
            Assert.AreEqual(stos.Count, 3);
            Assert.AreEqual(stos[0], 'a');
            Assert.AreEqual(stos[1], 'b');
            Assert.AreEqual(stos[2], 'c');
        }
Esempio n. 9
0
        public void IndexerTest()
        {
            var stos = new StosWTablicy <int>();

            stos.Push(1);
            stos.Push(2);
            stos.Push(3);
            stos.Push(4);

            Assert.AreEqual(stos[0], 1);
            Assert.AreEqual(stos[1], 2);
            Assert.AreEqual(stos[2], 3);
            Assert.AreEqual(stos[3], 4);
        }
Esempio n. 10
0
        public void IndexerTest()
        {
            StosWTablicy <char> stos = new StosWTablicy <char>();

            stos.Push('a');
            stos.Push('b');
            stos.Push('c');
            Assert.AreEqual(stos[0], 'a');
            Assert.AreEqual(stos[1], 'b');
            Assert.AreEqual(stos[2], 'c');

            stos.Pop();
            Assert.AreEqual(stos[0], 'a');
            Assert.AreEqual(stos[1], 'b');
        }
Esempio n. 11
0
        public void CzyTrimDziala()
        {
            StosWTablicy <char> stos = new StosWTablicy <char>(2);

            stos.Push('a');
            stos.Push('b');
            stos.Push('c');
            stos.Push('d');
            stos.Push('e');
            stos.TrimExcess();
            Assert.AreEqual(stos.Count, 5);
            Assert.AreEqual(stos[0], 'a');
            Assert.AreEqual(stos[1], 'b');
            Assert.AreEqual(stos[2], 'c');
            Assert.AreEqual(stos[3], 'd');
            Assert.AreEqual(stos[4], 'e');
        }
Esempio n. 12
0
        public void IndexerTest(string val, int elements)
        {
            var s = new StosWTablicy <string>(elements);

            for (int i = 0; i < elements; i++)
            {
                if (i == elements - 1)
                {
                    s.Push(val);
                }
                else
                {
                    s.Push("test0");
                }
            }
            Assert.AreEqual(val, s[elements - 1]);
        }
Esempio n. 13
0
        public void StackTrimExcess(int index)
        {
            int expectedLength;

            if (index <= 5)
            {
                expectedLength = index + 1;
            }
            else
            {
                expectedLength = index + Convert.ToInt32((1d / 10d) * index);
            }
            var s = new StosWTablicy <int>();

            for (int i = 0; i < index; i++)
            {
                s.Push(1);
            }
            s.TrimExcess();
            Assert.AreEqual(expectedLength, s.Length());
        }
Esempio n. 14
0
        public void TrimExcessTestMethod(int elements)
        {
            int expectedLength;

            if (elements <= 5)
            {
                expectedLength = elements + 1;
            }
            else
            {
                expectedLength = elements + Convert.ToInt32((1 / 10d) * elements);
            }
            var s = new StosWTablicy <int>();

            for (int i = 0; i < elements; i++)
            {
                s.Push(1);
            }
            s.TrimExcess();
            Assert.AreEqual(expectedLength, s.GetActualTabLength());
        }
        static void Main(string[] args)
        {
            StosWTablicy <string> s = new StosWTablicy <string>();

            s.Push("km");
            s.Push("aa");
            s.Push("ab");
            s.Push("ac");
            s.Push("xx");

            foreach (var x in s)
            {
                Console.WriteLine(x);
            }
            Console.WriteLine("---top to bottom---");
            foreach (var x in ((StosWTablicy <string>)s).TopToBottom)
            {
                Console.WriteLine(x);
            }
            Console.WriteLine($"Actual tab length: {s.GetActualTabLength()}");
            s.TrimExcess();
            Console.WriteLine($"Length after TrimExcess: {s.GetActualTabLength()}");

            Console.WriteLine($"el at position 1 (\"aa\"): {s[1]} {"aa" == s[1]}");
            Console.WriteLine();

            var sToArray         = s.ToArray();
            var sToArrayReadOnly = s.ToArrayReadOnly();

            sToArray[1] = "ssss";
            foreach (var x in sToArray)
            {
                Console.WriteLine(x);
            }
            //sToArrayReadOnly[1] = "ss"; read only error
            Console.WriteLine("---StosWLiscie---");
            StosWLiscie <int> sl = new StosWLiscie <int>();

            sl.Push(5);
            sl.Push(6);
            Console.WriteLine($"el at index 1: {sl[1]}");
            sl.Push(7);
            sl.Push(8);
            int[] tab = sl.ToArray();
            foreach (var i in tab)
            {
                Console.Write($"{i} ");
            }
            Console.WriteLine("\nPop:");
            sl.Pop();
            tab = sl.ToArray();
            foreach (var i in tab)
            {
                Console.Write($"{i} ");
            }
            Console.WriteLine();
            Console.WriteLine("foreach through StosWLiscie");
            foreach (var i in sl)
            {
                Console.Write($"{i} ");
            }
            Console.WriteLine($"\nIs array empty? {sl.IsEmpty}");
            sl.Clear();
            Console.WriteLine("After clear:");
            Console.WriteLine($"Is array empty? {sl.IsEmpty}");
        }
        public void TrimExcess_PustegoStosu_StosEmptyException()
        {
            var f = new StosWTablicy <int>();

            f.TrimExcess();
        }
Esempio n. 17
0
 public void Indexer_ArgumentOutOfRangeException(int ind)
 {
     var s = new StosWTablicy <int>();
     int i = s[ind];
 }
Esempio n. 18
0
        public void TrimExcessDlaPustegoStosu_StosEmptyException()
        {
            var s = new StosWTablicy <int>();

            s.TrimExcess();
        }