Atlas › Test

TestTruncateUTF8

Exact test identity: go.temporal.io/server/common/util/TestTruncateUTF8

Package
go.temporal.io/server/common/util
Suite / test hierarchy
TestTruncateUTF8
Test
TestTruncateUTF8
Introduced at
TestTruncateUTF8 Frontier kind: Test frontier
Covered ranges
7
Covered lines
10
Covered files
1

Covered source

Expand a file to inspect source; the > gutter marks covered lines.

go.temporal.io/server/common/util/strings.go 10 covered LOC · 7 ranges

Open complete file

7 // Note that truncation pays attention to codepoints only! This may truncate in the middle of a
8 // grapheme cluster.
9 > func TruncateUTF8(s string, n int) string { strings.go
10 > if len(s) <= n {
11 > return s strings.go
12 > } else if n <= 0 { strings.go
13 > return "" strings.go
14 > }
15 > for n > 0 && !utf8.RuneStart(s[n]) { strings.go
16 > n-- strings.go
17 > }
18 > return s[:n] strings.go
19 }