diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2022-05-12 16:29:48 +0200 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2022-05-12 17:15:51 +0200 |
commit | 8b0c43475a764080299f1d69efc2cef0db7b6c66 (patch) | |
tree | 01ecef3b89b90a541641a1aeca638f1c539893ad /src/test/test-macro.c | |
parent | resolve: fix false maybe-uninitialized warning (diff) | |
download | systemd-8b0c43475a764080299f1d69efc2cef0db7b6c66.tar.xz systemd-8b0c43475a764080299f1d69efc2cef0db7b6c66.zip |
Add saturate_add() that generalizes size_add()
Diffstat (limited to 'src/test/test-macro.c')
-rw-r--r-- | src/test/test-macro.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/test/test-macro.c b/src/test/test-macro.c index ba319953cd..c39f64b385 100644 --- a/src/test/test-macro.c +++ b/src/test/test-macro.c @@ -6,6 +6,15 @@ #include "macro.h" #include "tests.h" +TEST(saturate_add) { + assert_se(saturate_add(1, 2, UINT8_MAX) == 3); + assert_se(saturate_add(1, UINT8_MAX-2, UINT8_MAX) == UINT8_MAX-1); + assert_se(saturate_add(1, UINT8_MAX-1, UINT8_MAX) == UINT8_MAX); + assert_se(saturate_add(1, UINT8_MAX, UINT8_MAX) == UINT8_MAX); + assert_se(saturate_add(2, UINT8_MAX, UINT8_MAX) == UINT8_MAX); + assert_se(saturate_add(60, 60, 50) == 50); +} + TEST(align_power2) { unsigned long i, p2; |