2 Commits

Author SHA1 Message Date
Thomas Martitz
30a486d624 utils: fix suboptimal elipsis substitution by utils_strv_shorten_file_list()
Because utils_strv_find_lcs() didn't consisider path component boundaries
it have have found substrings that are longest in itself but not so ideal
when utils_strv_shorten_file_list() applied path boundaries.

utils_strv_find_lcs() now can optionally restrict the substring between
delimiters (i.e. dir separators). In that mode it will find the longest
substring that is also sorrounded by the delimiters (there may be more
delimiters inside the string).

The unit test that demonstrated the deficient is fixed since
now the expected substitution takes place.
2019-09-20 23:01:03 +02:00
Thomas Martitz
64a32db5e1 tests: unit test for some util strv functions
We didn't use unit tests so far so I have picked up the glib testing
framework. While there are better frameworks out there glib's it gets the job
done and doesn't impose extra dependencies.

For upcoming fixes and refactorings to utils_strv_find_lcs and
utils_strv_shorten_file_list I would like to make sure
to not introduce regressions and unit tests are ideal for that.

A function to be tested must be exported by libgeany.so. Use
GEANY_EXPORT_SYMBOL for that. It's not the same as GEANY_API_SYMBOL
to avoid the impression that it's OK to use them in plugins. Also
no doxygen comments for those.

I resurrected utils_strv_new() because it's convinient to have in the tests.
The function has its own test suite since it's otherwise unused.
2019-09-20 22:58:25 +02:00