From a650a2c9e95d18a108a3a37e52125716e836aef2 Mon Sep 17 00:00:00 2001 From: Ian Davis Date: Thu, 7 Jun 2012 01:09:36 +0100 Subject: [PATCH] Parses multiple values for a property --- microdata_test.go | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/microdata_test.go b/microdata_test.go index ba11e5a..87d0fcb 100644 --- a/microdata_test.go +++ b/microdata_test.go @@ -251,7 +251,7 @@ func TestReadTwoValues(t *testing.T) { item := ReadOneItem(html, t) 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" { t.Errorf("Property value 'Lemon sorbet' not found") @@ -262,3 +262,26 @@ func TestReadTwoValues(t *testing.T) { } + +func TestReadTwoPropertiesOneValue(t *testing.T) { + html := ` +
+ orange +
` + + 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'") + } + + +}