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