github.com/unidoc/unidoc@v2.2.0+incompatible/pdf/extractor/text_test.go (about)

     1  /*
     2   * This file is subject to the terms and conditions defined in
     3   * file 'LICENSE.md', which is part of this source code package.
     4   */
     5  
     6  package extractor
     7  
     8  import (
     9  	"flag"
    10  	"testing"
    11  )
    12  
    13  func init() {
    14  	if flag.Lookup("test.v") != nil {
    15  		isTesting = true
    16  	}
    17  }
    18  
    19  const testContents1 = `
    20  BT
    21  /F1 24 Tf
    22  (Hello World!)Tj
    23  0 -10 Td
    24  (Doink)Tj
    25  ET
    26  `
    27  const testExpected1 = "Hello World!\nDoink"
    28  
    29  func TestTextExtraction1(t *testing.T) {
    30  	e := Extractor{}
    31  	e.contents = testContents1
    32  
    33  	s, err := e.ExtractText()
    34  	if err != nil {
    35  		t.Errorf("Error extracting text: %v", err)
    36  		return
    37  	}
    38  	if s != testExpected1 {
    39  		t.Errorf("Text mismatch (%s)", s)
    40  		t.Errorf("Text mismatch (% X vs % X)", s, testExpected1)
    41  		return
    42  	}
    43  }