| 1 | package main |
| 2 | |
| 3 | import ( |
| 4 | "reflect" |
| 5 | "sort" |
| 6 | "testing" |
| 7 | ) |
| 8 | |
| 9 | func TestUnifiedBacklog(t *testing.T) { |
| 10 | b := NewUnifiedBacklog() |
| 11 | b.Add("foo") |
| 12 | b.Add("bar") |
| 13 | if got, want := b.Next(), "foo"; got != want { |
| 14 | t.Errorf("Next(): got %q; want %q", got, want) |
| 15 | } |
| 16 | if got := b.RemoveOne(); !got { |
| 17 | t.Error("RemoveOne(): got !empty") |
| 18 | } |
| 19 | } |
| 20 | |
| 21 | func TestUniqueFilesBacklog(t *testing.T) { |
| 22 | b := NewUniqueFilesBacklog() |
| 23 | b.Add("foo") |
| 24 | b.Add("bar") |
| 25 | s := []string{b.Next()} |
| 26 | if got := b.RemoveOne(); got { |
| 27 | t.Error("RemoveOne(): got empty") |
| 28 | } |
| 29 | s = append(s, b.Next()) |
| 30 | if got := b.RemoveOne(); !got { |
| 31 | t.Error("RemoveOne(): got !empty") |
| 32 | } |
| 33 | sort.Strings(s) |
| 34 | if want := []string{"bar", "foo"}; !reflect.DeepEqual(s, want) { |
| 35 | t.Errorf("Next() result set: got %v; want %v", s, want) |
| 36 | } |
| 37 | } |