@@ -7,20 +7,35 @@ import (
77
88// FuzzLongestUnique tests the longestUnique function with random string inputs.
99func FuzzLongestUnique (f * testing.F ) {
10- // Seed with test cases from the unit test
1110 f .Add ("apple,banana,cherry,applecherry,bananaapple,cherrybanana" )
1211 f .Add ("test,testing,tester,testest" )
1312 f .Add (",a,aa,aaa" )
1413 f .Add ("abc,def,ghi" )
1514 f .Add ("abc,abcabc,abcabcabc" )
16-
17- // Add edge cases
1815 f .Add ("" ) // empty input
1916 f .Add ("single" ) // single string
2017 f .Add ("a,a,a,a" ) // all duplicates
2118 f .Add ("very_long_string_" + strings .Repeat ("x" , 1000 )) // long strings
2219 f .Add (strings .Repeat ("a," , 100 )) // many strings
2320 f .Add ("a,b,c,d,e,f,g,h,i,j,k,l,m" ) // many different strings
21+ f .Add ("test\x00 null,normal" ) // null byte
22+ f .Add ("test\n newline,test\r carriage,test\t tab" ) // whitespace control chars
23+ f .Add ("test\x01 \x02 \x03 ,normal" ) // low control characters
24+ f .Add ("test\x7f \x80 \x9f ,normal" ) // high control characters
25+ f .Add ("test\u200b ,normal" ) // zero-width space
26+ f .Add ("test\u200c ,normal" ) // zero-width non-joiner
27+ f .Add ("test\u200d ,normal" ) // zero-width joiner
28+ f .Add ("test\ufeff ,normal" ) // zero-width no-break space (BOM)
29+ f .Add ("test\u202a \u202b \u202c ,normal" ) // bidirectional text marks
30+ f .Add ("test\u2060 ,normal" ) // word joiner
31+ f .Add ("hello\u200b world,helloworld" ) // same word with/without zero-width
32+ f .Add ("test\u034f ,normal" ) // combining grapheme joiner
33+ f .Add ("\u200b \u200c \u200d ,visible" ) // only invisible characters
34+ f .Add ("a\u0300 \u0301 \u0302 ,a" ) // combining diacritical marks
35+ f .Add ("test\u00ad ,test" ) // soft hyphen
36+ f .Add ("fi\ufb01 ,fi" ) // ligature vs normal chars
37+ f .Add ("test\u180e ,normal" ) // mongolian vowel separator
38+ f .Add ("\u061c \u2066 \u2067 \u2068 \u2069 ,normal" ) // directional formatting
2439
2540 f .Fuzz (func (t * testing.T , input string ) {
2641 var strs []string
@@ -76,12 +91,32 @@ func FuzzLongestUnique(f *testing.F) {
7691func FuzzTrimPrefixes (f * testing.F ) {
7792 f .Add ("/tmp/extract/path/to/file" , "/tmp/extract" )
7893 f .Add ("/home/user/file" , "/home/user,/tmp" )
79- f .Add ("./relative/path" , "./relative" )
8094 f .Add ("/absolute/path" , "/absolute,./relative" )
95+ f .Add ("/path/to/file" , "/path/to" )
96+ f .Add ("./relative/path" , "./relative" )
97+ f .Add ("./path/to/file" , "./path" )
98+ f .Add ("./a/b/c/d/e" , "./a/b" )
99+ f .Add ("../path/to/file" , "../path/to" )
100+ f .Add ("../../parent/path" , "../../parent" )
101+ f .Add ("../../../deeply/nested" , "../../../deeply" )
102+ f .Add ("./././path" , "./" )
103+ f .Add ("path/../other/file" , "path/.." )
104+ f .Add ("relative/path" , "/absolute,./relative" )
105+ f .Add ("/abs/path" , "./relative,/abs" )
81106 f .Add ("" , "" )
82107 f .Add ("path" , "" )
83108 f .Add ("path/to/file" , "path" )
84- f .Add ("/path/to/file" , "/path/to" )
109+ f .Add ("." , "." )
110+ f .Add (".." , ".." )
111+ f .Add ("../.." , "../.." )
112+ f .Add ("./path/./to/./file" , "./path" )
113+ f .Add ("path/./to/file" , "path/." )
114+ f .Add ("path/../to/file" , "path/.." )
115+ f .Add ("path/to/link/../real" , "path/to" )
116+ f .Add ("./path/to/../../other" , "./path" )
117+ f .Add ("path/to/file/" , "path/to/" )
118+ f .Add ("/path/to/file/" , "/path/to/" )
119+ f .Add ("./path/to/file/" , "./path/to/" )
85120
86121 f .Fuzz (func (t * testing.T , path , prefixesStr string ) {
87122 var prefixes []string
0 commit comments