Commit 674c416d authored by Thomas Guillem's avatar Thomas Guillem

test: slaves: fix false positive when calling test_expected_slaves with 0

parent bb44d80a
...@@ -73,33 +73,33 @@ test_expected_slaves(libvlc_media_t *p_m, ...@@ -73,33 +73,33 @@ test_expected_slaves(libvlc_media_t *p_m,
unsigned int i_slave_count = libvlc_media_slaves_get(p_m, &pp_slaves); unsigned int i_slave_count = libvlc_media_slaves_get(p_m, &pp_slaves);
assert(i_expected_slaves == i_slave_count); assert(i_expected_slaves == i_slave_count);
if (i_expected_slaves > 0) unsigned i_found_slaves = 0;
bool *p_found_list = calloc(i_expected_slaves, sizeof(bool));
assert(p_found_list != NULL);
for (unsigned int i = 0; i < i_slave_count; ++i)
{ {
bool *p_found_list = calloc(i_expected_slaves, sizeof(bool)); libvlc_media_slave_t *p_slave1 = pp_slaves[i];
assert(p_found_list != NULL); for (unsigned int j = 0; j < i_expected_slaves; ++j)
for (unsigned int i = 0; i < i_slave_count; ++i)
{ {
libvlc_media_slave_t *p_slave1 = pp_slaves[i]; libvlc_media_slave_t *p_slave2 = &p_expected_slaves[j];
for (unsigned int j = 0; i < i_expected_slaves; ++j) if (strcmp(p_slave1->psz_uri, p_slave2->psz_uri) == 0)
{ {
libvlc_media_slave_t *p_slave2 = &p_expected_slaves[j]; assert(p_found_list[j] == false);
if (strcmp(p_slave1->psz_uri, p_slave2->psz_uri) == 0) assert(p_slave1->i_type == p_slave2->i_type);
{ assert(p_slave1->i_priority == p_slave2->i_priority);
assert(p_found_list[j] == false); p_found_list[j] = true;
assert(p_slave1->i_type == p_slave2->i_type); i_found_slaves++;
assert(p_slave1->i_priority == p_slave2->i_priority); break;
p_found_list[j] = true;
break;
}
} }
} }
for (unsigned int i = 0; i < i_expected_slaves; ++i)
{
printf("Check if slaves[%d] is found\n", i);
assert(p_found_list[i]);
}
free(p_found_list);
} }
assert(i_expected_slaves == i_found_slaves);
for (unsigned int i = 0; i < i_expected_slaves; ++i)
{
printf("Check if slaves[%d] is found\n", i);
assert(p_found_list[i]);
}
free(p_found_list);
libvlc_media_slaves_release(pp_slaves, i_slave_count); libvlc_media_slaves_release(pp_slaves, i_slave_count);
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment