diff options
author | Jan Janssen <medhefgo@web.de> | 2021-11-24 12:00:02 +0100 |
---|---|---|
committer | Jan Janssen <medhefgo@web.de> | 2021-11-25 15:03:06 +0100 |
commit | 4f7452a8eb7a946efea927fae017d4d661097833 (patch) | |
tree | 413778cc0fb08fbbed0890130b5ba66c90581e61 /src/test/test-percent-util.c | |
parent | 4d5ad9d951299c905453ac8e3769dc82b0a09fb4 (diff) | |
download | systemd-4f7452a8eb7a946efea927fae017d4d661097833.tar.gz |
test: Use TEST macro
This converts to TEST macro where it is trivial.
Some additional notable changes:
- simplify HAVE_LIBIDN #ifdef in test-dns-domain.c
- use saved_argc/saved_argv in test-copy.c, test-path-util.c,
test-tmpfiles.c and test-unit-file.c
Diffstat (limited to 'src/test/test-percent-util.c')
-rw-r--r-- | src/test/test-percent-util.c | 28 |
1 files changed, 8 insertions, 20 deletions
diff --git a/src/test/test-percent-util.c b/src/test/test-percent-util.c index b8801438a7..7e8e11b49c 100644 --- a/src/test/test-percent-util.c +++ b/src/test/test-percent-util.c @@ -4,7 +4,7 @@ #include "tests.h" #include "time-util.h" -static void test_parse_percent(void) { +TEST(parse_percent) { assert_se(parse_percent("") == -EINVAL); assert_se(parse_percent("foo") == -EINVAL); assert_se(parse_percent("0") == -EINVAL); @@ -24,12 +24,12 @@ static void test_parse_percent(void) { assert_se(parse_percent("3.2%") == -EINVAL); } -static void test_parse_percent_unbounded(void) { +TEST(parse_percent_unbounded) { assert_se(parse_percent_unbounded("101%") == 101); assert_se(parse_percent_unbounded("400%") == 400); } -static void test_parse_permille(void) { +TEST(parse_permille) { assert_se(parse_permille("") == -EINVAL); assert_se(parse_permille("foo") == -EINVAL); assert_se(parse_permille("0") == -EINVAL); @@ -67,7 +67,7 @@ static void test_parse_permille(void) { assert_se(parse_permille("0.1%") == 1); } -static void test_parse_permille_unbounded(void) { +TEST(parse_permille_unbounded) { assert_se(parse_permille_unbounded("1001‰") == 1001); assert_se(parse_permille_unbounded("4000‰") == 4000); assert_se(parse_permille_unbounded("2147483647‰") == 2147483647); @@ -83,7 +83,7 @@ static void test_parse_permille_unbounded(void) { assert_se(parse_permille_unbounded("429496729.6%") == -ERANGE); } -static void test_parse_permyriad(void) { +TEST(parse_permyriad) { assert_se(parse_permyriad("") == -EINVAL); assert_se(parse_permyriad("foo") == -EINVAL); assert_se(parse_permyriad("0") == -EINVAL); @@ -128,7 +128,7 @@ static void test_parse_permyriad(void) { assert_se(parse_permyriad("3.212%") == -EINVAL); } -static void test_parse_permyriad_unbounded(void) { +TEST(parse_permyriad_unbounded) { assert_se(parse_permyriad_unbounded("1001‱") == 1001); assert_se(parse_permyriad_unbounded("4000‱") == 4000); assert_se(parse_permyriad_unbounded("2147483647‱") == 2147483647); @@ -151,7 +151,7 @@ static void test_parse_permyriad_unbounded(void) { assert_se(parse_permyriad_unbounded("42949672.96%") == -ERANGE); } -static void test_scale(void) { +TEST(scale) { /* Check some fixed values */ assert_se(UINT32_SCALE_FROM_PERCENT(0) == 0); assert_se(UINT32_SCALE_FROM_PERCENT(50) == UINT32_MAX/2+1); @@ -196,16 +196,4 @@ static void test_scale(void) { } } -int main(int argc, char *argv[]) { - test_setup_logging(LOG_DEBUG); - - test_parse_percent(); - test_parse_percent_unbounded(); - test_parse_permille(); - test_parse_permille_unbounded(); - test_parse_permyriad(); - test_parse_permyriad_unbounded(); - test_scale(); - - return 0; -} +DEFINE_TEST_MAIN(LOG_DEBUG); |