2018-03-22 14:03:47 +00:00
|
|
|
/*
|
|
|
|
* This file is subject to the terms and conditions defined in
|
|
|
|
* file 'LICENSE.md', which is part of this source code package.
|
|
|
|
*/
|
|
|
|
|
2018-03-22 13:01:04 +00:00
|
|
|
package extractor
|
|
|
|
|
2018-03-22 13:53:12 +00:00
|
|
|
import (
|
|
|
|
"flag"
|
|
|
|
"testing"
|
2018-11-02 15:13:48 +11:00
|
|
|
|
|
|
|
"github.com/unidoc/unidoc/common"
|
2018-03-22 13:53:12 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func init() {
|
2018-11-02 15:13:48 +11:00
|
|
|
common.SetLogger(common.NewConsoleLogger(common.LogLevelDebug))
|
2018-03-22 13:53:12 +00:00
|
|
|
if flag.Lookup("test.v") != nil {
|
|
|
|
isTesting = true
|
|
|
|
}
|
|
|
|
}
|
2018-03-22 13:01:04 +00:00
|
|
|
|
|
|
|
const testContents1 = `
|
2018-07-07 09:45:55 +10:00
|
|
|
BT
|
2018-07-15 17:22:00 +10:00
|
|
|
/UniDocCourier 24 Tf
|
2018-07-07 09:45:55 +10:00
|
|
|
(Hello World!)Tj
|
|
|
|
0 -10 Td
|
|
|
|
(Doink)Tj
|
|
|
|
ET
|
2018-03-22 13:01:04 +00:00
|
|
|
`
|
2018-07-07 09:45:55 +10:00
|
|
|
|
2018-03-22 13:01:04 +00:00
|
|
|
const testExpected1 = "Hello World!\nDoink"
|
|
|
|
|
|
|
|
func TestTextExtraction1(t *testing.T) {
|
|
|
|
e := Extractor{}
|
|
|
|
e.contents = testContents1
|
|
|
|
|
|
|
|
s, err := e.ExtractText()
|
|
|
|
if err != nil {
|
|
|
|
t.Errorf("Error extracting text: %v", err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
if s != testExpected1 {
|
2018-06-27 16:31:28 +10:00
|
|
|
t.Errorf("Text mismatch. Got %q. Expected %q", s, testExpected1)
|
2018-03-22 13:01:04 +00:00
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|