chore: lint

This commit is contained in:
Kujtim Hoxha
2025-07-24 22:21:34 +02:00
parent 4614a6cdcf
commit 5ba54bc7ee
3 changed files with 32 additions and 33 deletions

View File

@@ -98,7 +98,7 @@ func TestSlice(t *testing.T) {
original := []int{1, 2, 3}
s := NewSliceFrom(original)
assert.Equal(t, 3, s.Len())
// Verify it's a copy, not a reference
original[0] = 999
val, ok := s.Get(0)
@@ -110,12 +110,12 @@ func TestSlice(t *testing.T) {
s := NewSlice[string]()
s.Append("hello")
s.Append("world")
assert.Equal(t, 2, s.Len())
val, ok := s.Get(0)
require.True(t, ok)
assert.Equal(t, "hello", val)
val, ok = s.Get(1)
require.True(t, ok)
assert.Equal(t, "world", val)
@@ -125,12 +125,12 @@ func TestSlice(t *testing.T) {
s := NewSlice[string]()
s.Append("world")
s.Prepend("hello")
assert.Equal(t, 2, s.Len())
val, ok := s.Get(0)
require.True(t, ok)
assert.Equal(t, "hello", val)
val, ok = s.Get(1)
require.True(t, ok)
assert.Equal(t, "world", val)
@@ -138,21 +138,21 @@ func TestSlice(t *testing.T) {
t.Run("Delete", func(t *testing.T) {
s := NewSliceFrom([]int{1, 2, 3, 4, 5})
// Delete middle element
ok := s.Delete(2)
assert.True(t, ok)
assert.Equal(t, 4, s.Len())
expected := []int{1, 2, 4, 5}
actual := s.Slice()
assert.Equal(t, expected, actual)
// Delete out of bounds
ok = s.Delete(10)
assert.False(t, ok)
assert.Equal(t, 4, s.Len())
// Delete negative index
ok = s.Delete(-1)
assert.False(t, ok)
@@ -161,15 +161,15 @@ func TestSlice(t *testing.T) {
t.Run("Get", func(t *testing.T) {
s := NewSliceFrom([]string{"a", "b", "c"})
val, ok := s.Get(1)
require.True(t, ok)
assert.Equal(t, "b", val)
// Out of bounds
_, ok = s.Get(10)
assert.False(t, ok)
// Negative index
_, ok = s.Get(-1)
assert.False(t, ok)
@@ -177,18 +177,18 @@ func TestSlice(t *testing.T) {
t.Run("Set", func(t *testing.T) {
s := NewSliceFrom([]string{"a", "b", "c"})
ok := s.Set(1, "modified")
assert.True(t, ok)
val, ok := s.Get(1)
require.True(t, ok)
assert.Equal(t, "modified", val)
// Out of bounds
ok = s.Set(10, "invalid")
assert.False(t, ok)
// Negative index
ok = s.Set(-1, "invalid")
assert.False(t, ok)
@@ -198,13 +198,13 @@ func TestSlice(t *testing.T) {
s := NewSlice[int]()
s.Append(1)
s.Append(2)
newItems := []int{10, 20, 30}
s.SetSlice(newItems)
assert.Equal(t, 3, s.Len())
assert.Equal(t, newItems, s.Slice())
// Verify it's a copy
newItems[0] = 999
val, ok := s.Get(0)
@@ -215,7 +215,7 @@ func TestSlice(t *testing.T) {
t.Run("Clear", func(t *testing.T) {
s := NewSliceFrom([]int{1, 2, 3})
assert.Equal(t, 3, s.Len())
s.Clear()
assert.Equal(t, 0, s.Len())
})
@@ -223,10 +223,10 @@ func TestSlice(t *testing.T) {
t.Run("Slice", func(t *testing.T) {
original := []int{1, 2, 3}
s := NewSliceFrom(original)
copy := s.Slice()
assert.Equal(t, original, copy)
// Verify it's a copy
copy[0] = 999
val, ok := s.Get(0)
@@ -236,25 +236,25 @@ func TestSlice(t *testing.T) {
t.Run("Seq", func(t *testing.T) {
s := NewSliceFrom([]int{1, 2, 3})
var result []int
for v := range s.Seq() {
result = append(result, v)
}
assert.Equal(t, []int{1, 2, 3}, result)
})
t.Run("SeqWithIndex", func(t *testing.T) {
s := NewSliceFrom([]string{"a", "b", "c"})
var indices []int
var values []string
for i, v := range s.SeqWithIndex() {
indices = append(indices, i)
values = append(values, v)
}
assert.Equal(t, []int{0, 1, 2}, indices)
assert.Equal(t, []string{"a", "b", "c"}, values)
})
@@ -263,9 +263,9 @@ func TestSlice(t *testing.T) {
s := NewSlice[int]()
const numGoroutines = 100
const itemsPerGoroutine = 10
var wg sync.WaitGroup
// Concurrent appends
for i := 0; i < numGoroutines; i++ {
wg.Add(1)
@@ -276,7 +276,7 @@ func TestSlice(t *testing.T) {
}
}(i)
}
// Concurrent reads
for i := 0; i < numGoroutines; i++ {
wg.Add(1)
@@ -287,9 +287,9 @@ func TestSlice(t *testing.T) {
}
}()
}
wg.Wait()
// Should have all items
assert.Equal(t, numGoroutines*itemsPerGoroutine, s.Len())
})

View File

@@ -265,7 +265,7 @@ func (f *filterableList[T]) Filter(query string) tea.Cmd {
matchedItems = append(matchedItems, item)
}
if f.list.direction == DirectionBackward {
if f.direction == DirectionBackward {
slices.Reverse(matchedItems)
}

View File

@@ -846,7 +846,6 @@ func (l *list[T]) SelectItemAbove() tea.Cmd {
cmds = append(cmds, cmd)
}
}
}
item, ok := l.items.Get(newIndex)
if !ok {