mirror of
https://github.com/go-gitea/gitea.git
synced 2024-11-27 04:24:08 +01:00
fd76f090a2
* markup: microoptimise for many short filenames in directory Move strings.ToLower() after the early-return length check. This is a safe operation in all cases and should slightly improve directory listing performance when a directory contains many thousands of files with short filenames. * markup: expand test cases for IsReadmeFile()
38 lines
712 B
Go
38 lines
712 B
Go
// Copyright 2017 The Gitea Authors. All rights reserved.
|
|
// Use of this source code is governed by a MIT-style
|
|
// license that can be found in the LICENSE file.
|
|
|
|
package markup
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestMisc_IsReadmeFile(t *testing.T) {
|
|
trueTestCases := []string{
|
|
"readme",
|
|
"README",
|
|
"readME.mdown",
|
|
"README.md",
|
|
}
|
|
falseTestCases := []string{
|
|
"test.md",
|
|
"wow.MARKDOWN",
|
|
"LOL.mDoWn",
|
|
"test",
|
|
"abcdefg",
|
|
"abcdefghijklmnopqrstuvwxyz",
|
|
"test.md.test",
|
|
"readmf",
|
|
}
|
|
|
|
for _, testCase := range trueTestCases {
|
|
assert.True(t, IsReadmeFile(testCase))
|
|
}
|
|
for _, testCase := range falseTestCases {
|
|
assert.False(t, IsReadmeFile(testCase))
|
|
}
|
|
}
|