Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc-gpu
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-gpu
Commits
c862c0fc
Commit
c862c0fc
authored
Oct 08, 2010
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Test case for vlc_strcasestr()
parent
027cc99e
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
48 additions
and
1 deletion
+48
-1
src/test/utf8.c
src/test/utf8.c
+48
-1
No files found.
src/test/utf8.c
View file @
c862c0fc
...
...
@@ -24,11 +24,12 @@
#endif
#include <vlc_common.h>
#include
"vlc_charset.h"
#include
<vlc_charset.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <locale.h>
static
void
test
(
const
char
*
in
,
const
char
*
out
)
{
...
...
@@ -68,8 +69,40 @@ static void test (const char *in, const char *out)
free
(
str
);
}
static
void
test_strcasestr
(
const
char
*
h
,
const
char
*
n
,
size_t
offset
)
{
printf
(
"
\"
%s
\"
should %sbe found in
\"
%s
\"
...
\n
"
,
n
,
(
offset
!=
-
1
)
?
""
:
"not "
,
h
);
const
char
*
ret
=
vlc_strcasestr
(
h
,
n
);
if
(
offset
==
-
1
)
{
if
(
ret
!=
NULL
)
{
printf
(
"ERROR: got
\"
%s
\"\n
"
,
ret
);
exit
(
10
);
}
}
else
{
if
(
ret
==
NULL
)
{
printf
(
"ERROR: not found
\n
"
);
exit
(
11
);
}
if
((
ret
-
h
)
!=
offset
)
{
printf
(
"ERROR: got
\"
%s
\"
instead of
\"
%s
\"\n
"
,
ret
,
h
+
offset
);
exit
(
12
);
}
}
}
int
main
(
void
)
{
setlocale
(
LC_CTYPE
,
"fr_FR"
);
(
void
)
setvbuf
(
stdout
,
NULL
,
_IONBF
,
0
);
test
(
""
,
""
);
...
...
@@ -85,5 +118,19 @@ int main (void)
test
(
"
\xC1\x94\xC3\xa9
l
\xC3\xA9
vision"
,
"??élévision"
);
/* overlong */
test
(
"Hel
\xF0\x83\x85\x87
lo"
,
"Hel????lo"
);
/* more overlong */
test_strcasestr
(
""
,
""
,
0
);
test_strcasestr
(
""
,
"a"
,
-
1
);
test_strcasestr
(
"a"
,
""
,
0
);
test_strcasestr
(
"heLLo"
,
"l"
,
2
);
test_strcasestr
(
"heLLo"
,
"lo"
,
3
);
test_strcasestr
(
"heLLo"
,
"llo"
,
2
);
test_strcasestr
(
"heLLo"
,
"la"
,
-
1
);
test_strcasestr
(
"heLLo"
,
"oa"
,
-
1
);
test_strcasestr
(
"Télé"
,
"é"
,
1
);
test_strcasestr
(
"Télé"
,
"É"
,
1
);
test_strcasestr
(
"Télé"
,
"Élé"
,
1
);
test_strcasestr
(
"Télé"
,
"léé"
,
-
1
);
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