Advertisement
Guest User

Untitled

a guest
Dec 7th, 2016
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. package stack
  2.  
  3. import (
  4. "testing"
  5.  
  6. )
  7.  
  8. func TestStack1(t *testing.T) {
  9. stack := new(Stack)
  10.  
  11. stack.Push(1)
  12. stack.Push("Hello")
  13.  
  14. stack_length := stack.Length()
  15.  
  16. if stack_length != 2 {
  17. t.Errorf("Stack length is: 2")
  18. }
  19.  
  20. }
  21.  
  22. func TestStack2(t *testing.T) {
  23. stack := new(Stack)
  24.  
  25. stack.Push(1)
  26. stack.Push("Hello")
  27. stack.Push(1.5)
  28. stack.Push(true)
  29.  
  30. stack_element := stack.Pop()
  31.  
  32. if stack_element != true {
  33. t.Errorf("Stack element should be true")
  34. }
  35.  
  36. stack_element = stack.Pop()
  37.  
  38. if stack_element != 1.5 {
  39. t.Errorf("Stack element should be 1.5")
  40. }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement