mirror of
https://github.com/systemd/systemd-stable.git
synced 2025-01-18 06:03:42 +03:00
test-parse-util: add tests with explicit plus character
I expected this to work, but our tests did not cover this explicitly. (cherry picked from commit 8eb491f4993c6080e9724c0359a87c64c460605e) (cherry picked from commit 7c0ac515c8094fd62c100477fa293aa31f97e2c4) (cherry picked from commit 36c35e765db478d5f72cdd70cd663baa865ad43a)
This commit is contained in:
parent
c20388003e
commit
eeb9299eee
@ -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);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user