From 28d37fe0800c2f8dcc556169978c144fc08fd3b9 Mon Sep 17 00:00:00 2001 From: luozhixiong Date: Fri, 29 May 2026 21:00:50 +0800 Subject: [PATCH] test(i18n): assert exact Codes() slice instead of len + first entry Per review feedback: len==3 + codes[0]==zh_cn still passes if Codes() returns duplicates or drops en_us/ja_jp. Assert the full ordered slice to lock the user-facing ordering contract. --- internal/i18n/lang_test.go | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/internal/i18n/lang_test.go b/internal/i18n/lang_test.go index 6dacb766..cb9d81fd 100644 --- a/internal/i18n/lang_test.go +++ b/internal/i18n/lang_test.go @@ -3,7 +3,10 @@ package i18n -import "testing" +import ( + "slices" + "testing" +) func TestParse(t *testing.T) { tests := []struct { @@ -84,11 +87,9 @@ func TestBase(t *testing.T) { func TestCodes(t *testing.T) { codes := Codes() - if len(codes) != 3 { - t.Fatalf("len(Codes()) = %d, want 3", len(codes)) - } - if codes[0] != "zh_cn" { - t.Errorf("Codes()[0] = %q, want %q (catalog order)", codes[0], "zh_cn") + want := []string{"zh_cn", "en_us", "ja_jp"} + if !slices.Equal(codes, want) { + t.Fatalf("Codes() = %v, want %v", codes, want) } // Every code must round-trip through Parse to itself (canonical). for _, c := range codes {