예제 #1
0
 private void AddStackValues <T>(IStacks <T> stacks, T[][] stackValues)
 {
     for (int i = 0; i < stackValues.Length; i++)
     {
         for (int j = 0; j < stackValues[i].Length; j++)
         {
             T   value      = stackValues[i][j];
             int stackIndex = i;
             stacks.Push(value, stackIndex);
         }
     }
 }
예제 #2
0
 private void PushTest(IStacks <int> stacks)
 {
     int[][] stackValues = GetStackValues();
     for (int i = 0; i < stackValues.Length; i++)
     {
         for (int j = 0; j < stackValues[i].Length; j++)
         {
             int value      = stackValues[i][j];
             int stackIndex = i;
             stacks.Push(value, stackIndex);
             int result = stacks.Peek(stackIndex);
             Assert.AreEqual(value, result);
         }
     }
 }
예제 #3
0
 private void PopTest(IStacks <int> stacks)
 {
     int[][] stackValues = GetStackValues();
     for (int i = 0; i < stackValues.Length; i++)
     {
         for (int j = 0; j < stackValues[i].Length; j++)
         {
             int stackIndex = i;
             int value      = stacks.Peek(stackIndex);
             int result     = stacks.Pop(stackIndex);
             int newValue   = (j < stackValues[i].Length - 1) ? stacks.Peek(stackIndex) : 0;
             Assert.AreEqual(value, result);
             Assert.AreEqual(false, (result == newValue));
         }
     }
 }
예제 #4
0
 private void RunTests(IStacks <int> stacks)
 {
     PushTest(stacks);
     PopTest(stacks);
 }