@@ -549,98 +549,3 @@ var selectorTests = []selectorTest{
549549 },
550550 },
551551}
552-
553- type PieceAttrTest struct {
554- HTML , selector string
555- results []string
556- piece OutputStyleMap
557- }
558-
559- var PieceAttrTests = []PieceAttrTest {
560- {
561- `<ul>
562- <li><a id="a1" href="http://www.google.com/finance"/>
563- <li><a id="a2" href="http://finance.yahoo.com/"/>
564- <li><a id="a3" href="https://www.google.com/news"></a>
565- <li><a id="a4" href="http://news.yahoo.com"/>
566- </ul>` ,
567- `li` ,
568- []string {
569- `id,` ,
570- `a1,` ,
571- `a2,` ,
572- `a3,` ,
573- `a4,` ,
574- },
575- OutputStyleMap {
576- []string {"id" },
577- map [string ]string {"id" : "a" },
578- map [string ]OutputStyle {"id" : OutputStyleATTR },
579- map [string ]string {"id" : "id" },
580- },
581- },
582- {
583- `<ul>
584- <li><a id="a1" href="http://www.google.com/finance"/>
585- <li><a id="a2" href="http://finance.yahoo.com/"/>
586- <li><a id="a3" href="https://www.google.com/news"></a>
587- <li><a id="a4" href="http://news.yahoo.com"/>
588- </ul>` ,
589- `li` ,
590- []string {
591- `href2,` ,
592- `,` ,
593- `,` ,
594- `,` ,
595- `,` ,
596- },
597- OutputStyleMap {
598- []string {"href2" },
599- map [string ]string {"href2" : "a" },
600- map [string ]OutputStyle {"href2" : OutputStyleATTR },
601- map [string ]string {"href2" : "href2" },
602- },
603- },
604- {
605- `<ul>
606- <li><a id="a1" href="http://www.google.com/finance"/>
607- <li><a id="a2" href="http://finance.yahoo.com/"/>
608- <li><a id="a3" href="https://www.google.com/news"></a>
609- <li><a id="a4" href="http://news.yahoo.com"/>
610- </ul>` ,
611- `li` ,
612- []string {
613- `href,` ,
614- `http://www.google.com/finance,` ,
615- `http://finance.yahoo.com/,` ,
616- `https://www.google.com/news,` ,
617- `http://news.yahoo.com,` ,
618- },
619- OutputStyleMap {
620- []string {"href" },
621- map [string ]string {"href" : "a" },
622- map [string ]OutputStyle {"href" : OutputStyleATTR },
623- map [string ]string {"href" : "href" },
624- },
625- },
626- }
627-
628- func TestPieceAttr (t * testing.T ) {
629- for _ , test := range PieceAttrTests {
630- buf := bytes .NewBufferString ("" )
631- Opts .CSS , Opts .Piece , Opts .Deli ,
632- Opts .WrapHTML , Opts .TextOut , Opts .TextRaw , Opts .Quiet =
633- []string {test .selector }, test .piece , "," ,
634- false , false , false , false
635- Cascadia (strings .NewReader (test .HTML ), buf , Opts )
636- got := buf .String ()
637- if len (got ) == 0 && len (test .results ) == 0 {
638- // correct
639- continue
640- }
641- want := strings .Join (test .results , "\n " ) + "\n "
642- if got != want {
643- t .Errorf ("wanted %s, got %s instead" , want , got )
644- }
645- }
646- }
0 commit comments