mirror of
https://github.com/go-sylixos/elvish.git
synced 2024-12-05 03:17:50 +08:00
6e36058d0a
- Use reflection to derive function name. - Take test cases as variadic arguments, instead of requiring them to be wrapped in a Table. - Support naming test cases. - Run test cases as subtests with t.Run.
28 lines
427 B
Go
28 lines
427 B
Go
package vals
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"src.elv.sh/pkg/tt"
|
|
)
|
|
|
|
type customBooler struct{ b bool }
|
|
|
|
func (b customBooler) Bool() bool { return b.b }
|
|
|
|
type customNonBooler struct{}
|
|
|
|
func TestBool(t *testing.T) {
|
|
tt.Test(t, Bool,
|
|
Args(nil).Rets(false),
|
|
|
|
Args(true).Rets(true),
|
|
Args(false).Rets(false),
|
|
|
|
Args(customBooler{true}).Rets(true),
|
|
Args(customBooler{false}).Rets(false),
|
|
|
|
Args(customNonBooler{}).Rets(true),
|
|
)
|
|
}
|