aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJoseph Hunkeler <jhunkeler@users.noreply.github.com>2021-05-06 00:34:05 -0400
committerGitHub <noreply@github.com>2021-05-06 00:34:05 -0400
commitc429ae2f0790c3486e7e420f4f2883c6a530ccf0 (patch)
tree200ab1a431513fdae9bd2c8b6652c70947287918 /tests
parent562258a7663a8d6447c46059743b173e19196e76 (diff)
downloadcleanpath-c429ae2f0790c3486e7e420f4f2883c6a530ccf0.tar.gz
No sep ending (#2)
* Be extra sure not to inject a separator at the end of the output string
Diffstat (limited to 'tests')
-rw-r--r--tests/test_no_sep_ending.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/tests/test_no_sep_ending.c b/tests/test_no_sep_ending.c
new file mode 100644
index 0000000..6b89c2b
--- /dev/null
+++ b/tests/test_no_sep_ending.c
@@ -0,0 +1,19 @@
+#include "cleanpath.h"
+#include "framework.h"
+
+int main() {
+ const char *input = "/usr/bin:/usr/sbin:/sbin:/bin:";
+ struct CleanPath *path;
+ char *result;
+ size_t len;
+
+ result = NULL;
+ path = cleanpath_init(input, TEST_SEP);
+ cleanpath_filter(path, CLEANPATH_FILTER_REGEX, "/bin");
+ result = cleanpath_read(path);
+ cleanpath_free(path);
+
+ len = strlen(result);
+ puts(result);
+ myassert(len && *(result + (len - 1)) != TEST_SEP[0], "Result ends with a separator:\n'%s'", result);
+} \ No newline at end of file