Skip to content

Instantly share code, notes, and snippets.

@sausheong
Created May 16, 2022 06:16
Show Gist options
  • Save sausheong/a00dbddac37d367cee6a809e484348ac to your computer and use it in GitHub Desktop.
Save sausheong/a00dbddac37d367cee6a809e484348ac to your computer and use it in GitHub Desktop.
generics
func TestStringStack(t *testing.T) {
stack := &StringStack{}
stack.Push("the")
stack.Push("quick")
stack.Push("brown")
stack.Push("fox")
if stack.Peek() != "fox" {
t.Error(stack.Peek())
}
if str := stack.Pop(); str != "fox" {
t.Error(str)
}
if str := stack.Pop(); str != "brown" {
t.Error(str)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment