diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/atom_test_utils.c | 10 | ||||
-rw-r--r-- | test/headers/.clang-tidy | 4 | ||||
-rw-r--r-- | test/test_atom.c | 10 |
3 files changed, 15 insertions, 9 deletions
diff --git a/test/atom_test_utils.c b/test/atom_test_utils.c index e7d45d0..bffa2ea 100644 --- a/test/atom_test_utils.c +++ b/test/atom_test_utils.c @@ -1,12 +1,15 @@ // Copyright 2012-2018 David Robillard <d@drobilla.net> // SPDX-License-Identifier: ISC +#undef NDEBUG + #include "lv2/atom/atom.h" #include "lv2/atom/forge.h" #include "lv2/atom/util.h" #include "lv2/log/log.h" #include "lv2/urid/urid.h" +#include <assert.h> #include <stdarg.h> #include <stdio.h> #include <stdlib.h> @@ -32,8 +35,11 @@ urid_map(LV2_URID_Map_Handle handle, const char* uri) } } - uris = (char**)realloc(uris, ++n_uris * sizeof(char*)); - uris[n_uris - 1] = copy_string(uri); + char** const new_uris = (char**)realloc(uris, (n_uris + 1) * sizeof(char*)); + assert(new_uris); + + uris = new_uris; + uris[n_uris++] = copy_string(uri); return n_uris; } diff --git a/test/headers/.clang-tidy b/test/headers/.clang-tidy index dd0b95f..bf971cc 100644 --- a/test/headers/.clang-tidy +++ b/test/headers/.clang-tidy @@ -1,15 +1,15 @@ -# Copyright 2020-2022 David Robillard <d@drobilla.net> +# Copyright 2020-2024 David Robillard <d@drobilla.net> # SPDX-License-Identifier: 0BSD OR ISC Checks: > *, + -*-macro-to-enum, -*-magic-numbers, -altera-*, -bugprone-assignment-in-if-condition, -bugprone-easily-swappable-parameters, -bugprone-macro-parentheses, -llvmlibc-restrict-system-libc-headers, - -modernize-macro-to-enum, -performance-no-int-to-ptr, -readability-identifier-length, CheckOptions: diff --git a/test/test_atom.c b/test/test_atom.c index beac05c..ffe73a1 100644 --- a/test/test_atom.c +++ b/test/test_atom.c @@ -101,7 +101,7 @@ main(void) lv2_atom_forge_key(&forge, eg_path); LV2_Atom_String* path = (LV2_Atom_String*)lv2_atom_forge_deref( &forge, lv2_atom_forge_uri(&forge, pstr, pstr_len)); - char* pbody = (char*)LV2_ATOM_BODY(path); + char* pbody = (char*)&path[1]; if (!!strcmp(pbody, pstr)) { return test_fail("%s != \"%s\"\n", pbody, pstr); } @@ -112,7 +112,7 @@ main(void) lv2_atom_forge_key(&forge, eg_uri); LV2_Atom_String* uri = (LV2_Atom_String*)lv2_atom_forge_deref( &forge, lv2_atom_forge_uri(&forge, ustr, ustr_len)); - char* ubody = (char*)LV2_ATOM_BODY(uri); + char* ubody = (char*)&uri[1]; if (!!strcmp(ubody, ustr)) { return test_fail("%s != \"%s\"\n", ubody, ustr); } @@ -130,7 +130,7 @@ main(void) lv2_atom_forge_key(&forge, eg_string); LV2_Atom_String* string = (LV2_Atom_String*)lv2_atom_forge_deref( &forge, lv2_atom_forge_string(&forge, "hello", strlen("hello"))); - char* sbody = (char*)LV2_ATOM_BODY(string); + char* sbody = (char*)&string[1]; if (!!strcmp(sbody, "hello")) { return test_fail("%s != \"hello\"\n", sbody); } @@ -144,7 +144,7 @@ main(void) strlen("bonjour"), 0, urid_map(NULL, "http://lexvo.org/id/term/fr"))); - char* lbody = (char*)LV2_ATOM_CONTENTS(LV2_Atom_Literal, literal); + char* lbody = (char*)&literal[1]; if (!!strcmp(lbody, "bonjour")) { return test_fail("%s != \"bonjour\"\n", lbody); } @@ -186,7 +186,7 @@ main(void) LV2_Atom_Vector* vector = (LV2_Atom_Vector*)lv2_atom_forge_deref( &forge, lv2_atom_forge_vector(&forge, sizeof(int32_t), forge.Int, 4, elems)); - void* vec_body = LV2_ATOM_CONTENTS(LV2_Atom_Vector, vector); + const void* vec_body = LV2_ATOM_CONTENTS_CONST(LV2_Atom_Vector, vector); if (!!memcmp(elems, vec_body, sizeof(elems))) { return test_fail("Corrupt vector\n"); } |