-
Notifications
You must be signed in to change notification settings - Fork 210
/
feed_test.go
50 lines (44 loc) · 860 Bytes
/
feed_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package gofeed_test
import (
"sort"
"testing"
"time"
"github.com/mmcdole/gofeed"
)
func TestFeedSort(t *testing.T) {
oldestItem := &gofeed.Item{
PublishedParsed: &[]time.Time{time.Unix(0, 0)}[0],
}
inbetweenItem := &gofeed.Item{
PublishedParsed: &[]time.Time{time.Unix(1, 0)}[0],
}
newestItem := &gofeed.Item{
PublishedParsed: &[]time.Time{time.Unix(2, 0)}[0],
}
feed := gofeed.Feed{
Items: []*gofeed.Item{
newestItem,
oldestItem,
inbetweenItem,
},
}
expected := gofeed.Feed{
Items: []*gofeed.Item{
oldestItem,
inbetweenItem,
newestItem,
},
}
sort.Sort(feed)
for i, item := range feed.Items {
if !item.PublishedParsed.Equal(
*expected.Items[i].PublishedParsed,
) {
t.Errorf(
"Item PublishedParsed = %s; want %s",
item.PublishedParsed,
expected.Items[i].PublishedParsed,
)
}
}
}