File: selection_test.go

package info (click to toggle)
peco 0.5.10-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 548 kB
  • sloc: makefile: 95
file content (32 lines) | stat: -rw-r--r-- 557 bytes parent folder | download | duplicates (2)
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
package peco

import (
	"testing"

	"github.com/peco/peco/line"
)

func TestSelection(t *testing.T) {
	s := NewSelection()

	var i uint64 = 0
	alice := line.NewRaw(i, "Alice", false)
	i++
	s.Add(alice)
	if s.Len() != 1 {
		t.Errorf("expected Len = 1, got %d", s.Len())
	}
	s.Add(line.NewRaw(i, "Bob", false))
	i++
	if s.Len() != 2 {
		t.Errorf("expected Len = 2, got %d", s.Len())
	}
	s.Add(alice)
	if s.Len() != 2 {
		t.Errorf("expected Len = 2, got %d", s.Len())
	}
	s.Remove(alice)
	if s.Len() != 1 {
		t.Errorf("expected Len = 1, got %d", s.Len())
	}
}