mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-01 07:35:40 +00:00
text: update fuzzer to sometimes truncate
This commit updates the shaper fuzzer to try truncating the text, exposing new edge cases. Signed-off-by: Chris Waldon <christopher.waldon.dev@gmail.com>
This commit is contained in:
+7
-2
@@ -567,10 +567,10 @@ func TestComputeVisualOrder(t *testing.T) {
|
||||
func FuzzLayout(f *testing.F) {
|
||||
ltrFace, _ := opentype.Parse(goregular.TTF)
|
||||
rtlFace, _ := opentype.Parse(nsareg.TTF)
|
||||
f.Add("د عرمثال dstي met لم aqل جدmوpمg lرe dرd لو عل ميrةsdiduntut lab renنيتذدagلaaiua.ئPocttأior رادرsاي mيrbلmnonaيdتد ماةعcلخ.", true, uint8(10), uint16(200))
|
||||
f.Add("د عرمثال dstي met لم aqل جدmوpمg lرe dرd لو عل ميrةsdiduntut lab renنيتذدagلaaiua.ئPocttأior رادرsاي mيrbلmnonaيdتد ماةعcلخ.", true, false, uint8(10), uint16(200))
|
||||
|
||||
shaper := testShaper(ltrFace, rtlFace)
|
||||
f.Fuzz(func(t *testing.T, txt string, rtl bool, fontSize uint8, width uint16) {
|
||||
f.Fuzz(func(t *testing.T, txt string, rtl bool, truncate bool, fontSize uint8, width uint16) {
|
||||
locale := system.Locale{
|
||||
Direction: system.LTR,
|
||||
}
|
||||
@@ -580,9 +580,14 @@ func FuzzLayout(f *testing.F) {
|
||||
if fontSize < 1 {
|
||||
fontSize = 1
|
||||
}
|
||||
maxLines := 0
|
||||
if truncate {
|
||||
maxLines = 1
|
||||
}
|
||||
lines := shaper.LayoutRunes(Parameters{
|
||||
PxPerEm: fixed.I(int(fontSize)),
|
||||
MaxWidth: int(width),
|
||||
MaxLines: maxLines,
|
||||
Locale: locale,
|
||||
}, []rune(txt))
|
||||
validateLines(t, lines.lines, len([]rune(txt)))
|
||||
|
||||
Vendored
+1
@@ -1,5 +1,6 @@
|
||||
go test fuzz v1
|
||||
string("\x1d")
|
||||
bool(true)
|
||||
bool(false)
|
||||
byte('\x1c')
|
||||
uint16(227)
|
||||
|
||||
Vendored
+1
@@ -1,5 +1,6 @@
|
||||
go test fuzz v1
|
||||
string("0")
|
||||
bool(true)
|
||||
bool(false)
|
||||
uint8(27)
|
||||
uint16(200)
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
go test fuzz v1
|
||||
string("\n")
|
||||
bool(false)
|
||||
bool(true)
|
||||
byte('±')
|
||||
uint16(0)
|
||||
@@ -1,5 +1,6 @@
|
||||
go test fuzz v1
|
||||
string("\n")
|
||||
bool(false)
|
||||
bool(false)
|
||||
byte('±')
|
||||
uint16(0)
|
||||
|
||||
Vendored
+1
@@ -1,5 +1,6 @@
|
||||
go test fuzz v1
|
||||
string("\u2029")
|
||||
bool(false)
|
||||
bool(false)
|
||||
byte('*')
|
||||
uint16(72)
|
||||
|
||||
Vendored
+1
@@ -1,5 +1,6 @@
|
||||
go test fuzz v1
|
||||
string("Aͮ000000000000000")
|
||||
bool(false)
|
||||
bool(false)
|
||||
byte('\u0087')
|
||||
uint16(111)
|
||||
|
||||
Vendored
+1
@@ -1,5 +1,6 @@
|
||||
go test fuzz v1
|
||||
string("\x1e")
|
||||
bool(true)
|
||||
bool(false)
|
||||
byte('\n')
|
||||
uint16(254)
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
go test fuzz v1
|
||||
string("000000000000000 00000000 ٰ00000")
|
||||
bool(true)
|
||||
bool(false)
|
||||
byte('\n')
|
||||
uint16(121)
|
||||
|
||||
Vendored
+1
@@ -1,5 +1,6 @@
|
||||
go test fuzz v1
|
||||
string("\r")
|
||||
bool(false)
|
||||
bool(false)
|
||||
byte('T')
|
||||
uint16(200)
|
||||
|
||||
Vendored
+1
@@ -1,5 +1,6 @@
|
||||
go test fuzz v1
|
||||
string("\u0085")
|
||||
bool(true)
|
||||
bool(false)
|
||||
byte('\x10')
|
||||
uint16(271)
|
||||
|
||||
Vendored
+1
@@ -1,5 +1,6 @@
|
||||
go test fuzz v1
|
||||
string("0")
|
||||
bool(false)
|
||||
bool(false)
|
||||
byte('\x00')
|
||||
uint16(142)
|
||||
|
||||
Vendored
+1
@@ -1,5 +1,6 @@
|
||||
go test fuzz v1
|
||||
string("\n")
|
||||
bool(true)
|
||||
bool(false)
|
||||
byte('\t')
|
||||
uint16(200)
|
||||
|
||||
Vendored
+1
@@ -1,5 +1,6 @@
|
||||
go test fuzz v1
|
||||
string("ع0 ׂ0")
|
||||
bool(false)
|
||||
bool(false)
|
||||
byte('\u0098')
|
||||
uint16(198)
|
||||
|
||||
Vendored
+1
@@ -1,5 +1,6 @@
|
||||
go test fuzz v1
|
||||
string("\x1c")
|
||||
bool(true)
|
||||
bool(false)
|
||||
byte('\u009c')
|
||||
uint16(200)
|
||||
|
||||
Reference in New Issue
Block a user