diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/.clang-tidy | 4 | ||||
-rw-r--r-- | test/test_uri.c | 26 |
2 files changed, 29 insertions, 1 deletions
diff --git a/test/.clang-tidy b/test/.clang-tidy index de654d8d..b7dd752b 100644 --- a/test/.clang-tidy +++ b/test/.clang-tidy @@ -3,6 +3,10 @@ Checks: > -*-magic-numbers, -*-uppercase-literal-suffix, -android-cloexec-fopen, + -bugprone-reserved-identifier, + -bugprone-suspicious-string-compare, + -cert-dcl37-c, + -cert-dcl51-cpp, -clang-analyzer-nullability.NullabilityBase, -clang-analyzer-nullability.NullableDereferenced, -clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling, diff --git a/test/test_uri.c b/test/test_uri.c index 88aa342c..dff4d999 100644 --- a/test/test_uri.c +++ b/test/test_uri.c @@ -20,6 +20,11 @@ #include "serd/serd.h" +#if defined(_WIN32) && !defined(__MINGW32__) +# include <io.h> +# define mkstemp(pat) _mktemp(pat) +#endif + #include <assert.h> #include <stdio.h> #include <stdlib.h> @@ -80,6 +85,24 @@ test_uri_parsing(void) } static void +test_real_file_uri(void) +{ + char path[16]; + strncpy(path, "serd_XXXXXX", sizeof(path)); + assert(mkstemp(path) > 0); + + SerdNode* const good = serd_new_real_file_uri(path, NULL); + assert(good); + assert(!strncmp(serd_node_string(good), "file://", 7)); + serd_node_free(good); + + SerdNode* const bad = serd_new_real_file_uri("not_a_file", NULL); + assert(!bad); + + assert(!remove(path)); +} + +static void test_parse_uri(void) { const SerdStringView base = SERD_STATIC_STRING("http://example.org/a/b/c/"); @@ -204,7 +227,7 @@ test_uri_resolution(void) const SerdURIView rel_foo_uri = serd_relative_uri(abs_foo_uri, base_uri); const SerdURIView resolved_uri = serd_resolve_uri(rel_foo_uri, base_uri); -SerdNode* const resolved = serd_new_parsed_uri(resolved_uri); + SerdNode* const resolved = serd_new_parsed_uri(resolved_uri); assert(!strcmp(serd_node_string(resolved), "http://example.org/a/b/c/foo")); serd_node_free(resolved); @@ -215,6 +238,7 @@ main(void) { test_uri_parsing(); test_parse_uri(); + test_real_file_uri(); test_is_within(); test_relative_uri(); test_uri_resolution(); |