From c49df0b27b6aaa18b7626093f89449727af40702 Mon Sep 17 00:00:00 2001 From: Nikolas de Hor Date: Tue, 3 Mar 2026 01:00:59 -0300 Subject: [PATCH] fix(agent): simplify test assertions per review feedback Replace custom eqFoldSlice/containsLower byte-level implementation with standard strings.Contains(strings.ToLower()) for consistency with the rest of the codebase. --- pkg/agent/errors_test.go | 35 +++-------------------------------- 1 file changed, 3 insertions(+), 32 deletions(-) diff --git a/pkg/agent/errors_test.go b/pkg/agent/errors_test.go index c0b127e34..f55fe178b 100644 --- a/pkg/agent/errors_test.go +++ b/pkg/agent/errors_test.go @@ -3,6 +3,7 @@ package agent import ( "errors" "fmt" + "strings" "testing" "github.com/sipeed/picoclaw/pkg/providers" @@ -205,37 +206,7 @@ func TestReasonToUserMessage_AllReasons(t *testing.T) { } } -// contains is a case-insensitive helper for test assertions. +// contains is a case-insensitive substring check for test assertions. func contains(s, substr string) bool { - return len(s) >= len(substr) && - len(substr) > 0 && - (s == substr || containsLower(s, substr)) -} - -func containsLower(s, substr string) bool { - for i := 0; i <= len(s)-len(substr); i++ { - if eqFoldSlice(s[i:i+len(substr)], substr) { - return true - } - } - return false -} - -func eqFoldSlice(a, b string) bool { - if len(a) != len(b) { - return false - } - for i := 0; i < len(a); i++ { - ca, cb := a[i], b[i] - if ca >= 'A' && ca <= 'Z' { - ca += 'a' - 'A' - } - if cb >= 'A' && cb <= 'Z' { - cb += 'a' - 'A' - } - if ca != cb { - return false - } - } - return true + return strings.Contains(strings.ToLower(s), strings.ToLower(substr)) }