Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
fontconfig
fontconfig
Commits
fb7be6d6
Commit
fb7be6d6
authored
Mar 14, 2018
by
Akira TAGOH
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add a testcase for FcNameParse
parent
4699406a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
94 additions
and
0 deletions
+94
-0
test/Makefile.am
test/Makefile.am
+4
-0
test/test-name-parse.c
test/test-name-parse.c
+90
-0
No files found.
test/Makefile.am
View file @
fb7be6d6
...
...
@@ -55,6 +55,10 @@ check_PROGRAMS += test-bz96676
test_bz96676_LDADD
=
$(top_builddir)
/src/libfontconfig.la
TESTS
+=
test-bz96676
check_PROGRAMS
+=
test-name-parse
test_name_parse_LDADD
=
$(top_builddir)
/src/libfontconfig.la
TESTS
+=
test-name-parse
EXTRA_DIST
=
run-test.sh
$(TESTDATA)
out.expected-long-family-names out.expected-no-long-family-names
CLEANFILES
=
out fonts.conf
...
...
test/test-name-parse.c
0 → 100644
View file @
fb7be6d6
#include <fontconfig/fontconfig.h>
#include <stdio.h>
int
test
(
const
FcChar8
*
query
,
const
FcPattern
*
expect
)
{
FcPattern
*
pat
;
int
c
=
0
;
c
++
;
pat
=
FcNameParse
(
query
);
if
(
!
pat
)
goto
bail
;
c
++
;
if
(
!
FcPatternEqual
(
pat
,
expect
))
goto
bail
;
c
=
0
;
bail:
FcPatternDestroy
(
pat
);
return
c
;
}
#define BEGIN(x) (x) = FcPatternCreate (); c++;
#define END(x) FcPatternDestroy (x); (x) = NULL
int
main
(
void
)
{
FcPattern
*
pat
,
*
expect
;
int
c
=
0
,
ret
;
BEGIN
(
expect
)
{
FcPatternAddString
(
expect
,
FC_FAMILY
,
(
const
FcChar8
*
)
"sans-serif"
);
if
((
ret
=
test
((
const
FcChar8
*
)
"sans
\\
-serif"
,
expect
))
!=
0
)
goto
bail
;
}
END
(
expect
);
BEGIN
(
expect
)
{
FcPatternAddString
(
expect
,
FC_FAMILY
,
(
const
FcChar8
*
)
"Foo"
);
FcPatternAddInteger
(
expect
,
FC_SIZE
,
10
);
if
((
ret
=
test
((
const
FcChar8
*
)
"Foo-10"
,
expect
))
!=
0
)
goto
bail
;
}
END
(
expect
);
BEGIN
(
expect
)
{
FcPatternAddString
(
expect
,
FC_FAMILY
,
(
const
FcChar8
*
)
"Foo"
);
FcPatternAddString
(
expect
,
FC_FAMILY
,
(
const
FcChar8
*
)
"Bar"
);
FcPatternAddInteger
(
expect
,
FC_SIZE
,
10
);
if
((
ret
=
test
((
const
FcChar8
*
)
"Foo,Bar-10"
,
expect
))
!=
0
)
goto
bail
;
}
END
(
expect
);
BEGIN
(
expect
)
{
FcPatternAddString
(
expect
,
FC_FAMILY
,
(
const
FcChar8
*
)
"Foo"
);
FcPatternAddInteger
(
expect
,
FC_WEIGHT
,
FC_WEIGHT_MEDIUM
);
if
((
ret
=
test
((
const
FcChar8
*
)
"Foo:weight=medium"
,
expect
))
!=
0
)
goto
bail
;
}
END
(
expect
);
BEGIN
(
expect
)
{
FcPatternAddString
(
expect
,
FC_FAMILY
,
(
const
FcChar8
*
)
"Foo"
);
FcPatternAddInteger
(
expect
,
FC_WEIGHT
,
FC_WEIGHT_MEDIUM
);
if
((
ret
=
test
((
const
FcChar8
*
)
"Foo:weight_medium"
,
expect
))
!=
0
)
goto
bail
;
}
END
(
expect
);
BEGIN
(
expect
)
{
FcPatternAddInteger
(
expect
,
FC_WEIGHT
,
FC_WEIGHT_MEDIUM
);
if
((
ret
=
test
((
const
FcChar8
*
)
":medium"
,
expect
))
!=
0
)
goto
bail
;
}
END
(
expect
);
BEGIN
(
expect
)
{
FcPatternAddInteger
(
expect
,
FC_WIDTH
,
FC_WIDTH_NORMAL
);
if
((
ret
=
test
((
const
FcChar8
*
)
":normal"
,
expect
))
!=
0
)
goto
bail
;
}
END
(
expect
);
BEGIN
(
expect
)
{
FcPatternAddInteger
(
expect
,
FC_WIDTH
,
FC_WIDTH_NORMAL
);
if
((
ret
=
test
((
const
FcChar8
*
)
":normal"
,
expect
))
!=
0
)
goto
bail
;
}
END
(
expect
);
BEGIN
(
expect
)
{
FcRange
*
r
=
FcRangeCreateDouble
(
FC_WEIGHT_MEDIUM
,
FC_WEIGHT_BOLD
);
FcPatternAddRange
(
expect
,
FC_WEIGHT
,
r
);
FcRangeDestroy
(
r
);
if
((
ret
=
test
((
const
FcChar8
*
)
":weight=[medium bold]"
,
expect
))
!=
0
)
goto
bail
;
}
END
(
expect
);
bail:
if
(
expect
)
FcPatternDestroy
(
expect
);
return
ret
==
0
?
0
:
(
c
-
1
)
*
2
+
ret
;
}
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