Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
V
vlc
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
13
Issues
13
List
Boards
Labels
Service Desk
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
GSoC
GSoC2018
macOS
vlc
Commits
f630cb66
Commit
f630cb66
authored
Feb 13, 2016
by
François Cartegnie
🤞
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
epg: add tests
parent
d9db85c3
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
192 additions
and
0 deletions
+192
-0
test/Makefile.am
test/Makefile.am
+3
-0
test/src/misc/epg.c
test/src/misc/epg.c
+189
-0
No files found.
test/Makefile.am
View file @
f630cb66
...
...
@@ -24,6 +24,7 @@ check_PROGRAMS = \
test_src_input_stream
\
test_src_interface_dialog
\
test_src_misc_bits
\
test_src_misc_epg
\
test_modules_packetizer_hxxx
\
test_modules_keystore
\
test_modules_tls
\
...
...
@@ -93,6 +94,8 @@ test_src_input_stream_net_CFLAGS = $(AM_CFLAGS) -DTEST_NET
test_src_input_stream_net_LDADD
=
$(LIBVLCCORE)
$(LIBVLC)
test_src_misc_bits_SOURCES
=
src/misc/bits.c
test_src_misc_bits_LDADD
=
$(LIBVLC)
test_src_misc_epg_SOURCES
=
src/misc/epg.c
test_src_misc_epg_LDADD
=
$(LIBVLC)
test_src_interface_dialog_SOURCES
=
src/interface/dialog.c
test_src_interface_dialog_LDADD
=
$(LIBVLCCORE)
$(LIBVLC)
test_modules_packetizer_hxxx_SOURCES
=
modules/packetizer/hxxx.c
...
...
test/src/misc/epg.c
0 → 100644
View file @
f630cb66
/*****************************************************************************
* epg.c test EPG
*****************************************************************************
* Copyright (C) 2016 - VideoLAN Authors
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*****************************************************************************/
#include "../../libvlc/test.h"
#ifdef NDEBUG
#undef NDEBUG
#endif
#include <vlc_common.h>
#include <vlc_epg.h>
#include <assert.h>
static
void
assert_current
(
const
vlc_epg_t
*
p_epg
,
const
char
*
psz_name
)
{
if
(
(
void
*
)
psz_name
==
(
void
*
)
p_epg
->
p_current
)
{
assert
(
psz_name
==
NULL
);
}
else
{
assert
(
p_epg
->
p_current
);
assert
(
p_epg
->
p_current
->
psz_name
);
assert
(
psz_name
[
0
]
==
p_epg
->
p_current
->
psz_name
[
0
]
);
}
}
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
);
printf
(
"
\n
"
);
}
static
void
assert_events
(
const
vlc_epg_t
*
p_epg
,
const
char
*
psz_names
,
int
i_names
)
{
assert
(
p_epg
->
i_event
==
i_names
);
for
(
int
i
=
0
;
i
<
p_epg
->
i_event
;
i
++
)
{
assert
(
p_epg
->
pp_event
[
i
]
->
psz_name
&&
p_epg
->
pp_event
[
i
]
->
psz_name
[
0
]
==
psz_names
[
i
]
);
}
}
#define EPG_ADD(epg, start, duration, a) \
vlc_epg_AddEvent( epg, start, duration, a, NULL, NULL, 0 )
int
main
(
void
)
{
test_init
();
int
i
=
1
;
/* Simple insert/current test */
printf
(
"--test %d
\n
"
,
i
++
);
vlc_epg_t
*
p_epg
=
vlc_epg_New
(
NULL
);
assert
(
p_epg
);
EPG_ADD
(
p_epg
,
42
,
20
,
"A"
);
EPG_ADD
(
p_epg
,
62
,
20
,
"B"
);
EPG_ADD
(
p_epg
,
82
,
20
,
"C"
);
EPG_ADD
(
p_epg
,
102
,
20
,
"D"
);
print_order
(
p_epg
);
assert_events
(
p_epg
,
"ABCD"
,
4
);
assert_current
(
p_epg
,
NULL
);
vlc_epg_SetCurrent
(
p_epg
,
82
);
assert_current
(
p_epg
,
"C"
);
vlc_epg_Delete
(
p_epg
);
/* Test reordering / head/tail inserts */
printf
(
"--test %d
\n
"
,
i
++
);
p_epg
=
vlc_epg_New
(
NULL
);
assert
(
p_epg
);
EPG_ADD
(
p_epg
,
82
,
20
,
"C"
);
EPG_ADD
(
p_epg
,
62
,
20
,
"B"
);
EPG_ADD
(
p_epg
,
102
,
20
,
"D"
);
EPG_ADD
(
p_epg
,
42
,
20
,
"A"
);
print_order
(
p_epg
);
assert_events
(
p_epg
,
"ABCD"
,
4
);
vlc_epg_Delete
(
p_epg
);
/* Test reordering/bisect lookup on insert */
printf
(
"--test %d
\n
"
,
i
++
);
p_epg
=
vlc_epg_New
(
NULL
);
assert
(
p_epg
);
EPG_ADD
(
p_epg
,
142
,
20
,
"F"
);
EPG_ADD
(
p_epg
,
122
,
20
,
"E"
);
EPG_ADD
(
p_epg
,
102
,
20
,
"D"
);
EPG_ADD
(
p_epg
,
82
,
20
,
"C"
);
EPG_ADD
(
p_epg
,
42
,
20
,
"A"
);
EPG_ADD
(
p_epg
,
62
,
20
,
"B"
);
print_order
(
p_epg
);
assert_events
(
p_epg
,
"ABCDEF"
,
6
);
vlc_epg_Delete
(
p_epg
);
/* Test deduplication and current pointer rebasing on insert */
printf
(
"--test %d
\n
"
,
i
++
);
p_epg
=
vlc_epg_New
(
NULL
);
assert
(
p_epg
);
EPG_ADD
(
p_epg
,
62
,
20
,
"E"
);
EPG_ADD
(
p_epg
,
62
,
20
,
"F"
);
EPG_ADD
(
p_epg
,
42
,
20
,
"A"
);
vlc_epg_SetCurrent
(
p_epg
,
62
);
EPG_ADD
(
p_epg
,
82
,
20
,
"C"
);
EPG_ADD
(
p_epg
,
62
,
20
,
"B"
);
EPG_ADD
(
p_epg
,
102
,
20
,
"D"
);
print_order
(
p_epg
);
assert_events
(
p_epg
,
"ABCD"
,
4
);
assert_current
(
p_epg
,
"B"
);
vlc_epg_Delete
(
p_epg
);
/* Test epg merging */
printf
(
"--test %d
\n
"
,
i
++
);
p_epg
=
vlc_epg_New
(
NULL
);
assert
(
p_epg
);
EPG_ADD
(
p_epg
,
142
,
20
,
"F"
);
EPG_ADD
(
p_epg
,
122
,
20
,
"E"
);
EPG_ADD
(
p_epg
,
42
,
20
,
"A"
);
EPG_ADD
(
p_epg
,
62
,
20
,
"B"
);
print_order
(
p_epg
);
vlc_epg_t
*
p_epg2
=
vlc_epg_New
(
NULL
);
assert
(
p_epg2
);
EPG_ADD
(
p_epg2
,
102
,
20
,
"D"
);
EPG_ADD
(
p_epg2
,
82
,
20
,
"C"
);
print_order
(
p_epg2
);
vlc_epg_Merge
(
p_epg
,
p_epg2
);
printf
(
"merged "
);
print_order
(
p_epg
);
assert_events
(
p_epg
,
"ABCDEF"
,
6
);
assert_events
(
p_epg2
,
"CD"
,
2
);
/* should be untouched */
vlc_epg_Delete
(
p_epg
);
vlc_epg_Delete
(
p_epg2
);
/* Test event overlapping */
printf
(
"--test %d
\n
"
,
i
++
);
p_epg
=
vlc_epg_New
(
NULL
);
assert
(
p_epg
);
EPG_ADD
(
p_epg
,
42
,
20
,
"A"
);
EPG_ADD
(
p_epg
,
62
,
20
,
"B"
);
EPG_ADD
(
p_epg
,
82
,
20
,
"C"
);
EPG_ADD
(
p_epg
,
102
,
20
,
"D"
);
print_order
(
p_epg
);
vlc_epg_SetCurrent
(
p_epg
,
62
);
p_epg2
=
vlc_epg_New
(
NULL
);
assert
(
p_epg2
);
EPG_ADD
(
p_epg2
,
41
,
30
,
"E"
);
print_order
(
p_epg2
);
vlc_epg_Merge
(
p_epg
,
p_epg2
);
printf
(
"merged "
);
print_order
(
p_epg
);
assert_events
(
p_epg
,
"ECD"
,
3
);
assert_current
(
p_epg
,
NULL
);
EPG_ADD
(
p_epg2
,
70
,
42
,
"F"
);
print_order
(
p_epg2
);
vlc_epg_Merge
(
p_epg
,
p_epg2
);
printf
(
"merged "
);
print_order
(
p_epg
);
assert_events
(
p_epg
,
"F"
,
1
);
vlc_epg_Delete
(
p_epg
);
vlc_epg_Delete
(
p_epg2
);
return
0
;
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment