mirror of
https://github.com/unidoc/unipdf.git
synced 2025-04-26 13:48:55 +08:00
48 lines
893 B
Go
48 lines
893 B
Go
/*
|
|
* This file is subject to the terms and conditions defined in
|
|
* file 'LICENSE.md', which is part of this source code package.
|
|
*/
|
|
|
|
package fdf
|
|
|
|
import (
|
|
"bytes"
|
|
"testing"
|
|
)
|
|
|
|
func TestFDFDataLoading(t *testing.T) {
|
|
r := bytes.NewReader([]byte(fdfExample1))
|
|
|
|
fdfData, err := Load(r)
|
|
if err != nil {
|
|
t.Fatalf("Error: %v", err)
|
|
}
|
|
|
|
fvalMap, err := fdfData.FieldValues()
|
|
if err != nil {
|
|
t.Fatalf("Error: %v", err)
|
|
}
|
|
|
|
expectedVals := []struct {
|
|
Name string
|
|
Val string
|
|
}{
|
|
{"Field1", "Test1"},
|
|
{"Field2", "Test2"},
|
|
}
|
|
|
|
if len(fvalMap) != len(expectedVals) {
|
|
t.Fatalf("len(fvalMap) != %d (got %d)", len(expectedVals), len(fvalMap))
|
|
}
|
|
|
|
for _, exp := range expectedVals {
|
|
val, has := fvalMap[exp.Name]
|
|
if !has {
|
|
t.Fatalf("%s missing from map", exp.Name)
|
|
}
|
|
if val.String() != exp.Val {
|
|
t.Fatalf("val.String() != %s (got %s)", exp.Val, val.String())
|
|
}
|
|
}
|
|
}
|