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