queue_unbounded_test.go 334 B

12345678910111213141516171819202122232425
  1. package util
  2. import "testing"
  3. func TestEnqueueAndConsume(t *testing.T) {
  4. q := NewUnboundedQueue()
  5. q.EnQueue("1", "2", "3")
  6. f := func(items []string) {
  7. for _, t := range items {
  8. println(t)
  9. }
  10. println("-----------------------")
  11. }
  12. q.Consume(f)
  13. q.Consume(f)
  14. q.EnQueue("4", "5")
  15. q.EnQueue("6", "7")
  16. q.Consume(f)
  17. }