2012-08-03 19:08:43 -06:00
|
|
|
// Copyright 2012 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.
|
|
|
|
|
2015-03-05 20:58:27 -07:00
|
|
|
package callback
|
2012-08-03 19:08:43 -06:00
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestCall(t *testing.T) {
|
2015-03-05 20:58:27 -07:00
|
|
|
c := NewCaller()
|
|
|
|
cb := NewCallback()
|
2012-08-03 19:08:43 -06:00
|
|
|
|
|
|
|
c.SetCallback(cb)
|
|
|
|
s := c.Call()
|
|
|
|
if s != "Callback::run" {
|
|
|
|
t.Errorf("unexpected string from Call: %q", s)
|
|
|
|
}
|
|
|
|
c.DelCallback()
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestCallback(t *testing.T) {
|
2015-03-05 20:58:27 -07:00
|
|
|
c := NewCaller()
|
|
|
|
cb := NewDirectorCallback(&GoCallback{})
|
2012-08-03 19:08:43 -06:00
|
|
|
c.SetCallback(cb)
|
|
|
|
s := c.Call()
|
|
|
|
if s != "GoCallback.Run" {
|
|
|
|
t.Errorf("unexpected string from Call with callback: %q", s)
|
|
|
|
}
|
|
|
|
c.DelCallback()
|
2015-03-05 20:58:27 -07:00
|
|
|
DeleteDirectorCallback(cb)
|
2012-08-03 19:08:43 -06:00
|
|
|
}
|