From 93dfe3798e03e74766b229418cde364a5ef29ae9 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Mon, 16 Mar 2026 03:54:28 +0200 Subject: Replace custom stringsTrim with strings.TrimSpace Remove duplicate stringsTrim implementations in stats and tmux packages, replacing all call sites with the standard library strings.TrimSpace. Co-Authored-By: Claude Opus 4.6 --- internal/stats/stats_test.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'internal/stats/stats_test.go') diff --git a/internal/stats/stats_test.go b/internal/stats/stats_test.go index 75c1c5b..45f9e2a 100644 --- a/internal/stats/stats_test.go +++ b/internal/stats/stats_test.go @@ -5,6 +5,7 @@ import ( "encoding/json" "os" "path/filepath" + "strings" "sync" "testing" "time" @@ -102,7 +103,7 @@ func TestCacheDir_FallbackHome(t *testing.T) { } // TestCacheDir_WhitespaceXDG covers the branch where XDG_CACHE_HOME contains -// only whitespace, which stringsTrim reduces to "" so the fallback is used. +// only whitespace, which strings.TrimSpace reduces to "" so the fallback is used. func TestCacheDir_WhitespaceXDG(t *testing.T) { t.Setenv("XDG_CACHE_HOME", " \t\n ") got, err := CacheDir() @@ -140,7 +141,7 @@ func TestSetWindow_ClampHigh(t *testing.T) { // has no leading or trailing whitespace, so the original string is returned. func TestStringsTrim_NoTrimNeeded(t *testing.T) { in := "hello" - got := stringsTrim(in) + got := strings.TrimSpace(in) if got != "hello" { t.Fatalf("expected %q, got %q", "hello", got) } @@ -148,7 +149,7 @@ func TestStringsTrim_NoTrimNeeded(t *testing.T) { // TestStringsTrim_AllWhitespace covers trimming a string that is entirely whitespace. func TestStringsTrim_AllWhitespace(t *testing.T) { - got := stringsTrim(" \t\r\n ") + got := strings.TrimSpace(" \t\r\n ") if got != "" { t.Fatalf("expected empty, got %q", got) } @@ -156,7 +157,7 @@ func TestStringsTrim_AllWhitespace(t *testing.T) { // TestStringsTrim_LeadingAndTrailing covers trimming from both ends. func TestStringsTrim_LeadingAndTrailing(t *testing.T) { - got := stringsTrim(" abc ") + got := strings.TrimSpace(" abc ") if got != "abc" { t.Fatalf("expected %q, got %q", "abc", got) } @@ -164,7 +165,7 @@ func TestStringsTrim_LeadingAndTrailing(t *testing.T) { // TestStringsTrim_Empty covers the empty string edge case. func TestStringsTrim_Empty(t *testing.T) { - got := stringsTrim("") + got := strings.TrimSpace("") if got != "" { t.Fatalf("expected empty, got %q", got) } -- cgit v1.2.3