summaryrefslogtreecommitdiffstats
path: root/src/test/test-id128.c
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2021-04-19 15:36:10 +0200
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2021-04-21 17:51:24 +0200
commit64b21afc727deb5a0702563dcbe4baba9cf5bd14 (patch)
tree3a51987a9b886cd035360215ef52e07cf8a7117c /src/test/test-id128.c
parentman: mention sd_id128_is_allf(), SD_ID128_ALLF (diff)
downloadsystemd-64b21afc727deb5a0702563dcbe4baba9cf5bd14.tar.xz
systemd-64b21afc727deb5a0702563dcbe4baba9cf5bd14.zip
sd-id128: add convenience functions to compare multiple sd_id128_t
Similar to sd_bus_error_has_names() that was added in 2b07ec316a0e25a3e10c270c7f6baee9e0187bf8. It is made inline in the hope that the compiler will be able to optimize all the va_args boilerplate away, and do an efficient comparison when the arguments are all constants.
Diffstat (limited to '')
-rw-r--r--src/test/test-id128.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/test/test-id128.c b/src/test/test-id128.c
index a0649b9deb..a61b35b9a3 100644
--- a/src/test/test-id128.c
+++ b/src/test/test-id128.c
@@ -31,6 +31,13 @@ int main(int argc, char *argv[]) {
assert_se(sd_id128_from_string(t, &id2) == 0);
assert_se(sd_id128_equal(id, id2));
+ assert_se(sd_id128_in_set(id, id));
+ assert_se(sd_id128_in_set(id, id2));
+ assert_se(sd_id128_in_set(id, id2, id));
+ assert_se(sd_id128_in_set(id, ID128_WALDI, id));
+ assert_se(!sd_id128_in_set(id));
+ assert_se(!sd_id128_in_set(id, ID128_WALDI));
+ assert_se(!sd_id128_in_set(id, ID128_WALDI, ID128_WALDI));
if (sd_booted() > 0) {
assert_se(sd_id128_get_machine(&id) == 0);