mirror of
https://github.com/zoriya/bubbles.git
synced 2026-08-05 04:36:07 +00:00
chore: run modernize
This commit is contained in:
@@ -121,5 +121,5 @@ type HInt int
|
||||
|
||||
// Hash is a method that returns the hash of the integer.
|
||||
func (h HInt) Hash() string {
|
||||
return fmt.Sprintf("%x", sha256.Sum256([]byte(fmt.Sprintf("%d", h))))
|
||||
return fmt.Sprintf("%x", sha256.Sum256(fmt.Appendf(nil, "%d", h)))
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import (
|
||||
"encoding/binary"
|
||||
"fmt"
|
||||
"os"
|
||||
"slices"
|
||||
"testing"
|
||||
)
|
||||
|
||||
@@ -17,8 +18,8 @@ const (
|
||||
type cacheAction struct {
|
||||
actionType actionType
|
||||
key HString
|
||||
value interface{}
|
||||
expectedValue interface{}
|
||||
value any
|
||||
expectedValue any
|
||||
}
|
||||
|
||||
type testCase struct {
|
||||
@@ -121,7 +122,7 @@ func TestCache(t *testing.T) {
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
cache := NewMemoCache[HString, interface{}](tt.capacity)
|
||||
cache := NewMemoCache[HString, any](tt.capacity)
|
||||
for _, action := range tt.actions {
|
||||
switch action.actionType {
|
||||
case set:
|
||||
@@ -174,7 +175,7 @@ func FuzzCache(f *testing.F) {
|
||||
// If the key is already in accessOrder, we remove it and append it again later
|
||||
for index, accessedKey := range accessOrder {
|
||||
if accessedKey == key {
|
||||
accessOrder = append(accessOrder[:index], accessOrder[index+1:]...)
|
||||
accessOrder = slices.Delete(accessOrder, index, index+1)
|
||||
break
|
||||
}
|
||||
}
|
||||
@@ -206,7 +207,7 @@ func FuzzCache(f *testing.F) {
|
||||
// If the key was accessed, move it to the end of the accessOrder to represent recent use
|
||||
for index, accessedKey := range accessOrder {
|
||||
if accessedKey == key {
|
||||
accessOrder = append(accessOrder[:index], accessOrder[index+1:]...)
|
||||
accessOrder = slices.Delete(accessOrder, index, index+1)
|
||||
accessOrder = append(accessOrder, key)
|
||||
break
|
||||
}
|
||||
|
||||
@@ -61,7 +61,7 @@ func (s *sanitizer) Sanitize(runes []rune) []rune {
|
||||
// is smaller or equal to the input.
|
||||
copied := false
|
||||
|
||||
for src := 0; src < len(runes); src++ {
|
||||
for src := range runes {
|
||||
r := runes[src]
|
||||
switch {
|
||||
case r == utf8.RuneError:
|
||||
|
||||
@@ -185,7 +185,7 @@ func (m Model) View() string {
|
||||
|
||||
func (m Model) dotsView() string {
|
||||
var s string
|
||||
for i := 0; i < m.TotalPages; i++ {
|
||||
for i := range m.TotalPages {
|
||||
if i == m.Page {
|
||||
s += m.ActiveDot
|
||||
continue
|
||||
|
||||
@@ -295,7 +295,7 @@ func (m Model) barView(b *strings.Builder, percent float64, textWidth int) {
|
||||
|
||||
if m.useRamp {
|
||||
// Gradient fill
|
||||
for i := 0; i < fw; i++ {
|
||||
for i := range fw {
|
||||
if fw == 1 {
|
||||
// this is up for debate: in a gradient of width=1, should the
|
||||
// single character rendered be the first color, the last color
|
||||
|
||||
@@ -374,7 +374,7 @@ func TestRightOverscroll(t *testing.T) {
|
||||
m := New(WithHeight(5), WithWidth(len(content)+1))
|
||||
m.SetContent(content)
|
||||
|
||||
for i := 0; i < 10; i++ {
|
||||
for range 10 {
|
||||
m.ScrollRight(m.horizontalStep)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user