Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
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
videolan
vlc
Commits
19bdca43
Commit
19bdca43
authored
Feb 15, 2008
by
Pierre d'Herbemont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test/dictionary.c: Add a new test entry for the vlc_dictionary_t type.
parent
14d79cf6
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
93 additions
and
0 deletions
+93
-0
src/test/dictionary.c
src/test/dictionary.c
+93
-0
No files found.
src/test/dictionary.c
0 → 100644
View file @
19bdca43
/*****************************************************************************
* dictionary.c: Tests for vlc_dictionary_t
*****************************************************************************
* Copyright (C) 2007 Pierre d'Herbemont
* $Id$
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <vlc/vlc.h>
#include "vlc_arrays.h"
#include <stdio.h>
#include <stdlib.h>
static
void
test_dictionary_validity
(
vlc_dictionary_t
*
p_dict
,
const
char
**
our_keys
,
int
size
)
{
/* Test values and keys now */
char
**
keys
=
vlc_dictionary_all_keys
(
p_dict
);
int
i
,
j
;
assert
(
keys
);
for
(
j
=
0
;
keys
[
j
];
j
++
)
{
vlc_bool_t
found
=
VLC_FALSE
;
for
(
i
=
0
;
i
<
size
;
i
++
)
{
if
(
!
strcmp
(
keys
[
j
],
our_keys
[
i
]
))
{
found
=
VLC_TRUE
;
break
;
}
}
free
(
keys
[
j
]
);
assert
(
found
);
}
free
(
keys
);
for
(
i
=
0
;
i
<
size
;
i
++
)
assert
(
vlc_dictionary_value_for_key
(
p_dict
,
our_keys
[
i
]
)
==
(
void
*
)
i
);
}
int
main
(
void
)
{
static
const
char
*
our_keys
[]
=
{
"Hello"
,
"Hella"
,
"flowmeter"
,
"Frostnipped"
,
"frostnipped"
,
"remiform"
,
"quadrifoliolate"
,
"singularity"
,
"unafflicted"
};
const
int
size
=
sizeof
(
our_keys
)
/
sizeof
(
our_keys
[
0
]);
char
**
keys
;
int
j
,
i
=
0
;
vlc_dictionary_t
dict
;
vlc_dictionary_init
(
&
dict
,
0
);
assert
(
vlc_dictionary_keys_count
(
&
dict
)
==
0
);
keys
=
vlc_dictionary_all_keys
(
&
dict
);
assert
(
keys
&&
!
keys
[
0
]
);
free
(
keys
);
/* Insert some values */
for
(
i
=
0
;
i
<
size
;
i
++
)
vlc_dictionary_insert
(
&
dict
,
our_keys
[
i
],
(
void
*
)
i
);
test_dictionary_validity
(
&
dict
,
our_keys
,
size
);
vlc_dictionary_remove_value_for_key
(
&
dict
,
our_keys
[
size
-
1
]
);
test_dictionary_validity
(
&
dict
,
our_keys
,
size
-
1
);
vlc_dictionary_clear
(
&
dict
);
assert
(
vlc_dictionary_keys_count
(
&
dict
)
==
0
);
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