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.

24 lines
596 B

  1. // Copyright 2017 The Gitea Authors. All rights reserved.
  2. // Use of this source code is governed by a MIT-style
  3. // license that can be found in the LICENSE file.
  4. package base
  5. import (
  6. "testing"
  7. "github.com/stretchr/testify/assert"
  8. )
  9. func TestNaturalSortLess(t *testing.T) {
  10. test := func(s1, s2 string, less bool) {
  11. assert.Equal(t, less, NaturalSortLess(s1, s2))
  12. }
  13. test("v1.20.0", "v1.2.0", false)
  14. test("v1.20.0", "v1.29.0", true)
  15. test("v1.20.0", "v1.20.0", false)
  16. test("abc", "bcd", "abc" < "bcd")
  17. test("a-1-a", "a-1-b", true)
  18. test("2", "12", true)
  19. test("a", "ab", "a" < "ab")
  20. }