- make ArrayStack make use of our ArrayList

- add Values() method to stacks interface
- write tests
This commit is contained in:
emirpasic
2015-03-07 18:19:58 +01:00
parent 28f559cc09
commit 8e5760a16e
6 changed files with 17 additions and 33 deletions
+4 -5
View File
@@ -27,7 +27,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package arraystack
import (
"github.com/emirpasic/gods/utils"
"testing"
)
@@ -44,8 +43,8 @@ func TestArrayStack(t *testing.T) {
stack.Push(2)
stack.Push(3)
if actualValue := stack.Values(); !utils.IdenticalSlices(actualValue, []interface{}{3, 2, 1}) {
t.Errorf("Got %v expected %v", actualValue, []interface{}{3, 2, 1})
if actualValue := stack.Values(); actualValue[0].(int) != 3 || actualValue[1].(int) != 2 || actualValue[2].(int) != 1 {
t.Errorf("Got %v expected %v", actualValue, "[3,2,1]")
}
if actualValue := stack.Empty(); actualValue != false {
@@ -82,8 +81,8 @@ func TestArrayStack(t *testing.T) {
t.Errorf("Got %v expected %v", actualValue, true)
}
if actualValue := stack.Values(); !utils.IdenticalSlices(actualValue, []interface{}{}) {
t.Errorf("Got %v expected %v", actualValue, []interface{}{})
if actualValue := stack.Values(); len(actualValue) != 0 {
t.Errorf("Got %v expected %v", actualValue, "[]")
}
}