Commit 9ce67f5b authored by Daniel Kamil Kozar's avatar Daniel Kamil Kozar Committed by Jean-Paul Saman

add tests for the local time offset descriptor

Signed-off-by: default avatarJean-Paul Saman <jpsaman@videolan.org>
parent b03fd26f
...@@ -340,4 +340,8 @@ ...@@ -340,4 +340,8 @@
<array name="p_pages" len_name="i_pages_number" min_size="1" type="dvbpsi_teletextpage_t"/> <array name="p_pages" len_name="i_pages_number" min_size="1" type="dvbpsi_teletextpage_t"/>
</descriptor> </descriptor>
<descriptor name="local time offset" sname="local_time_offset" fname="LocalTimeOffset">
<array name="p_local_time_offset" len_name="i_local_time_offsets_number" min_size="1" type="dvbpsi_local_time_offset_t"/>
</descriptor>
</dr> </dr>
...@@ -2177,6 +2177,30 @@ static int main_teletext_(void) ...@@ -2177,6 +2177,30 @@ static int main_teletext_(void)
return i_err; return i_err;
} }
/* local time offset */
static int main_local_time_offset_(void)
{
BOZO_VARS(local_time_offset);
BOZO_START(local time offset);
/* check p_local_time_offset */
BOZO_init_array(i_local_time_offsets_number);
BOZO_begin_array(p_local_time_offset)
BOZO_loop_array_begin(p_local_time_offset, i_local_time_offsets_number, 1)
BOZO_DOJOB(LocalTimeOffset);
BOZO_check_array_begin(p_local_time_offset, i_local_time_offsets_number)
BOZO_check_array_cmp(p_local_time_offset, i_local_time_offsets_number, dvbpsi_local_time_offset_t)
BOZO_CLEAN();
BOZO_loop_array_end(p_local_time_offset, ARRAY_SIZE(s_decoded.p_local_time_offset))
BOZO_end_array
BOZO_END(local time offset);
return i_err;
}
/* main function */ /* main function */
int main(void) int main(void)
...@@ -2230,6 +2254,7 @@ int main(void) ...@@ -2230,6 +2254,7 @@ int main(void)
i_err |= main_content_(); i_err |= main_content_();
i_err |= main_parental_rating_(); i_err |= main_parental_rating_();
i_err |= main_teletext_(); i_err |= main_teletext_();
i_err |= main_local_time_offset_();
if(i_err) if(i_err)
fprintf(stderr, "At least one test has FAILED !!!\n"); fprintf(stderr, "At least one test has FAILED !!!\n");
......
...@@ -72,3 +72,26 @@ static int compare_dvbpsi_teletextpage_t(const void *s1, const void *s2) ...@@ -72,3 +72,26 @@ static int compare_dvbpsi_teletextpage_t(const void *s1, const void *s2)
a->i_teletext_page_number > b->i_teletext_page_number) return 1; a->i_teletext_page_number > b->i_teletext_page_number) return 1;
else return 0; else return 0;
} }
static int compare_dvbpsi_local_time_offset_t(const void *s1, const void *s2)
{
const dvbpsi_local_time_offset_t *a = s1, *b = s2;
int iso_cmp = memcmp(a->i_country_code, b->i_country_code,
sizeof(a->i_country_code));
uint8_t a_cr_id = (a->i_country_region_id & 0x3f),
a_ltop = (a->i_local_time_offset_polarity & 1),
b_cr_id = (b->i_country_region_id & 0x3f),
b_ltop = (b->i_local_time_offset_polarity & 1);
uint64_t a_toc = (a->i_time_of_change & 0xffffffffff),
b_toc = (b->i_time_of_change & 0xffffffffff);
if(iso_cmp < 0 || a_cr_id < b_cr_id || a_ltop < b_ltop ||
a->i_local_time_offset < b->i_local_time_offset ||
a_toc < b_toc || a->i_next_time_offset < b->i_next_time_offset)
return -1;
else if(iso_cmp > 0 || a_cr_id > b_cr_id || a_ltop > b_ltop ||
a->i_local_time_offset > b->i_local_time_offset ||
a_toc > b_toc || a->i_next_time_offset > b->i_next_time_offset)
return 1;
else return 0;
}
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