ЛР 6 — БПИ2302 — Нурлыгаянова — на 3

This commit is contained in:
Nurlygayanova Ekaterina
2026-11-13 11:32:45 +03:00
parent 470d9d6f1e
commit 69a190be0e
164 changed files with 25947 additions and 29 deletions
+18
View File
@@ -0,0 +1,18 @@
package db
import "testing"
func TestTextEscapeRoundTrip(t *testing.T) {
cases := []string{"", "plain", "\x00", "a\x00b", `\`, `\0`, `\\0`, "\\\x00", "\x00\\0\x00", "привет\x00мир"}
for _, s := range cases {
enc := encodeText(s)
for i := 0; i < len(enc); i++ {
if enc[i] == 0 {
t.Fatalf("encodeText(%q) = %q содержит NUL", s, enc)
}
}
if got := decodeText(enc); got != s {
t.Fatalf("decodeText(encodeText(%q)) = %q", s, got)
}
}
}