(t *testing.T)
| 123 | } |
| 124 | |
| 125 | func TestSwapStack(t *testing.T) { |
| 126 | stack := NewStack() |
| 127 | stack.Push(1) |
| 128 | stack.Push(2) |
| 129 | |
| 130 | stackTest := NewStack() |
| 131 | stackTest.Push(1) |
| 132 | stackTest.Push(2) |
| 133 | |
| 134 | stackOther := NewStack() |
| 135 | stackOther.Push(3) |
| 136 | stackOther.Push(4) |
| 137 | |
| 138 | stackOtherTest := NewStack() |
| 139 | stackOtherTest.Push(3) |
| 140 | stackOtherTest.Push(4) |
| 141 | |
| 142 | Swap(stack, stackOther) |
| 143 | |
| 144 | if !stack.Equal(stackOtherTest) || !stackOther.Equal(stackTest) { |
| 145 | t.Errorf("swap stack failed") |
| 146 | } |
| 147 | stackOther.Pop() |
| 148 | stackOther.Pop() |
| 149 | |
| 150 | Swap(stack, stackOther) |
| 151 | if !stack.Empty() || !stackOther.Equal(stackOtherTest) { |
| 152 | t.Errorf("swap empty stacl failed") |
| 153 | } |
| 154 | |
| 155 | } |