refactor: simplify test helper using stdlib strings.Contains

Addresses code review feedback from silverwind:
- Replace complex custom contains() implementation with strings.Contains
- Remove unnecessary containsMiddle() function
- Improves readability and maintainability by using standard library

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
James Pharaoh
2026-02-10 12:24:44 +00:00
parent 71dbc9d6da
commit b8630b5b9a

View File

@@ -1,6 +1,7 @@
package params
import (
"strings"
"testing"
)
@@ -103,14 +104,5 @@ func TestGetIndex(t *testing.T) {
}
func contains(s, substr string) bool {
return len(s) >= len(substr) && (s == substr || len(s) > len(substr) && (s[:len(substr)] == substr || s[len(s)-len(substr):] == substr || containsMiddle(s, substr)))
}
func containsMiddle(s, substr string) bool {
for i := 0; i <= len(s)-len(substr); i++ {
if s[i:i+len(substr)] == substr {
return true
}
}
return false
return strings.Contains(s, substr)
}