diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2018-11-18 10:42:39 +0100 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2018-11-18 16:12:53 +0100 |
commit | 7f6bfc561fea20251eb42b9c2fb17348172ccbbf (patch) | |
tree | c1c1255eb071e5e79e8a89d7d15eb1ec885f0e16 /src/test/test-util.c | |
parent | test-util: modernize (diff) | |
download | systemd-7f6bfc561fea20251eb42b9c2fb17348172ccbbf.tar.xz systemd-7f6bfc561fea20251eb42b9c2fb17348172ccbbf.zip |
basic/util: import memeqzero from casync
Diffstat (limited to '')
-rw-r--r-- | src/test/test-util.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/test/test-util.c b/src/test/test-util.c index 80856e6388..eeee09a7d2 100644 --- a/src/test/test-util.c +++ b/src/test/test-util.c @@ -237,6 +237,20 @@ static void test_log2i(void) { assert_se(log2i(INT_MAX) == sizeof(int)*8-2); } +static void test_eqzero(void) { + const uint32_t zeros[] = {0, 0, 0}; + const uint32_t ones[] = {1, 1}; + const uint32_t mixed[] = {0, 1, 0, 0, 0}; + const uint8_t longer[] = {[55] = 255}; + + log_info("/* %s */", __func__); + + assert_se(eqzero(zeros)); + assert_se(!eqzero(ones)); + assert_se(!eqzero(mixed)); + assert_se(!eqzero(longer)); +} + static void test_raw_clone(void) { pid_t parent, pid, pid2; @@ -370,6 +384,7 @@ int main(int argc, char *argv[]) { test_protect_errno(); test_in_set(); test_log2i(); + test_eqzero(); test_raw_clone(); test_physical_memory(); test_physical_memory_scale(); |