@@ -159,10 +159,36 @@ describe("Stem / Suffix Test", function()
159159 }
160160 for _ , test in ipairs (test_table ) do
161161 local a , suffix , b = unpack (test )
162- it (string.format (" %s - '%s' -> %s" , a , suffix , b ), function ()
162+ it (string.format (" add: %s - '%s' -> %s" , a , suffix , b ), function ()
163163 assert .are_equal (Posix (b ), Posix (a ):add_suffix (suffix ))
164164 assert .are_equal (Windows (b ), Windows (a ):add_suffix (suffix ))
165165 end )
166166 end
167167 end )
168+
169+ describe (" add_suffix" , function ()
170+ local test_table = { -- from, suffix, to
171+ { " folder/foo.txt" , " .png" , " folder/foo.txt.png" },
172+ { " folder/foo.txt" , " .txt" , " folder/foo.txt.txt" },
173+ { " foo.txt" , " .bak" , " foo.txt.bak" },
174+ { " foo.tar" , " .zip" , " foo.tar.zip" },
175+ { " foo.tar.gz" , " .zip" , " foo.tar.gz.zip" },
176+ { " foo.png" , " .tar.gz" , " foo.png.tar.gz" },
177+ { " .bashrc" , " .zshrc" , " .bashrc.zshrc" },
178+ { " " , " .zshrc" , " .zshrc" },
179+ { " foo" , " .zip" , " foo.zip" },
180+ { " foo.txt" , " " , " foo.txt" },
181+ { " my.awesome.file.png" , " " , " my.awesome.file.png" },
182+ { " my.awesome.file." , " " , " my.awesome.file." },
183+ { " my.awesome.file.png" , " .txt" , " my.awesome.file.png.txt" },
184+ { " my.awesome.file.." , " .png" , " my.awesome.file...png" },
185+ }
186+ for _ , test in ipairs (test_table ) do
187+ local a , suffix , b = unpack (test )
188+ it (string.format (" remove: %s - '%s' -> %s" , b , suffix , a ), function ()
189+ assert .are_equal (Posix (a ), Posix (b ):remove_suffix (suffix ))
190+ assert .are_equal (Windows (a ), Windows (b ):remove_suffix (suffix ))
191+ end )
192+ end
193+ end )
168194end )
0 commit comments