2018-10-13 20:57:25 +08:00
|
|
|
package diag
|
|
|
|
|
2020-03-29 04:30:54 +08:00
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
2021-01-27 09:28:38 +08:00
|
|
|
"src.elv.sh/pkg/tt"
|
2020-03-29 04:30:54 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
var Args = tt.Args
|
2018-10-13 20:57:25 +08:00
|
|
|
|
|
|
|
type aRanger struct {
|
|
|
|
Ranging
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestEmbeddingRangingImplementsRanger(t *testing.T) {
|
|
|
|
r := Ranging{1, 10}
|
|
|
|
s := Ranger(aRanger{Ranging{1, 10}})
|
|
|
|
if s.Range() != r {
|
|
|
|
t.Errorf("s.Range() = %v, want %v", s.Range(), r)
|
|
|
|
}
|
|
|
|
}
|
2020-03-29 04:30:54 +08:00
|
|
|
|
|
|
|
func TestPointRanging(t *testing.T) {
|
|
|
|
tt.Test(t, tt.Fn("PointRanging", PointRanging), tt.Table{
|
|
|
|
Args(1).Rets(Ranging{1, 1}),
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestMixedRanging(t *testing.T) {
|
|
|
|
tt.Test(t, tt.Fn("MixedRanging", MixedRanging), tt.Table{
|
|
|
|
Args(Ranging{1, 2}, Ranging{0, 4}).Rets(Ranging{1, 4}),
|
|
|
|
Args(Ranging{0, 4}, Ranging{1, 2}).Rets(Ranging{0, 2}),
|
|
|
|
})
|
|
|
|
}
|