mirror of https://github.com/junegunn/fzf
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
25 lines
452 B
Go
25 lines
452 B
Go
2 months ago
|
package util
|
||
|
|
||
|
import (
|
||
|
"reflect"
|
||
|
"testing"
|
||
|
)
|
||
|
|
||
|
func TestAtExit(t *testing.T) {
|
||
|
want := []int{3, 2, 1, 0}
|
||
|
var called []int
|
||
|
for i := 0; i < 4; i++ {
|
||
|
n := i
|
||
|
AtExit(func() { called = append(called, n) })
|
||
|
}
|
||
|
RunAtExitFuncs()
|
||
|
if !reflect.DeepEqual(called, want) {
|
||
|
t.Errorf("AtExit: want call order: %v got: %v", want, called)
|
||
|
}
|
||
|
|
||
|
RunAtExitFuncs()
|
||
|
if !reflect.DeepEqual(called, want) {
|
||
|
t.Error("AtExit: should only call exit funcs once")
|
||
|
}
|
||
|
}
|