package x2j
import (
"fmt"
"testing"
)
var doc01 = `
William H. Gaddis
The Recognitions
One of the great seminal American novels of the 20th century.
Austin Tappan Wright
Islandia
An example of earlier 20th century American utopian fiction.
John Hawkes
The Beetle Leg
A lyrical novel about the construction of Ft. Peck Dam in Montana.
T.E.
Porter
King's Day
A magical novella.
`
var doc02 = `
William H. Gaddis
The Recognitions
One of the great seminal American novels of the 20th century.
JR
Won the National Book Award
John Hawkes
The Beetle Leg
The Blood Oranges
`
// the basic demo/test case - a small bibliography with mixed element types
func TestPathsForKey(t *testing.T) {
fmt.Println("\n================================ x2jfindPath_test.go")
fmt.Println("\n=============== TestPathsForKey ...")
fmt.Println("\nPathsForKey... doc01#author")
m, _ := DocToMap(doc01)
ss := PathsForKey(m, "author")
fmt.Println("ss:", ss)
fmt.Println("\nPathsForKey... doc01#books")
// m, _ := DocToMap(doc01)
ss = PathsForKey(m, "books")
fmt.Println("ss:", ss)
fmt.Println("\nPathsForKey...doc02#book")
m, _ = DocToMap(doc02)
ss = PathsForKey(m, "book")
fmt.Println("ss:", ss)
fmt.Println("\nPathForKeyShortest...doc02#book")
m, _ = DocToMap(doc02)
s := PathForKeyShortest(m, "book")
fmt.Println("s:", s)
}
// the basic demo/test case - a small bibliography with mixed element types
func TestPathsForTag(t *testing.T) {
fmt.Println("\n=============== TestPathsForTag ...")
fmt.Println("\nPathsForTag... doc01#author")
ss, _ := PathsForTag(doc01, "author")
fmt.Println("ss:", ss)
fmt.Println("\nPathsForTag... doc01#books")
ss, _ = PathsForTag(doc01, "books")
fmt.Println("ss:", ss)
fmt.Println("\nPathsForTag...doc02#book")
ss, _ = PathsForTag(doc02, "book")
fmt.Println("ss:", ss)
fmt.Println("\nPathForTagShortest...doc02#book")
s, _ := PathForTagShortest(doc02, "book")
fmt.Println("s:", s)
}