File: backlog_test.go

package info (click to toggle)
reflex 0.3.1-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 164 kB
  • sloc: makefile: 4
file content (37 lines) | stat: -rw-r--r-- 768 bytes parent folder | download | duplicates (3)
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
package main

import (
	"reflect"
	"sort"
	"testing"
)

func TestUnifiedBacklog(t *testing.T) {
	b := NewUnifiedBacklog()
	b.Add("foo")
	b.Add("bar")
	if got, want := b.Next(), "foo"; got != want {
		t.Errorf("Next(): got %q; want %q", got, want)
	}
	if got := b.RemoveOne(); !got {
		t.Error("RemoveOne(): got !empty")
	}
}

func TestUniqueFilesBacklog(t *testing.T) {
	b := NewUniqueFilesBacklog()
	b.Add("foo")
	b.Add("bar")
	s := []string{b.Next()}
	if got := b.RemoveOne(); got {
		t.Error("RemoveOne(): got empty")
	}
	s = append(s, b.Next())
	if got := b.RemoveOne(); !got {
		t.Error("RemoveOne(): got !empty")
	}
	sort.Strings(s)
	if want := []string{"bar", "foo"}; !reflect.DeepEqual(s, want) {
		t.Errorf("Next() result set: got %v; want %v", s, want)
	}
}