summaryrefslogtreecommitdiffstats
path: root/src/test/test-format-util.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* shared/format-table: do not print '.0'Zbigniew Jędrzejewski-Szmek2024-05-301-10/+10
| | | | | | | | | This makes output a bit shorter and nicer. For us, shorter output is generally better. Also, drop unnecessary UINT64_C macros. The left operand is always uint64_t, and C upcasting rules mean that it doesn't matter if the right operand is narrower or signed, the operation is always done on the wider unsigned type.
* ASSERT_STREQ for simple casesIvan Kruglov2024-04-151-4/+4
|
* test: Test STRLEN for C11 string literalsJan Janssen2022-05-221-2/+14
|
* macro: handle DECIMAL_STR_MAX() special cases more accuratelyLennart Poettering2022-03-141-4/+6
| | | | | | | | | | | | | | | | | | So far DECIMAL_STR_MAX() overestimated the types in two ways: it would also adds space for a "-" for unsigned types. And it would always return the same size for 64bit values regardless of signedness, even though the longest maximum numbers for signed and unsigned differ in length by one digit. i.e. 2^64-1 (i.e. UINT64_MAX) is one decimal digit longer than -2^63 (INT64_MIN) - for the other integer widths the number of digits in the "longest" decimal value is always the same, regardless of signedness. by example: strlen("65535") == strlen("32768") (i.e. the relevant 16 bit limits) holds — and similar for 8bit and 32bit integer width limits — but strlen("18446744073709551615") > strlen("9223372036854775808") (i.e. the relevant 64 bit limits). Let's fix both misestimations.
* test: Use TEST macroJan Janssen2021-11-251-6/+3
| | | | | | | | | 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
* macro: Move some macros to macro-fundamental.hJan Janssen2021-08-111-0/+2
| | | | Also, make sure STRLEN works with wide strings too.
* basic/macro: make CONST_MAX(DECIMAL_STR_MAX(…), STRLEN(…)) possibleZbigniew Jędrzejewski-Szmek2021-07-091-0/+9
| | | | | | | | | | | | | | | | When those two macros were used together in CONST_MAX(), gcc would complain about a type mismatch. So either DECIMAL_STR_MAX() should be made size_t like STRLEN(), or STRLEN() be made unsigned. Since those macros are only usable on arguments of (small) fixed size, any type should be fine (even char would work…). For buffer size specifications, both size_t and unsigned are OK. But unsigned was used for DECIMAL_STR_MAX macros and FORMAT_foo_MAX macros, making STRLEN the only exception, so let's adjust STRLEN() to be unsigned too. Also: I don't think this is currently used anywhere, but if any of those macros were used as an argument to sprintf, size_t would require a cast. ("%*s" requires an int/unsigned argument.)
* license: LGPL-2.1+ -> LGPL-2.1-or-laterYu Watanabe2020-11-091-1/+1
|
* test: fix argument type of test_format_bytes_one()Yu Watanabe2019-06-271-7/+8
| | | | Closes #12891.
* util,test: rename variable non_iec -> siYu Watanabe2019-06-271-3/+3
|
* test: add tests for format_bytes()Yu Watanabe2019-06-191-0/+38