add test for issue #26, cannot reproduce

This commit is contained in:
Martin Angers
2013-11-12 12:34:21 -05:00
parent aa0519aedd
commit d247f5b79a
+22
View File
@@ -1,6 +1,7 @@
package goquery
import (
"strings"
"testing"
)
@@ -673,3 +674,24 @@ func TestClosestNodesRollback(t *testing.T) {
sel2 := sel.ClosestNodes(Doc().Find(".pvk-content").Nodes...).End()
AssertEqual(t, sel, sel2)
}
func TestIssue26(t *testing.T) {
img1 := `<img src="assets/images/gallery/thumb-1.jpg" alt="150x150" />`
img2 := `<img alt="150x150" src="assets/images/gallery/thumb-1.jpg" />`
cases := []struct {
s string
l int
}{
{s: img1 + img2, l: 2},
{s: img1, l: 1},
{s: img2, l: 1},
}
for _, c := range cases {
doc, err := NewDocumentFromReader(strings.NewReader(c.s))
if err != nil {
t.Fatal(err)
}
sel := doc.Find("img[src]")
AssertLength(t, sel.Nodes, c.l)
}
}