Skip to content

🧪 Scout: improve locale normalization unit tests#1141

Merged
cungminh2710 merged 1 commit into
mainfrom
scout/improve-locale-normalize-tests-645406899846358883
Jun 28, 2026
Merged

🧪 Scout: improve locale normalization unit tests#1141
cungminh2710 merged 1 commit into
mainfrom
scout/improve-locale-normalize-tests-645406899846358883

Conversation

@cungminh2710

Copy link
Copy Markdown
Contributor
  • 💡 What: Added comprehensive test cases to internal/i18n/locales/normalize_test.go.
  • 🎯 Why: To ensure NormalizeList robustly handles overlapping values, "first-seen" casing retention, and various whitespace characters (including non-breaking space).
  • 🧩 Scope: internal/i18n/locales/normalize_test.go
  • ✅ Verification: Ran go test ./internal/i18n/locales/...
  • 🛡️ Confidence: Prevents regressions in locale list parsing when dealing with messy input from configuration files or API responses.

PR created automatically by Jules for task 645406899846358883 started by @cungminh2710

Co-authored-by: cungminh2710 <8063319+cungminh2710@users.noreply.github.com>
@cungminh2710
cungminh2710 requested a review from MuenYu as a code owner June 28, 2026 22:48
@google-labs-jules

Copy link
Copy Markdown
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@vercel

vercel Bot commented Jun 28, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
hyperlocalise Ignored Ignored Jun 28, 2026 10:48pm

Request Review

@greptile-apps

greptile-apps Bot commented Jun 28, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

Adds four new table-driven test cases to TestNormalizeListSplitsTrimsAndDeduplicates covering deduplication across multiple input strings, first-encounter casing retention, ASCII whitespace variants (\t, \n, \r, \f, \v), and a non-breaking space (U+00A0) flanking a comma.

  • All new test expectations are correct and consistent with the NormalizeList implementation; in particular, Go's strings.TrimSpace calls unicode.IsSpace which does include U+00A0, so the NBSP test will pass.
  • The slices.Equal ordering assertion is appropriate because NormalizeList preserves first-seen insertion order, and every new test encodes that contract explicitly.

Confidence Score: 5/5

Test-only change with no production code modifications; safe to merge.

All four new test cases are correctly aligned with the NormalizeList implementation. The expected values were verified against the actual loop-and-deduplicate logic, including the U+00A0 case which is handled by Go's unicode-aware TrimSpace. No existing tests are modified and no production code is touched.

No files require special attention.

Important Files Changed

Filename Overview
internal/i18n/locales/normalize_test.go Adds four well-formed test cases; all expected values match the actual behaviour of NormalizeList and will pass without modification.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A["NormalizeList(values)"] --> B[Iterate each value string]
    B --> C["Find next comma via IndexByte"]
    C --> D["Extract part before comma"]
    D --> E["strings.TrimSpace(part)\n(handles ASCII ws + U+00A0)"]
    E --> F{Trimmed is empty?}
    F -- yes --> G[Skip]
    F -- no --> H["key = strings.ToLower(trimmed)"]
    H --> I{key already in seen?}
    I -- yes --> J[Skip – first-seen casing wins]
    I -- no --> K["Add trimmed to result\nAdd key to seen map"]
    K --> L{More commas?}
    G --> L
    J --> L
    L -- yes --> C
    L -- no --> M[Next value string]
    M --> B
    B --> N[Return normalized slice]
Loading
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
flowchart TD
    A["NormalizeList(values)"] --> B[Iterate each value string]
    B --> C["Find next comma via IndexByte"]
    C --> D["Extract part before comma"]
    D --> E["strings.TrimSpace(part)\n(handles ASCII ws + U+00A0)"]
    E --> F{Trimmed is empty?}
    F -- yes --> G[Skip]
    F -- no --> H["key = strings.ToLower(trimmed)"]
    H --> I{key already in seen?}
    I -- yes --> J[Skip – first-seen casing wins]
    I -- no --> K["Add trimmed to result\nAdd key to seen map"]
    K --> L{More commas?}
    G --> L
    J --> L
    L -- yes --> C
    L -- no --> M[Next value string]
    M --> B
    B --> N[Return normalized slice]
Loading

Reviews (1): Last reviewed commit: "🧪 Scout: improve locale normalization u..." | Re-trigger Greptile

@cungminh2710
cungminh2710 merged commit 6b0a2ec into main Jun 28, 2026
11 checks passed
@cungminh2710
cungminh2710 deleted the scout/improve-locale-normalize-tests-645406899846358883 branch June 28, 2026 23:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant