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) {
|
func FuzzLayout(f *testing.F) {
|
||||||
ltrFace, _ := opentype.Parse(goregular.TTF)
|
ltrFace, _ := opentype.Parse(goregular.TTF)
|
||||||
rtlFace, _ := opentype.Parse(nsareg.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)
|
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{
|
locale := system.Locale{
|
||||||
Direction: system.LTR,
|
Direction: system.LTR,
|
||||||
}
|
}
|
||||||
@@ -580,9 +580,14 @@ func FuzzLayout(f *testing.F) {
|
|||||||
if fontSize < 1 {
|
if fontSize < 1 {
|
||||||
fontSize = 1
|
fontSize = 1
|
||||||
}
|
}
|
||||||
|
maxLines := 0
|
||||||
|
if truncate {
|
||||||
|
maxLines = 1
|
||||||
|
}
|
||||||
lines := shaper.LayoutRunes(Parameters{
|
lines := shaper.LayoutRunes(Parameters{
|
||||||
PxPerEm: fixed.I(int(fontSize)),
|
PxPerEm: fixed.I(int(fontSize)),
|
||||||
MaxWidth: int(width),
|
MaxWidth: int(width),
|
||||||
|
MaxLines: maxLines,
|
||||||
Locale: locale,
|
Locale: locale,
|
||||||
}, []rune(txt))
|
}, []rune(txt))
|
||||||
validateLines(t, lines.lines, len([]rune(txt)))
|
validateLines(t, lines.lines, len([]rune(txt)))
|
||||||
|
|||||||
Vendored
+1
@@ -1,5 +1,6 @@
|
|||||||
go test fuzz v1
|
go test fuzz v1
|
||||||
string("\x1d")
|
string("\x1d")
|
||||||
bool(true)
|
bool(true)
|
||||||
|
bool(false)
|
||||||
byte('\x1c')
|
byte('\x1c')
|
||||||
uint16(227)
|
uint16(227)
|
||||||
|
|||||||
Vendored
+1
@@ -1,5 +1,6 @@
|
|||||||
go test fuzz v1
|
go test fuzz v1
|
||||||
string("0")
|
string("0")
|
||||||
bool(true)
|
bool(true)
|
||||||
|
bool(false)
|
||||||
uint8(27)
|
uint8(27)
|
||||||
uint16(200)
|
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
|
go test fuzz v1
|
||||||
string("\n")
|
string("\n")
|
||||||
bool(false)
|
bool(false)
|
||||||
|
bool(false)
|
||||||
byte('±')
|
byte('±')
|
||||||
uint16(0)
|
uint16(0)
|
||||||
|
|||||||
Vendored
+1
@@ -1,5 +1,6 @@
|
|||||||
go test fuzz v1
|
go test fuzz v1
|
||||||
string("\u2029")
|
string("\u2029")
|
||||||
bool(false)
|
bool(false)
|
||||||
|
bool(false)
|
||||||
byte('*')
|
byte('*')
|
||||||
uint16(72)
|
uint16(72)
|
||||||
|
|||||||
Vendored
+1
@@ -1,5 +1,6 @@
|
|||||||
go test fuzz v1
|
go test fuzz v1
|
||||||
string("Aͮ000000000000000")
|
string("Aͮ000000000000000")
|
||||||
bool(false)
|
bool(false)
|
||||||
|
bool(false)
|
||||||
byte('\u0087')
|
byte('\u0087')
|
||||||
uint16(111)
|
uint16(111)
|
||||||
|
|||||||
Vendored
+1
@@ -1,5 +1,6 @@
|
|||||||
go test fuzz v1
|
go test fuzz v1
|
||||||
string("\x1e")
|
string("\x1e")
|
||||||
bool(true)
|
bool(true)
|
||||||
|
bool(false)
|
||||||
byte('\n')
|
byte('\n')
|
||||||
uint16(254)
|
uint16(254)
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
go test fuzz v1
|
go test fuzz v1
|
||||||
string("000000000000000 00000000 ٰ00000")
|
string("000000000000000 00000000 ٰ00000")
|
||||||
bool(true)
|
bool(true)
|
||||||
|
bool(false)
|
||||||
byte('\n')
|
byte('\n')
|
||||||
uint16(121)
|
uint16(121)
|
||||||
|
|||||||
Vendored
+1
@@ -1,5 +1,6 @@
|
|||||||
go test fuzz v1
|
go test fuzz v1
|
||||||
string("\r")
|
string("\r")
|
||||||
bool(false)
|
bool(false)
|
||||||
|
bool(false)
|
||||||
byte('T')
|
byte('T')
|
||||||
uint16(200)
|
uint16(200)
|
||||||
|
|||||||
Vendored
+1
@@ -1,5 +1,6 @@
|
|||||||
go test fuzz v1
|
go test fuzz v1
|
||||||
string("\u0085")
|
string("\u0085")
|
||||||
bool(true)
|
bool(true)
|
||||||
|
bool(false)
|
||||||
byte('\x10')
|
byte('\x10')
|
||||||
uint16(271)
|
uint16(271)
|
||||||
|
|||||||
Vendored
+1
@@ -1,5 +1,6 @@
|
|||||||
go test fuzz v1
|
go test fuzz v1
|
||||||
string("0")
|
string("0")
|
||||||
bool(false)
|
bool(false)
|
||||||
|
bool(false)
|
||||||
byte('\x00')
|
byte('\x00')
|
||||||
uint16(142)
|
uint16(142)
|
||||||
|
|||||||
Vendored
+1
@@ -1,5 +1,6 @@
|
|||||||
go test fuzz v1
|
go test fuzz v1
|
||||||
string("\n")
|
string("\n")
|
||||||
bool(true)
|
bool(true)
|
||||||
|
bool(false)
|
||||||
byte('\t')
|
byte('\t')
|
||||||
uint16(200)
|
uint16(200)
|
||||||
|
|||||||
Vendored
+1
@@ -1,5 +1,6 @@
|
|||||||
go test fuzz v1
|
go test fuzz v1
|
||||||
string("ع0 ׂ0")
|
string("ع0 ׂ0")
|
||||||
bool(false)
|
bool(false)
|
||||||
|
bool(false)
|
||||||
byte('\u0098')
|
byte('\u0098')
|
||||||
uint16(198)
|
uint16(198)
|
||||||
|
|||||||
Vendored
+1
@@ -1,5 +1,6 @@
|
|||||||
go test fuzz v1
|
go test fuzz v1
|
||||||
string("\x1c")
|
string("\x1c")
|
||||||
bool(true)
|
bool(true)
|
||||||
|
bool(false)
|
||||||
byte('\u009c')
|
byte('\u009c')
|
||||||
uint16(200)
|
uint16(200)
|
||||||
|
|||||||
Reference in New Issue
Block a user