add test to detect a   from a call to Text()

This commit is contained in:
Martin Angers
2014-04-25 15:28:38 -04:00
parent 308a3c0fda
commit cf82003f7e
2 changed files with 13 additions and 2 deletions
+13
View File
@@ -61,3 +61,16 @@ func TestHtml(t *testing.T) {
}
}
}
func TestNbsp(t *testing.T) {
src := `<p>Some&nbsp;text</p>`
d, err := NewDocumentFromReader(strings.NewReader(src))
if err != nil {
t.Fatal(err)
}
txt := d.Find("p").Text()
ix := strings.Index(txt, "\u00a0")
if ix != 4 {
t.Errorf("expected a non-breaking space at index 4, got %d", ix)
}
}
-2
View File
@@ -492,8 +492,6 @@ func getChildrenWithSiblingType(parent *html.Node, st siblingType, skipNode *htm
// Not a valid node, try again from this one
cur = ret
}
// For Go 1.0 compatibility
panic("Unreachable code reached.")
}
for c := iter(nil); c != nil; c = iter(c) {