Пример #1
0
func TestFindMissingMessages(t *testing.T) {
	RegisterTestingT(t)
	overviews := []nntp.MessageOverview{}
	missed := findMissingMessages(1, 10, overviews)
	Expect(missed).To(HaveLen(10))
	Expect(missed.Contains(types.MessageNumber(1))).To(BeTrue())
	Expect(missed.Contains(types.MessageNumber(10))).To(BeTrue())
}
Пример #2
0
// Given a start and end message number find the
func findMissingMessages(begin, end int64, overviews []nntp.MessageOverview) types.MessageNumberSet {
	fullset := types.NewMessageNumberSet()
	messages := types.NewMessageNumberSet()
	for _, o := range overviews {
		messages.Add(types.MessageNumber(o.MessageNumber))
	}
	for i := begin; i <= end; i++ {
		fullset.Add(types.MessageNumber(i))
	}
	missed := fullset.Difference(messages)
	return missed
}