diff options
author | Patrick Steinhardt <ps@pks.im> | 2024-05-27 13:47:04 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2024-05-27 20:20:02 +0200 |
commit | 11ce77b5cc04e2a42b98f0f9f42d367f50f3b1fc (patch) | |
tree | de3d223621a5afca4f2d9a24b9d8b280adee2d7c /t/unit-tests/test-lib.h | |
parent | submodule: fix leaking memory for submodule entries (diff) | |
download | git-11ce77b5cc04e2a42b98f0f9f42d367f50f3b1fc.tar.xz git-11ce77b5cc04e2a42b98f0f9f42d367f50f3b1fc.zip |
strvec: add functions to replace and remove strings
Add two functions that allow to replace and remove strings contained in
the strvec. This will be used by a subsequent commit that refactors
git-mv(1).
While at it, add a bunch of unit tests that cover both old and new
functionality.
Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to '')
-rw-r--r-- | t/unit-tests/test-lib.h | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/t/unit-tests/test-lib.h b/t/unit-tests/test-lib.h index a8f07ae0b7..2de6d715d5 100644 --- a/t/unit-tests/test-lib.h +++ b/t/unit-tests/test-lib.h @@ -79,6 +79,18 @@ int check_bool_loc(const char *loc, const char *check, int ok); * Compare two integers. Prints a message with the two values if the * comparison fails. NB this is not thread safe. */ +#define check_pointer_eq(a, b) \ + (test__tmp[0].p = (a), test__tmp[1].p = (b), \ + check_pointer_eq_loc(TEST_LOCATION(), #a" == "#b, \ + test__tmp[0].p == test__tmp[1].p, \ + test__tmp[0].p, test__tmp[1].p)) +int check_pointer_eq_loc(const char *loc, const char *check, int ok, + const void *a, const void *b); + +/* + * Compare two integers. Prints a message with the two values if the + * comparison fails. NB this is not thread safe. + */ #define check_int(a, op, b) \ (test__tmp[0].i = (a), test__tmp[1].i = (b), \ check_int_loc(TEST_LOCATION(), #a" "#op" "#b, \ @@ -136,6 +148,7 @@ union test__tmp { intmax_t i; uintmax_t u; char c; + const void *p; }; extern union test__tmp test__tmp[2]; |