mirror of
https://github.com/sajari/docconv.git
synced 2026-10-16 21:21:59 +08:00
93312f47fc
- Some methods have been changed to return an error as their last argument - Log calls inside various functions have been removed - Use a v1 tag if you need the previous signature
39 lines
881 B
Go
39 lines
881 B
Go
package rtf_test
|
|
|
|
import (
|
|
"bytes"
|
|
"os"
|
|
"strings"
|
|
"testing"
|
|
|
|
"code.sajari.com/docconv/v2"
|
|
)
|
|
|
|
func TestConvertRTF(t *testing.T) {
|
|
data, err := os.ReadFile("testdata/test.rtf")
|
|
if err != nil {
|
|
t.Fatalf("got error %v, want nil", err)
|
|
}
|
|
res, _, err := docconv.ConvertRTF(bytes.NewReader(data))
|
|
if err != nil {
|
|
t.Fatalf("got error %v, want nil", err)
|
|
}
|
|
lines := strings.Split(res, "\n")[2:]
|
|
line, expectedLine := lines[0], "hello world"
|
|
if line != expectedLine {
|
|
t.Fatalf("got %s, want %s", line, expectedLine)
|
|
}
|
|
line, expectedLine = lines[1], "helo"
|
|
if line != expectedLine {
|
|
t.Fatalf("got %s, want %s", line, expectedLine)
|
|
}
|
|
line, expectedLine = lines[2], ""
|
|
if line != expectedLine {
|
|
t.Fatalf("got %s, want %s", line, expectedLine)
|
|
}
|
|
line, expectedLine = lines[3], "1"
|
|
if line != expectedLine {
|
|
t.Fatalf("got %s, want %s", line, expectedLine)
|
|
}
|
|
}
|