aboutsummaryrefslogtreecommitdiff
path: root/internal/extract/plain_test.go
diff options
context:
space:
mode:
authorLukasz Kasprzak <lukas@labunix.xyz>2026-09-14 23:53:54 +0200
committerLukasz Kasprzak <lukas@labunix.xyz>2026-09-14 23:53:54 +0200
commit0b155e8df3205aebf129091b517f4116665a5adc (patch)
tree2215aa05b1d703f9b37badd96aa94a95fd2b14bf /internal/extract/plain_test.go
parent1f1a303c617057f149b4f0d748ee0a195484642c (diff)
downloadkrino-0b155e8df3205aebf129091b517f4116665a5adc.tar.gz
krino-0b155e8df3205aebf129091b517f4116665a5adc.zip
main excludes checked with the defaults' case and fold; Latin-1 decoding memory; hardlink election documented
Diffstat (limited to 'internal/extract/plain_test.go')
-rw-r--r--internal/extract/plain_test.go16
1 files changed, 16 insertions, 0 deletions
diff --git a/internal/extract/plain_test.go b/internal/extract/plain_test.go
index 5752bf8..c8e1008 100644
--- a/internal/extract/plain_test.go
+++ b/internal/extract/plain_test.go
@@ -3,6 +3,7 @@
package extract
import (
+ "bytes"
"context"
"errors"
"os"
@@ -228,3 +229,18 @@ func TestSniffRuneStraddlingSampleBoundary(t *testing.T) {
t.Errorf("got tail %q, want it to end in %q", got[len(got)-8:], want)
}
}
+
+// TestLatin1DecodingMemory: decoding Latin-1 allocates about what the UTF-8
+// result needs (at most two bytes per input byte), not a four-byte rune per
+// input byte on top of it (triage 28d).
+func TestLatin1DecodingMemory(t *testing.T) {
+ data := bytes.Repeat([]byte("Gr\xfc\xdfe "), 16000)
+ r := testing.Benchmark(func(b *testing.B) {
+ for range b.N {
+ decodeLatin1(data)
+ }
+ })
+ if got, limit := r.AllocedBytesPerOp(), int64(3*len(data)); got > limit {
+ t.Errorf("decoding %d bytes allocates %d bytes, over %d", len(data), got, limit)
+ }
+}