Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package stack
- import (
- "testing"
- )
- func TestStack1(t *testing.T) {
- stack := new(Stack)
- stack.Push(1)
- stack.Push("Hello")
- stack_length := stack.Length()
- if stack_length != 2 {
- t.Errorf("Stack length is: 2")
- }
- }
- func TestStack2(t *testing.T) {
- stack := new(Stack)
- stack.Push(1)
- stack.Push("Hello")
- stack.Push(1.5)
- stack.Push(true)
- stack_element := stack.Pop()
- if stack_element != true {
- t.Errorf("Stack element should be true")
- }
- stack_element = stack.Pop()
- if stack_element != 1.5 {
- t.Errorf("Stack element should be 1.5")
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement