You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

51 lines
1.5 KiB

package service
import (
"testing"
. "github.com/smartystreets/goconvey/convey"
)
func TestWithinFloor(t *testing.T) {
var (
ids = []int64{3, 5, 7, 9, 11, 13, 15}
)
// within asc
Convey("withinFloor asc without page 1", t, WithService(func(s *Service) {
r := withinFloor(ids, 1, 1, 5, true)
So(r, ShouldBeFalse)
}))
Convey("withinFloor asc within page 1", t, WithService(func(s *Service) {
r := withinFloor(ids, 4, 1, 5, true)
So(r, ShouldBeTrue)
}))
Convey("withinFloor asc within page 1", t, WithService(func(s *Service) {
r := withinFloor(ids, 16, 1, 20, true)
So(r, ShouldBeTrue)
}))
Convey("withinFloor asc without page 1", t, WithService(func(s *Service) {
r := withinFloor(ids, 16, 1, 5, true)
So(r, ShouldBeFalse)
}))
// within desc
Convey("withinFloor desc within page 1", t, WithService(func(s *Service) {
r := withinFloor(ids, 16, 1, 5, false)
So(r, ShouldBeTrue)
}))
Convey("withinFloor desc within page 2", t, WithService(func(s *Service) {
r := withinFloor(ids, 16, 2, 5, false)
So(r, ShouldBeFalse)
}))
Convey("withinFloor desc within page 1", t, WithService(func(s *Service) {
r := withinFloor(ids, 2, 3, 20, false)
So(r, ShouldBeTrue)
}))
Convey("withinFloor desc without page 1", t, WithService(func(s *Service) {
r := withinFloor(ids, 1, 1, 5, false)
So(r, ShouldBeFalse)
}))
Convey("withinFloor desc within page 1", t, WithService(func(s *Service) {
r := withinFloor(ids, 1, 1, 20, true)
So(r, ShouldBeTrue)
}))
}