Parses multiple values for a property

pull/2/head
Ian Davis 2012-06-07 01:09:36 +01:00
parent d6e293d40a
commit a650a2c9e9
1 changed files with 24 additions and 1 deletions

View File

@ -251,7 +251,7 @@ func TestReadTwoValues(t *testing.T) {
item := ReadOneItem(html, t) item := ReadOneItem(html, t)
if len(item.properties["flavor"]) != 2 { if len(item.properties["flavor"]) != 2 {
t.Errorf("Expecting 2 items but got %d",len(item.properties["flavor"]) ) t.Errorf("Expecting 2 values but got %d",len(item.properties["flavor"]) )
} }
if item.properties["flavor"][0].(string) != "Lemon sorbet" { if item.properties["flavor"][0].(string) != "Lemon sorbet" {
t.Errorf("Property value 'Lemon sorbet' not found") t.Errorf("Property value 'Lemon sorbet' not found")
@ -262,3 +262,26 @@ func TestReadTwoValues(t *testing.T) {
} }
func TestReadTwoPropertiesOneValue(t *testing.T) {
html := `
<div itemscope>
<span itemprop="favorite-color favorite-fruit">orange</span>
</div>`
item := ReadOneItem(html, t)
if len(item.properties["favorite-color"]) != 2 {
t.Errorf("Expecting 1 value but got %d",len(item.properties["favorite-color"]) )
}
if len(item.properties["favorite-fruit"]) != 2 {
t.Errorf("Expecting 1 value but got %d",len(item.properties["favorite-fruit"]) )
}
if item.properties["favorite-color"][0].(string) != "orange" {
t.Errorf("Property value 'orange' not found for 'favorite-color'")
}
if item.properties["favorite-fruit"][0].(string) != "orange" {
t.Errorf("Property value 'orange' not found for 'favorite-fruit'")
}
}