mirror of
https://github.com/walles/moar.git
synced 2024-11-27 01:05:23 +03:00
Fix a heading identification bug
This commit is contained in:
parent
3b16284ed9
commit
4ccc36732d
@ -62,7 +62,7 @@ func isManPageHeading(s string) bool {
|
||||
}
|
||||
}
|
||||
|
||||
return true
|
||||
return nextCharNumber%3 == 0
|
||||
}
|
||||
|
||||
// Alphabetic chars must be upper case, all others are fine.
|
||||
|
20
m/textstyles/manPageHeading_test.go
Normal file
20
m/textstyles/manPageHeading_test.go
Normal file
@ -0,0 +1,20 @@
|
||||
package textstyles
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"gotest.tools/v3/assert"
|
||||
)
|
||||
|
||||
func TestIsManPageHeading(t *testing.T) {
|
||||
assert.Assert(t, !isManPageHeading(""))
|
||||
assert.Assert(t, !isManPageHeading("A"), "Incomplete sequence")
|
||||
assert.Assert(t, !isManPageHeading("A\b"), "Incomplete sequence")
|
||||
|
||||
assert.Assert(t, isManPageHeading("A\bA"))
|
||||
|
||||
assert.Assert(t, !isManPageHeading("A\bC"), "Different first and last char")
|
||||
assert.Assert(t, !isManPageHeading("a\ba"), "Not ALL CAPS")
|
||||
|
||||
assert.Assert(t, !isManPageHeading("A\bAX"), "Incomplete sequence")
|
||||
}
|
Loading…
Reference in New Issue
Block a user