Skip to content

Commit

Permalink
Add testcase that parses a large dictionary.
Browse files Browse the repository at this point in the history
  • Loading branch information
fancycode authored and hhrutter committed Jan 25, 2024
1 parent bec27a4 commit 04634d3
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions pkg/pdfcpu/model/parse_dict_test.go
Expand Up @@ -17,6 +17,8 @@ limitations under the License.
package model

import (
"fmt"
"strings"
"testing"
)

Expand Down Expand Up @@ -145,6 +147,19 @@ func doTestParseDictWithComments(t *testing.T) {

}

func doTestLargeDicts(t *testing.T) {
// Make sure parsing large dictionaries is fast. Found a file in the wild
// that has two dictionaries with about 200.000 entries each.
var sb strings.Builder
sb.WriteString("<<")
for i := 0; i < 50000; i++ {
sb.WriteString(fmt.Sprintf("/Key%d (Value)", i))
}
sb.WriteString(">>")

doTestParseDictOK(sb.String(), t)
}

func TestParseDict(t *testing.T) {
doTestParseDictGeneral(t)
doTestParseDictNameObjects(t)
Expand All @@ -156,4 +171,5 @@ func TestParseDict(t *testing.T) {
doTestParseDictNumerics(t)
doTestParseDictIndirectRefs(t)
doTestParseDictWithComments(t)
doTestLargeDicts(t)
}

0 comments on commit 04634d3

Please sign in to comment.