aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/.clang-tidy1
-rw-r--r--test/test_string.c30
2 files changed, 30 insertions, 1 deletions
diff --git a/test/.clang-tidy b/test/.clang-tidy
index 4e2b14eb..dd609218 100644
--- a/test/.clang-tidy
+++ b/test/.clang-tidy
@@ -6,6 +6,7 @@ Checks: >
-android-cloexec-fopen,
-bugprone-easily-swappable-parameters,
-bugprone-reserved-identifier,
+ -bugprone-suspicious-string-compare,
-clang-analyzer-nullability.NullabilityBase,
-clang-analyzer-nullability.NullableDereferenced,
-clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling,
diff --git a/test/test_string.c b/test/test_string.c
index 472b464a..5bc304d1 100644
--- a/test/test_string.c
+++ b/test/test_string.c
@@ -18,6 +18,11 @@
#include "serd/serd.h"
+#if defined(_WIN32) && !defined(__MINGW32__)
+# include <io.h>
+# define mkstemp(pat) _mktemp(pat)
+#endif
+
#include <assert.h>
#include <stdint.h>
#include <stdio.h>
@@ -48,11 +53,34 @@ test_strerror(void)
assert(!strcmp(msg, "Unknown error"));
}
+static void
+test_canonical_path(const char* const path)
+{
+ char* const canonical = serd_canonical_path(path);
+
+ assert(canonical);
+ assert(!strstr(canonical, "../"));
+
+#if defined(_WIN32)
+ assert(strlen(canonical) > 2);
+ assert(canonical[0] >= 'A' && canonical[0] <= 'Z');
+ assert(canonical[1] == ':');
+ assert(!strstr(canonical, "..\\"));
+#else
+ assert(canonical[0] == '/');
+#endif
+
+ serd_free(canonical);
+}
+
int
-main(void)
+main(int argc, char** argv)
{
+ (void)argc;
+
test_strlen();
test_strerror();
+ test_canonical_path(argv[0]);
printf("Success\n");
return 0;