1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2024-12-21 09:33:57 +03:00

test-parse-util: add tests with explicit plus character

I expected this to work, but our tests did not cover this
explicitly.
This commit is contained in:
Zbigniew Jędrzejewski-Szmek 2023-02-08 10:54:49 +01:00
parent 502096b565
commit 8eb491f499

View File

@ -480,6 +480,14 @@ TEST(safe_atou16) {
assert_se(r == 0);
assert_se(l == 12345);
r = safe_atou16("+12345", &l);
assert_se(r == 0);
assert_se(l == 12345);
r = safe_atou16(" +12345", &l);
assert_se(r == 0);
assert_se(l == 12345);
r = safe_atou16("123456", &l);
assert_se(r == -ERANGE);
@ -514,6 +522,14 @@ TEST(safe_atoi16) {
assert_se(r == 0);
assert_se(l == -12345);
r = safe_atoi16("+12345", &l);
assert_se(r == 0);
assert_se(l == 12345);
r = safe_atoi16(" +12345", &l);
assert_se(r == 0);
assert_se(l == 12345);
r = safe_atoi16("32767", &l);
assert_se(r == 0);
assert_se(l == 32767);
@ -703,6 +719,22 @@ TEST(safe_atoux64) {
assert_se(r == 0);
assert_se(l == 11603985);
r = safe_atoux64("+12345", &l);
assert_se(r == 0);
assert_se(l == 0x12345);
r = safe_atoux64(" +12345", &l);
assert_se(r == 0);
assert_se(l == 0x12345);
r = safe_atoux64("+0x12345", &l);
assert_se(r == 0);
assert_se(l == 0x12345);
r = safe_atoux64("+0b11011", &l);
assert_se(r == 0);
assert_se(l == 11603985);
r = safe_atoux64("0o11011", &l);
assert_se(r == -EINVAL);