callback_test.go 673 B

123456789101112131415161718192021222324252627282930313233
  1. // Copyright 2012 The Go Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style
  3. // license that can be found in the LICENSE file.
  4. package callback
  5. import (
  6. "testing"
  7. )
  8. func TestCall(t *testing.T) {
  9. c := NewCaller()
  10. cb := NewCallback()
  11. c.SetCallback(cb)
  12. s := c.Call()
  13. if s != "Callback::run" {
  14. t.Errorf("unexpected string from Call: %q", s)
  15. }
  16. c.DelCallback()
  17. }
  18. func TestCallback(t *testing.T) {
  19. c := NewCaller()
  20. cb := NewDirectorCallback(&GoCallback{})
  21. c.SetCallback(cb)
  22. s := c.Call()
  23. if s != "GoCallback.Run" {
  24. t.Errorf("unexpected string from Call with callback: %q", s)
  25. }
  26. c.DelCallback()
  27. DeleteDirectorCallback(cb)
  28. }