Skip to content

Commit

Permalink
Fix PDF tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tdewolff committed Nov 3, 2024
1 parent bc39995 commit 7753158
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions renderers/pdf/pdf_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package pdf

import (
"bytes"
"fmt"
"image"
"io"
"os"
Expand Down Expand Up @@ -109,7 +108,6 @@ func doTestPDFText(t *testing.T, subsetFonts bool, expectedSize int, filename st
pdf.Close()

written := len(buf.Bytes()) // expecting around 506K
fmt.Println(written)
test.That(t, expectedSize-1000 < written && written < expectedSize+1000, "Unexpected rendering result length")
}

Expand All @@ -130,9 +128,9 @@ func TestPDFMultipage(t *testing.T) {
test.Error(t, err)
out := buf.String()

test.That(t, strings.Contains(out, "/Type /Pages /Count 2"), `could not find "/Type /Pages /Count 2" in output`)
test.That(t, strings.Contains(out, "/Type/Pages/Count 2"), `could not find "/Type /Pages /Count 2" in output`)

nbPages := strings.Count(out, "/Type /Page ")
nbPages := strings.Count(out, "/Type/Page/")
test.That(t, nbPages == 2, "expected 2 pages, got", nbPages)
}

Expand All @@ -145,9 +143,9 @@ func TestPDFMetadata(t *testing.T) {
test.Error(t, err)
out := buf.String()

test.That(t, strings.Contains(out, "/Title (a1)"), `could not find "/Title (a1)" in output`)
test.That(t, strings.Contains(out, "/Subject (b2)"), `could not find "/Subject (b2)" in output`)
test.That(t, strings.Contains(out, "/Keywords (c3)"), `could not find "/Keywords (c3)" in output`)
test.That(t, strings.Contains(out, "/Author (d4)"), `could not find "/Author (d4)" in output`)
test.That(t, strings.Contains(out, "/Creator (e5)"), `could not find "/Creator (e5)" in output`)
test.That(t, strings.Contains(out, "/Title(a1)"), `could not find "/Title (a1)" in output`)
test.That(t, strings.Contains(out, "/Subject(b2)"), `could not find "/Subject (b2)" in output`)
test.That(t, strings.Contains(out, "/Keywords(c3)"), `could not find "/Keywords (c3)" in output`)
test.That(t, strings.Contains(out, "/Author(d4)"), `could not find "/Author (d4)" in output`)
test.That(t, strings.Contains(out, "/Creator(e5)"), `could not find "/Creator (e5)" in output`)
}

0 comments on commit 7753158

Please sign in to comment.