Skip to content

armgit / laya

Public Imported from GitHub
0

Non-autoregressive System 1 decision engine. Typed choice, score and yes/no decisions over any text in a single forward pass, in 100+ languages, with a router that picks the right checkpoint per request.

test(go): pin email helpers at non-ASCII space edges

Adeshina Lasisi7907db3a0dee
diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml
index 4481fcc9..0f6f45ef 100644
--- a/.github/workflows/go.yml
+++ b/.github/workflows/go.yml
@@ -129,11 +129,11 @@ jobs:
LAYA_GO_FIXTURES: ${{ github.workspace }}/.go-goldens
LAYA_CHECKPOINTS: ${{ github.workspace }}/laya-java/.work/checkpoints
run: go test -race -count=1 -json ./... > "$RUNNER_TEMP/go-test.json"
- # Exactly the measured count (1741 tests and subtests, on both Go versions): dropping a
+ # Exactly the measured count (1742 tests and subtests, on both Go versions): dropping a
# case fails here, and adding one means raising this number.
- name: No test was skipped
if: ${{ !cancelled() }}
- run: python laya-go/scripts/check_test_json.py "$RUNNER_TEMP/go-test.json" --min-tests 1741
+ run: python laya-go/scripts/check_test_json.py "$RUNNER_TEMP/go-test.json" --min-tests 1742
# go.mod declares go 1.22, so that is what a consumer may build with.
- name: Run the tests on the oldest supported Go
@@ -145,7 +145,7 @@ jobs:
run: go test -count=1 -json ./... > "$RUNNER_TEMP/go-test-oldest.json"
- name: No test was skipped on the oldest Go either
if: ${{ !cancelled() }}
- run: python laya-go/scripts/check_test_json.py "$RUNNER_TEMP/go-test-oldest.json" --min-tests 1741
+ run: python laya-go/scripts/check_test_json.py "$RUNNER_TEMP/go-test-oldest.json" --min-tests 1742
- uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
if: ${{ failure() }}
diff --git a/laya-go/email/email_test.go b/laya-go/email/email_test.go
index cdf1019f..1700c654 100644
--- a/laya-go/email/email_test.go
+++ b/laya-go/email/email_test.go
@@ -106,3 +106,17 @@ func TestLiteralSpacesAndDigitsStayASCII(t *testing.T) {
}
}
}
+
+// helpers whose edge is a non-ASCII space: the trailing colon guard and the quote-line test.
+func TestNonASCIISpaceAtLineEdges(t *testing.T) {
+ for body, want := range map[string]string{
+ "Hi\nI need help.\[email protected]> escreveu: \nold": "Hi\nI need help.",
+ "Hi\nI need help.\[email protected]> wrote:\u3000\nold": "Hi\nI need help.",
+ "Hi\nI need help.\n > quoted\nmore": "Hi\nI need help.\nmore",
+ "Hi\nI need help.\n\u3000>old\n\u3000>old2": "Hi\nI need help.",
+ } {
+ if got := CleanBody(body, DefaultMaxChars); got != want {
+ t.Errorf("CleanBody(%q) = %q, want %q", body, got, want)
+ }
+ }
+}
diff --git a/laya-go/email/view.go b/laya-go/email/view.go
index c38dee77..dee390f3 100644
--- a/laya-go/email/view.go
+++ b/laya-go/email/view.go
@@ -93,16 +93,14 @@ func viewOf(runes []rune) string {
}
// disclaimerViewOf is the view for the disclaimer pattern, which has no \s or \d of its own but
-// does use \b: a non-ASCII digit has to read as a word character there, and a non-ASCII space
-// as a non-word one that no literal matches.
+// does use \b: a non-ASCII digit has to read as a word character there. A non-ASCII space stays
+// the control byte it is, which is non-word and matches no literal.
func disclaimerViewOf(runes []rune) string {
out := []byte(viewOf(runes))
for i, c := range out {
switch c {
case nonASCIIDigit:
out[i] = '0'
- case nonASCIISpace:
- out[i] = 1
}
}
return string(out)