Add RuneCount to Page

Fixes #1266
This commit is contained in:
Bjørn Erik Pedersen
2015-07-12 11:05:37 +02:00
parent 90af334c21
commit 77c60a3440
4 changed files with 46 additions and 0 deletions

View File

@@ -138,6 +138,16 @@ title: Simple
Summary Same Line<!--more-->
Some more text
`
SIMPLE_PAGE_WITH_FIVE_MULTIBYTE_UFT8_RUNES = `---
title: Simple
---
€ € € € €
`
SIMPLE_PAGE_WITH_LONG_CONTENT = `---
@@ -470,6 +480,21 @@ func TestPageWithDate(t *testing.T) {
checkPageDate(t, p, d)
}
func TestRuneCount(t *testing.T) {
p, _ := NewPage("simple.md")
_, err := p.ReadFrom(strings.NewReader(SIMPLE_PAGE_WITH_FIVE_MULTIBYTE_UFT8_RUNES))
p.Convert()
p.analyzePage()
if err != nil {
t.Fatalf("Unable to create a page with frontmatter and body content: %s", err)
}
if p.RuneCount() != 5 {
t.Fatalf("incorrect rune count for content '%s'. expected %v, got %v", p.plain, 1, p.RuneCount())
}
}
func TestWordCount(t *testing.T) {
p, _ := NewPage("simple.md")
_, err := p.ReadFrom(strings.NewReader(SIMPLE_PAGE_WITH_LONG_CONTENT))