public void MimicStaticText() { // 5.栈的压入弹出 MimicStack <int> test = new MimicStack <int>(); Assert.AreEqual(0, test.pop()); test.push(23); Assert.AreEqual(23, test.pop()); test.push(232); Assert.AreEqual(232, test.pop()); Assert.AreNotEqual(23, test.pop()); test.push(23); test.push(26); test.push(213541233); test.push(23); test.push(24); test.push(231); test.push(2324); test.push(2563); test.push(273); test.push(233); test.push(223); //here already stack overflow. test.push(253); //here already stack overflow. Assert.AreEqual(233, test.pop()); Assert.AreNotEqual(253, test.pop()); Assert.AreEqual(2563, test.pop()); Assert.AreEqual(2324, test.pop()); Assert.AreNotEqual(2153, test.pop()); }
[Test] //5.栈的压入弹出 public void PushTest1() //压入测试 { MimicStack <string> lw = new MimicStack <string>(3); Assert.AreEqual(1, lw.Push("0000")); Assert.AreEqual(2, lw.Push("0001")); Assert.AreEqual(3, lw.Push("0002")); Assert.AreEqual(-1, lw.Push("0003")); }
public void PopTest() { int element = 0; MimicStack <int> zl = new MimicStack <int> (3); bool hasEmpty = zl.Pop(out element); Assert.AreEqual(false, hasEmpty); Assert.AreEqual(0, element); zl.Push(3); zl.Push(5); hasEmpty = zl.Pop(out element); Assert.IsTrue(hasEmpty); Assert.AreEqual(5, element); hasEmpty = zl.Pop(out element); Assert.IsTrue(hasEmpty); Assert.AreEqual(3, element); }
//[Test] public void MimicStackTest001() { MimicStack mstack = new MimicStack(3); Console.WriteLine(mstack.Push(35)); Console.WriteLine(mstack.Push(25)); Console.WriteLine(mstack.Push(15)); Console.WriteLine(mstack.Pop()); Console.WriteLine(mstack.Push(5)); Console.WriteLine(mstack.Pop()); Console.WriteLine(mstack.Pop()); int[] arr = new int[] { 5, 6, 7, 8, 9 }; Console.WriteLine(mstack.Push(arr)); Console.WriteLine(mstack.Pop()); Console.WriteLine(mstack.Pop()); Console.WriteLine(mstack.Pop()); Console.WriteLine(mstack.Pop()); }
public void TMimicStackTest() { //MimicStack mstack = new MimicStack(3); MimicStack <int> mstack = new MimicStack <int>(3); Console.WriteLine($"{mstack.Push(35, out int putin)}+{putin}"); Console.WriteLine($"{mstack.Push(25, out putin)}+{putin}"); Console.WriteLine($"{mstack.Push(15, out putin)}+{putin}"); Console.WriteLine($"{mstack.Pop(out int putout)}+{putout}"); Console.WriteLine($"{mstack.Push(5, out putin)}+{putin}"); Console.WriteLine($"{mstack.Pop(out putout)}+{putout}"); Console.WriteLine($"{mstack.Pop(out putout)}+{putout}"); int[] arr = new int[] { 5, 6, 7, 8, 9 }; Console.WriteLine($"{mstack.Push(arr, out List<int> list)}+{list}"); Console.WriteLine($"{mstack.Pop(out putout)}+{putout}"); Console.WriteLine($"{mstack.Pop(out putout)}+{putout}"); Console.WriteLine($"{mstack.Pop(out putout)}+{putout}"); Console.WriteLine($"{mstack.Pop(out putout)}+{putout}"); }