mirror of
https://github.com/rjNemo/underscore
synced 2026-06-09 12:06:41 +00:00
31 lines
530 B
Go
31 lines
530 B
Go
package underscore_test
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
u "github.com/rjNemo/underscore"
|
|
)
|
|
|
|
func Test_OrderBy_Asc(t *testing.T) {
|
|
set := u.Range(5, 0)
|
|
want := u.Range(0, 5)
|
|
|
|
result := u.OrderBy(set, func(left int, right int) bool {
|
|
return left > right
|
|
})
|
|
|
|
assert.Equal(t, want, result)
|
|
}
|
|
|
|
func Test_OrderBy_Desc(t *testing.T) {
|
|
set := u.Range(0, 5)
|
|
want := u.Range(5, 0)
|
|
|
|
result := u.OrderBy(set, func(left int, right int) bool {
|
|
return left < right
|
|
})
|
|
|
|
assert.Equal(t, want, result)
|
|
}
|