mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-02 09:01:46 -05:00
core-util-test: Test pa_atou64() and pa_atoi64()
Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/51>
This commit is contained in:
parent
ef5a2f1554
commit
fe162e0bbd
1 changed files with 56 additions and 0 deletions
|
|
@ -115,6 +115,7 @@ START_TEST (test_atoi) {
|
|||
ck_assert_int_lt(pa_atoi("3.14", &value), 0);
|
||||
ck_assert_int_lt(pa_atoi("7*8", &value), 0);
|
||||
ck_assert_int_lt(pa_atoi("false", &value), 0);
|
||||
ck_assert_int_lt(pa_atoi("10000000000", &value), 0);
|
||||
}
|
||||
END_TEST
|
||||
|
||||
|
|
@ -137,6 +138,31 @@ START_TEST (test_atou) {
|
|||
ck_assert_int_lt(pa_atou("3.14", &value), 0);
|
||||
ck_assert_int_lt(pa_atou("7*8", &value), 0);
|
||||
ck_assert_int_lt(pa_atou("false", &value), 0);
|
||||
ck_assert_int_lt(pa_atou("10000000000", &value), 0);
|
||||
}
|
||||
END_TEST
|
||||
|
||||
START_TEST (test_atou64) {
|
||||
uint64_t value;
|
||||
|
||||
// decimal
|
||||
ck_assert_int_eq(pa_atou64("100000", &value), 0);
|
||||
ck_assert_int_eq(value, 100000);
|
||||
ck_assert_int_eq(pa_atou64("010", &value), 0);
|
||||
ck_assert_int_eq(value, 10);
|
||||
ck_assert_int_eq(pa_atou64("10000000000", &value), 0);
|
||||
ck_assert_int_eq(value, 10000000000);
|
||||
|
||||
// hexadecimal
|
||||
ck_assert_int_eq(pa_atou64("0x100000", &value), 0);
|
||||
ck_assert_int_eq(value, 0x100000);
|
||||
|
||||
// invalid values
|
||||
ck_assert_int_lt(pa_atou64("-100000", &value), 0);
|
||||
ck_assert_int_lt(pa_atou64("-0x100000", &value), 0);
|
||||
ck_assert_int_lt(pa_atou64("3.14", &value), 0);
|
||||
ck_assert_int_lt(pa_atou64("7*8", &value), 0);
|
||||
ck_assert_int_lt(pa_atou64("false", &value), 0);
|
||||
}
|
||||
END_TEST
|
||||
|
||||
|
|
@ -166,6 +192,34 @@ START_TEST (test_atol) {
|
|||
}
|
||||
END_TEST
|
||||
|
||||
START_TEST (test_atoi64) {
|
||||
int64_t value;
|
||||
|
||||
// decimal
|
||||
ck_assert_int_eq(pa_atoi64("100000", &value), 0);
|
||||
ck_assert_int_eq(value, 100000);
|
||||
ck_assert_int_eq(pa_atoi64("-100000", &value), 0);
|
||||
ck_assert_int_eq(value, -100000);
|
||||
ck_assert_int_eq(pa_atoi64("010", &value), 0);
|
||||
ck_assert_int_eq(value, 10);
|
||||
ck_assert_int_eq(pa_atoi64("-010", &value), 0);
|
||||
ck_assert_int_eq(value, -10);
|
||||
ck_assert_int_eq(pa_atoi64("10000000000", &value), 0);
|
||||
ck_assert_int_eq(value, 10000000000);
|
||||
|
||||
// hexadecimal
|
||||
ck_assert_int_eq(pa_atoi64("0x100000", &value), 0);
|
||||
ck_assert_int_eq(value, 0x100000);
|
||||
ck_assert_int_eq(pa_atoi64("-0x100000", &value), 0);
|
||||
ck_assert_int_eq(value, -0x100000);
|
||||
|
||||
// invalid values
|
||||
ck_assert_int_lt(pa_atoi64("3.14", &value), 0);
|
||||
ck_assert_int_lt(pa_atoi64("7*8", &value), 0);
|
||||
ck_assert_int_lt(pa_atoi64("false", &value), 0);
|
||||
}
|
||||
END_TEST
|
||||
|
||||
START_TEST (test_atod) {
|
||||
double value;
|
||||
double epsilon = 0.001;
|
||||
|
|
@ -275,7 +329,9 @@ int main(int argc, char *argv[]) {
|
|||
tcase_add_test(tc, test_parse_volume);
|
||||
tcase_add_test(tc, test_atoi);
|
||||
tcase_add_test(tc, test_atou);
|
||||
tcase_add_test(tc, test_atou64);
|
||||
tcase_add_test(tc, test_atol);
|
||||
tcase_add_test(tc, test_atoi64);
|
||||
tcase_add_test(tc, test_atod);
|
||||
tcase_add_test(tc, test_replace);
|
||||
tcase_add_test_raise_signal(tc, test_replace_fail_1, SIGABRT);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue