summaryrefslogtreecommitdiffstats
path: root/hugolib/page_test.go
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2018-10-19 11:30:57 +0200
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2018-10-22 20:46:13 +0200
commit44da60d869578423dea529db62ed613588a2a560 (patch)
tree0e9839e0d4a23048ae57f145fb3dedc1ad8005f5 /hugolib/page_test.go
parent1e3e34002dae3d4a980141efcc86886e7de5bef8 (diff)
hugolib: Redo the summary delimiter logic
Now that we have a proper page parse tree, this can be greatly simplified. See #5324
Diffstat (limited to 'hugolib/page_test.go')
-rw-r--r--hugolib/page_test.go54
1 files changed, 0 insertions, 54 deletions
diff --git a/hugolib/page_test.go b/hugolib/page_test.go
index bb820b86e..7359140fc 100644
--- a/hugolib/page_test.go
+++ b/hugolib/page_test.go
@@ -1272,60 +1272,6 @@ func TestSliceToLower(t *testing.T) {
}
}
-func TestReplaceDivider(t *testing.T) {
- t.Parallel()
-
- tests := []struct {
- content string
- from string
- to string
- expectedContent string
- expectedTruncated bool
- }{
- {"none", "a", "b", "none", false},
- {"summary <!--more--> content", "<!--more-->", "HUGO", "summary HUGO content", true},
- {"summary\n\ndivider", "divider", "HUGO", "summary\n\nHUGO", false},
- {"summary\n\ndivider\n\r", "divider", "HUGO", "summary\n\nHUGO\n\r", false},
- }
-
- for i, test := range tests {
- replaced, truncated := replaceDivider([]byte(test.content), []byte(test.from), []byte(test.to))
-
- if truncated != test.expectedTruncated {
- t.Fatalf("[%d] Expected truncated to be %t, was %t", i, test.expectedTruncated, truncated)
- }
-
- if string(replaced) != test.expectedContent {
- t.Fatalf("[%d] Expected content to be %q, was %q", i, test.expectedContent, replaced)
- }
- }
-}
-
-func BenchmarkReplaceDivider(b *testing.B) {
- divider := "HUGO_DIVIDER"
- from, to := []byte(divider), []byte("HUGO_REPLACED")
-
- withDivider := make([][]byte, b.N)
- noDivider := make([][]byte, b.N)
-
- for i := 0; i < b.N; i++ {
- withDivider[i] = []byte(strings.Repeat("Summary ", 5) + "\n" + divider + "\n" + strings.Repeat("Word ", 300))
- noDivider[i] = []byte(strings.Repeat("Word ", 300))
- }
-
- b.ResetTimer()
- for i := 0; i < b.N; i++ {
- _, t1 := replaceDivider(withDivider[i], from, to)
- _, t2 := replaceDivider(noDivider[i], from, to)
- if !t1 {
- b.Fatal("Should be truncated")
- }
- if t2 {
- b.Fatal("Should not be truncated")
- }
- }
-}
-
func TestPagePaths(t *testing.T) {
t.Parallel()