1// This program is free software: you can redistribute it and/or modify 2// it under the terms of the GNU General Public License as published by 3// the Free Software Foundation, either version 3 of the License, or 4// (at your option) any later version. 5// 6// This program is distributed in the hope that it will be useful, 7// but WITHOUT ANY WARRANTY; without even the implied warranty of 8// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 9// GNU General Public License for more details.10//11// You should have received a copy of the GNU General Public License12// along with this program. If not, see <http://www.gnu.org/licenses/>.13//14// This is a slightly modified version of 'encoding/xml/read_test.go'.15// Copyright 2009 The Go Authors. All rights reserved. Use of this16// source code is governed by a BSD-style license that can be found in17// the LICENSE file.1819package feedparser2021import (22 "net/http"23 "testing"24)2526type testpair struct {27 URL string28 Type string29}3031func TestParse(t *testing.T) {32 tests := []testpair{33 {"http://cyber.law.harvard.edu/rss/examples/rss2sample.xml", "rss"},34 {"http://www.heise.de/developer/rss/news-atom.xml", "atom"},35 {"http://blog.case.edu/news/feed.atom", "atom"},36 }3738 for _, test := range tests {39 resp, err := http.Get(test.URL)40 if err != nil {41 t.Fatal(err)42 }4344 reader := resp.Body45 defer reader.Close()4647 feed, err := Parse(reader)48 if err != nil {49 t.Fatal(err)50 }5152 if feed.Type != test.Type {53 t.Fatalf("Expected %q - got %q", test.Type, feed.Type)54 }55 }56}