| // Copyright 2020 The Go Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style |
| // license that can be found in the LICENSE file. |
| |
| package main |
| |
| import "./a" |
| |
| func main() { |
| var s a.Stack[string] |
| s.Push("hi") |
| s.Push("bye") |
| if s.IsEmpty() { |
| panic("unexpected IsEmpty") |
| } |
| if s.Len() != 2 { |
| panic("bad Len") |
| } |
| if v, ok := s.Pop(); !ok || v != "bye" { |
| panic("bad Pop 1") |
| } |
| if v, ok := s.Pop(); !ok || v != "hi" { |
| panic("bad Pop 2") |
| } |
| if !s.IsEmpty() { |
| panic("expected IsEmpty") |
| } |
| if s.Len() != 0 { |
| panic("bad Len 2") |
| } |
| } |