[vlc-commits] epg: fix current replacement and add tests
Francois Cartegnie
git at videolan.org
Sun Mar 6 21:17:55 CET 2016
vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Sun Mar 6 21:02:55 2016 +0100| [c91def4bac51049f9aad234592c22004ea1875bc] | committer: Francois Cartegnie
epg: fix current replacement and add tests
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=c91def4bac51049f9aad234592c22004ea1875bc
---
src/misc/epg.c | 7 +++++--
test/src/misc/epg.c | 26 +++++++++++++++++++++++++-
2 files changed, 30 insertions(+), 3 deletions(-)
diff --git a/src/misc/epg.c b/src/misc/epg.c
index 2541a5a..f2cfa98 100644
--- a/src/misc/epg.c
+++ b/src/misc/epg.c
@@ -195,7 +195,7 @@ void vlc_epg_Merge( vlc_epg_t *p_dst_epg, const vlc_epg_t *p_src_epg )
int i_src=0;
for( ; i_src < p_src_epg->i_event; i_src++ )
{
- const bool b_current = ( p_src_epg->pp_event[i_src] == p_src_epg->p_current );
+ bool b_current = ( p_src_epg->pp_event[i_src] == p_src_epg->p_current );
vlc_epg_event_t *p_src = vlc_epg_Event_Duplicate( p_src_epg->pp_event[i_src] );
if( unlikely(!p_src) )
@@ -218,8 +218,11 @@ void vlc_epg_Merge( vlc_epg_t *p_dst_epg, const vlc_epg_t *p_src_epg )
( i_dst_end > p_src->i_start && i_dst_end <= i_src_end ) )
{
vlc_epg_Event_Delete( p_dst );
- if( p_dst_epg->p_current )
+ if( p_dst_epg->p_current == p_dst )
+ {
+ b_current |= true;
p_dst_epg->p_current = NULL;
+ }
TAB_ERASE( p_dst_epg->i_event, p_dst_epg->pp_event, i_dst );
}
else
diff --git a/test/src/misc/epg.c b/test/src/misc/epg.c
index 8f5a571..96eeb86 100644
--- a/test/src/misc/epg.c
+++ b/test/src/misc/epg.c
@@ -43,6 +43,8 @@ static void print_order( const vlc_epg_t *p_epg )
printf("order: ");
for( int i=0; i<p_epg->i_event; i++ )
printf("%s ", p_epg->pp_event[i]->psz_name );
+ if( p_epg->p_current )
+ printf(" current %s", p_epg->p_current->psz_name );
printf("\n");
}
@@ -173,7 +175,7 @@ int main( void )
print_order( p_epg );
assert_events( p_epg, "ECD", 3 );
- assert_current( p_epg, NULL );
+ assert_current( p_epg, "E" );
EPG_ADD( p_epg2, 70, 42, "F" );
print_order( p_epg2 );
@@ -182,6 +184,28 @@ int main( void )
print_order( p_epg );
assert_events( p_epg, "F", 1 );
+ /* Test current overwriting */
+ printf("--test %d\n", i++);
+ vlc_epg_SetCurrent( p_epg, 70 );
+ assert_current( p_epg, "F" );
+ print_order( p_epg );
+ print_order( p_epg2 );
+ vlc_epg_Merge( p_epg, p_epg2 );
+ printf("merged " );
+ print_order( p_epg );
+ assert_events( p_epg, "F", 1 );
+ assert_current( p_epg, "F" );
+
+ printf("--test %d\n", i++);
+ print_order( p_epg );
+ EPG_ADD( p_epg2, 270, 42, "Z" );
+ vlc_epg_SetCurrent( p_epg2, 270 );
+ print_order( p_epg2 );
+ vlc_epg_Merge( p_epg, p_epg2 );
+ printf("merged " );
+ print_order( p_epg );
+ assert_current( p_epg, "Z" );
+
vlc_epg_Delete( p_epg );
vlc_epg_Delete( p_epg2 );
More information about the vlc-commits
mailing list