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.

natural_sort_test.go 509B

1234567891011121314151617181920212223
  1. // Copyright 2017 The Gitea Authors. All rights reserved.
  2. // SPDX-License-Identifier: MIT
  3. package base
  4. import (
  5. "testing"
  6. "github.com/stretchr/testify/assert"
  7. )
  8. func TestNaturalSortLess(t *testing.T) {
  9. test := func(s1, s2 string, less bool) {
  10. assert.Equal(t, less, NaturalSortLess(s1, s2))
  11. }
  12. test("v1.20.0", "v1.2.0", false)
  13. test("v1.20.0", "v1.29.0", true)
  14. test("v1.20.0", "v1.20.0", false)
  15. test("abc", "bcd", true)
  16. test("a-1-a", "a-1-b", true)
  17. test("2", "12", true)
  18. test("a", "ab", true)
  19. }