Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Third Party Harfbuzz
提交
6af9cff5
T
Third Party Harfbuzz
项目概览
OpenHarmony
/
Third Party Harfbuzz
1 年多 前同步成功
通知
0
Star
18
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
Third Party Harfbuzz
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
6af9cff5
编写于
4月 29, 2011
作者:
B
Behdad Esfahbod
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[test/unicode] Use text fixture instead of static variables
上级
13db3d40
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
74 addition
and
49 deletion
+74
-49
src/hb-unicode-private.hh
src/hb-unicode-private.hh
+1
-1
src/hb-unicode.h
src/hb-unicode.h
+1
-1
test/test-buffer.c
test/test-buffer.c
+1
-1
test/test-c.c
test/test-c.c
+1
-0
test/test-common.c
test/test-common.c
+2
-1
test/test-cplusplus.cc
test/test-cplusplus.cc
+1
-0
test/test-unicode.c
test/test-unicode.c
+67
-45
未找到文件。
src/hb-unicode-private.hh
浏览文件 @
6af9cff5
/*
/*
* Copyright © 2009 Red Hat, Inc.
* Copyright © 2009 Red Hat, Inc.
* Copyright © 2011 Codethink Limited
* Copyright © 2011
Codethink Limited
* Copyright © 2010,2011 Google, Inc.
* Copyright © 2010,2011 Google, Inc.
*
*
* This is part of HarfBuzz, a text shaping library.
* This is part of HarfBuzz, a text shaping library.
...
...
src/hb-unicode.h
浏览文件 @
6af9cff5
/*
/*
* Copyright © 2009 Red Hat, Inc.
* Copyright © 2009 Red Hat, Inc.
* Copyright © 2011 Codethink Limited
* Copyright © 2011
Codethink Limited
* Copyright © 2011 Google, Inc.
* Copyright © 2011 Google, Inc.
*
*
* This is part of HarfBuzz, a text shaping library.
* This is part of HarfBuzz, a text shaping library.
...
...
test/test-buffer.c
浏览文件 @
6af9cff5
...
@@ -26,7 +26,7 @@
...
@@ -26,7 +26,7 @@
#include "hb-test.h"
#include "hb-test.h"
/*
This file tests types defined in
hb-buffer.h */
/*
Unit tests for
hb-buffer.h */
static
const
char
utf8
[
10
]
=
"ab
\360\240\200\200
defg"
;
static
const
char
utf8
[
10
]
=
"ab
\360\240\200\200
defg"
;
...
...
test/test-c.c
浏览文件 @
6af9cff5
...
@@ -26,6 +26,7 @@
...
@@ -26,6 +26,7 @@
/* This file tests that all headers can be included from .c files */
/* This file tests that all headers can be included from .c files */
#include <config.h>
#include <config.h>
#include <hb.h>
#include <hb.h>
...
...
test/test-common.c
浏览文件 @
6af9cff5
...
@@ -26,7 +26,8 @@
...
@@ -26,7 +26,8 @@
#include "hb-test.h"
#include "hb-test.h"
/* This file tests types defined in hb-common.h */
/* Unit tests for hb-common.h */
static
void
static
void
test_types_int
(
void
)
test_types_int
(
void
)
...
...
test/test-cplusplus.cc
浏览文件 @
6af9cff5
...
@@ -26,4 +26,5 @@
...
@@ -26,4 +26,5 @@
/* This file tests that all headers can be included from .cc files */
/* This file tests that all headers can be included from .cc files */
#include "test-c.c"
#include "test-c.c"
test/test-unicode.c
浏览文件 @
6af9cff5
/*
/*
* Copyright © 2011 Codethink Limited
* Copyright © 2011 Codethink Limited
* Copyright © 2011 Google, Inc.
*
*
* This is part of HarfBuzz, a text shaping library.
* This is part of HarfBuzz, a text shaping library.
*
*
...
@@ -22,11 +23,13 @@
...
@@ -22,11 +23,13 @@
* PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
* PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
*
*
* Codethink Author(s): Ryan Lortie
* Codethink Author(s): Ryan Lortie
* Google Author(s): Behdad Esfahbod
*/
*/
#include "hb-test.h"
#include "hb-test.h"
/* This file tests the unicode virtual functions interface */
/* Unit tests for hb-unicode.h */
static
void
static
void
test_unicode_nil
(
void
)
test_unicode_nil
(
void
)
...
@@ -54,20 +57,36 @@ test_unicode_default (void)
...
@@ -54,20 +57,36 @@ test_unicode_default (void)
g_assert_cmpint
(
hb_unicode_get_script
(
uf
,
'd'
),
==
,
HB_SCRIPT_LATIN
);
g_assert_cmpint
(
hb_unicode_get_script
(
uf
,
'd'
),
==
,
HB_SCRIPT_LATIN
);
}
}
static
gboolean
freed0
,
freed1
;
static
int
unique_pointer0
[
1
];
#define MAGIC0 0x12345678
static
int
unique_pointer1
[
1
];
#define MAGIC1 0x76543210
static
void
free_up
(
void
*
up
)
typedef
struct
{
int
value
;
gboolean
freed
;
}
data_t
;
typedef
struct
{
data_t
data
[
2
];
}
data_fixture_t
;
static
void
data_fixture_init
(
data_fixture_t
*
f
,
gconstpointer
user_data
)
{
f
->
data
[
0
].
value
=
MAGIC0
;
f
->
data
[
1
].
value
=
MAGIC1
;
}
static
void
data_fixture_finish
(
data_fixture_t
*
f
,
gconstpointer
user_data
)
{
{
if
(
up
==
unique_pointer0
)
{
}
g_assert
(
!
freed0
);
freed0
=
TRUE
;
static
void
free_up
(
void
*
p
)
}
else
if
(
up
==
unique_pointer1
)
{
{
g_assert
(
!
freed1
)
;
data_t
*
data
=
(
data_t
*
)
p
;
freed1
=
TRUE
;
}
else
{
g_assert
(
data
->
value
==
MAGIC0
||
data
->
value
==
MAGIC1
);
g_assert_not_reached
(
);
g_assert
(
data
->
freed
==
FALSE
);
}
data
->
freed
=
TRUE
;
}
}
static
hb_script_t
static
hb_script_t
...
@@ -75,8 +94,11 @@ simple_get_script (hb_unicode_funcs_t *ufuncs,
...
@@ -75,8 +94,11 @@ simple_get_script (hb_unicode_funcs_t *ufuncs,
hb_codepoint_t
codepoint
,
hb_codepoint_t
codepoint
,
void
*
user_data
)
void
*
user_data
)
{
{
data_t
*
data
=
(
data_t
*
)
user_data
;
g_assert
(
hb_unicode_funcs_get_parent
(
ufuncs
)
==
NULL
);
g_assert
(
hb_unicode_funcs_get_parent
(
ufuncs
)
==
NULL
);
g_assert
(
unique_pointer0
==
user_data
);
g_assert
(
data
->
value
==
MAGIC0
);
g_assert
(
data
->
freed
==
FALSE
);
if
(
'a'
<=
codepoint
&&
codepoint
<=
'z'
)
if
(
'a'
<=
codepoint
&&
codepoint
<=
'z'
)
return
HB_SCRIPT_LATIN
;
return
HB_SCRIPT_LATIN
;
...
@@ -85,30 +107,31 @@ simple_get_script (hb_unicode_funcs_t *ufuncs,
...
@@ -85,30 +107,31 @@ simple_get_script (hb_unicode_funcs_t *ufuncs,
}
}
static
void
static
void
test_unicode_custom
(
void
)
test_unicode_custom
(
data_fixture_t
*
f
,
gconstpointer
user_data
)
{
{
hb_unicode_funcs_t
*
uf
=
hb_unicode_funcs_create
(
NULL
);
hb_unicode_funcs_t
*
uf
=
hb_unicode_funcs_create
(
NULL
);
hb_unicode_funcs_set_script_func
(
uf
,
simple_get_script
,
hb_unicode_funcs_set_script_func
(
uf
,
simple_get_script
,
unique_pointer0
,
free_up
);
&
f
->
data
[
0
]
,
free_up
);
g_assert_cmpint
(
hb_unicode_get_script
(
uf
,
'a'
),
==
,
HB_SCRIPT_LATIN
);
g_assert_cmpint
(
hb_unicode_get_script
(
uf
,
'a'
),
==
,
HB_SCRIPT_LATIN
);
g_assert_cmpint
(
hb_unicode_get_script
(
uf
,
'0'
),
==
,
HB_SCRIPT_UNKNOWN
);
g_assert_cmpint
(
hb_unicode_get_script
(
uf
,
'0'
),
==
,
HB_SCRIPT_UNKNOWN
);
g_assert
(
!
f
reed0
&&
!
freed1
);
g_assert
(
!
f
->
data
[
0
].
freed
&&
!
f
->
data
[
1
].
freed
);
hb_unicode_funcs_destroy
(
uf
);
hb_unicode_funcs_destroy
(
uf
);
g_assert
(
freed0
&&
!
freed1
);
g_assert
(
f
->
data
[
0
].
freed
&&
!
f
->
data
[
1
].
freed
);
freed0
=
FALSE
;
}
}
static
hb_script_t
static
hb_script_t
a_is_for_arabic_get_script
(
hb_unicode_funcs_t
*
ufuncs
,
a_is_for_arabic_get_script
(
hb_unicode_funcs_t
*
ufuncs
,
hb_codepoint_t
codepoint
,
hb_codepoint_t
codepoint
,
void
*
user_data
)
void
*
user_data
)
{
{
data_t
*
data
=
(
data_t
*
)
user_data
;
g_assert
(
hb_unicode_funcs_get_parent
(
ufuncs
)
!=
NULL
);
g_assert
(
hb_unicode_funcs_get_parent
(
ufuncs
)
!=
NULL
);
g_assert
(
user_data
==
unique_pointer1
);
g_assert
(
data
->
value
==
MAGIC1
);
g_assert
(
data
->
freed
==
FALSE
);
if
(
codepoint
==
'a'
)
{
if
(
codepoint
==
'a'
)
{
return
HB_SCRIPT_ARABIC
;
return
HB_SCRIPT_ARABIC
;
...
@@ -120,7 +143,7 @@ a_is_for_arabic_get_script (hb_unicode_funcs_t *ufuncs,
...
@@ -120,7 +143,7 @@ a_is_for_arabic_get_script (hb_unicode_funcs_t *ufuncs,
}
}
static
void
static
void
test_unicode_subclassing_nil
(
void
)
test_unicode_subclassing_nil
(
data_fixture_t
*
f
,
gconstpointer
user_data
)
{
{
hb_unicode_funcs_t
*
uf
,
*
aa
;
hb_unicode_funcs_t
*
uf
,
*
aa
;
...
@@ -131,67 +154,65 @@ test_unicode_subclassing_nil (void)
...
@@ -131,67 +154,65 @@ test_unicode_subclassing_nil (void)
hb_unicode_funcs_destroy
(
uf
);
hb_unicode_funcs_destroy
(
uf
);
hb_unicode_funcs_set_script_func
(
aa
,
a_is_for_arabic_get_script
,
hb_unicode_funcs_set_script_func
(
aa
,
a_is_for_arabic_get_script
,
unique_pointer1
,
free_up
);
&
f
->
data
[
1
]
,
free_up
);
g_assert_cmpint
(
hb_unicode_get_script
(
aa
,
'a'
),
==
,
HB_SCRIPT_ARABIC
);
g_assert_cmpint
(
hb_unicode_get_script
(
aa
,
'a'
),
==
,
HB_SCRIPT_ARABIC
);
g_assert_cmpint
(
hb_unicode_get_script
(
aa
,
'b'
),
==
,
HB_SCRIPT_UNKNOWN
);
g_assert_cmpint
(
hb_unicode_get_script
(
aa
,
'b'
),
==
,
HB_SCRIPT_UNKNOWN
);
g_assert
(
!
f
reed0
&&
!
freed1
);
g_assert
(
!
f
->
data
[
0
].
freed
&&
!
f
->
data
[
1
].
freed
);
hb_unicode_funcs_destroy
(
aa
);
hb_unicode_funcs_destroy
(
aa
);
g_assert
(
!
freed0
&&
freed1
);
g_assert
(
!
f
->
data
[
0
].
freed
&&
f
->
data
[
1
].
freed
);
freed1
=
FALSE
;
}
}
static
void
static
void
test_unicode_subclassing_
glib
(
void
)
test_unicode_subclassing_
default
(
data_fixture_t
*
f
,
gconstpointer
user_data
)
{
{
hb_unicode_funcs_t
*
uf
,
*
aa
;
hb_unicode_funcs_t
*
uf
,
*
aa
;
uf
=
hb_
glib_get_unicode_funcs
();
uf
=
hb_
unicode_funcs_get_default
();
aa
=
hb_unicode_funcs_create
(
uf
);
aa
=
hb_unicode_funcs_create
(
uf
);
hb_unicode_funcs_set_script_func
(
aa
,
a_is_for_arabic_get_script
,
hb_unicode_funcs_set_script_func
(
aa
,
a_is_for_arabic_get_script
,
unique_pointer1
,
free_up
);
&
f
->
data
[
1
]
,
free_up
);
g_assert_cmpint
(
hb_unicode_get_script
(
aa
,
'a'
),
==
,
HB_SCRIPT_ARABIC
);
g_assert_cmpint
(
hb_unicode_get_script
(
aa
,
'a'
),
==
,
HB_SCRIPT_ARABIC
);
g_assert_cmpint
(
hb_unicode_get_script
(
aa
,
'b'
),
==
,
HB_SCRIPT_LATIN
);
g_assert_cmpint
(
hb_unicode_get_script
(
aa
,
'b'
),
==
,
HB_SCRIPT_LATIN
);
g_assert
(
!
f
reed0
&&
!
freed1
);
g_assert
(
!
f
->
data
[
0
].
freed
&&
!
f
->
data
[
1
].
freed
);
hb_unicode_funcs_destroy
(
aa
);
hb_unicode_funcs_destroy
(
aa
);
g_assert
(
!
freed0
&&
freed1
);
g_assert
(
!
f
->
data
[
0
].
freed
&&
f
->
data
[
1
].
freed
);
freed1
=
FALSE
;
}
}
static
void
static
void
test_unicode_subclassing_deep
(
void
)
test_unicode_subclassing_deep
(
data_fixture_t
*
f
,
gconstpointer
user_data
)
{
{
hb_unicode_funcs_t
*
uf
,
*
aa
;
hb_unicode_funcs_t
*
uf
,
*
aa
;
uf
=
hb_unicode_funcs_create
(
NULL
);
uf
=
hb_unicode_funcs_create
(
NULL
);
hb_unicode_funcs_set_script_func
(
uf
,
simple_get_script
,
hb_unicode_funcs_set_script_func
(
uf
,
simple_get_script
,
unique_pointer0
,
free_up
);
&
f
->
data
[
0
]
,
free_up
);
aa
=
hb_unicode_funcs_create
(
uf
);
aa
=
hb_unicode_funcs_create
(
uf
);
hb_unicode_funcs_destroy
(
uf
);
hb_unicode_funcs_destroy
(
uf
);
/* make sure the 'uf' didn't get freed, since 'aa' holds a ref */
/* make sure the 'uf' didn't get freed, since 'aa' holds a ref */
g_assert
(
!
f
reed0
);
g_assert
(
!
f
->
data
[
0
].
freed
);
hb_unicode_funcs_set_script_func
(
aa
,
a_is_for_arabic_get_script
,
hb_unicode_funcs_set_script_func
(
aa
,
a_is_for_arabic_get_script
,
unique_pointer1
,
free_up
);
&
f
->
data
[
1
]
,
free_up
);
g_assert_cmpint
(
hb_unicode_get_script
(
aa
,
'a'
),
==
,
HB_SCRIPT_ARABIC
);
g_assert_cmpint
(
hb_unicode_get_script
(
aa
,
'a'
),
==
,
HB_SCRIPT_ARABIC
);
g_assert_cmpint
(
hb_unicode_get_script
(
aa
,
'b'
),
==
,
HB_SCRIPT_LATIN
);
g_assert_cmpint
(
hb_unicode_get_script
(
aa
,
'b'
),
==
,
HB_SCRIPT_LATIN
);
g_assert_cmpint
(
hb_unicode_get_script
(
aa
,
'0'
),
==
,
HB_SCRIPT_UNKNOWN
);
g_assert_cmpint
(
hb_unicode_get_script
(
aa
,
'0'
),
==
,
HB_SCRIPT_UNKNOWN
);
g_assert
(
!
f
reed0
&&
!
freed1
);
g_assert
(
!
f
->
data
[
0
].
freed
&&
!
f
->
data
[
1
].
freed
);
hb_unicode_funcs_destroy
(
aa
);
hb_unicode_funcs_destroy
(
aa
);
g_assert
(
freed0
&&
freed1
);
g_assert
(
f
->
data
[
0
].
freed
&&
f
->
data
[
1
].
freed
);
freed0
=
freed1
=
FALSE
;
}
}
int
int
main
(
int
argc
,
char
**
argv
)
main
(
int
argc
,
char
**
argv
)
{
{
...
@@ -200,10 +221,11 @@ main (int argc, char **argv)
...
@@ -200,10 +221,11 @@ main (int argc, char **argv)
hb_test_add
(
test_unicode_nil
);
hb_test_add
(
test_unicode_nil
);
hb_test_add
(
test_unicode_glib
);
hb_test_add
(
test_unicode_glib
);
hb_test_add
(
test_unicode_default
);
hb_test_add
(
test_unicode_default
);
hb_test_add
(
test_unicode_custom
);
hb_test_add
(
test_unicode_subclassing_nil
);
hb_test_add_fixture
(
data_fixture
,
NULL
,
test_unicode_custom
);
hb_test_add
(
test_unicode_subclassing_glib
);
hb_test_add_fixture
(
data_fixture
,
NULL
,
test_unicode_subclassing_nil
);
hb_test_add
(
test_unicode_subclassing_deep
);
hb_test_add_fixture
(
data_fixture
,
NULL
,
test_unicode_subclassing_default
);
hb_test_add_fixture
(
data_fixture
,
NULL
,
test_unicode_subclassing_deep
);
/* XXX test all methods for their defaults and various (glib, icu, default) implementations. */
/* XXX test all methods for their defaults and various (glib, icu, default) implementations. */
/* XXX test glib & icu two-way script conversion */
/* XXX test glib & icu two-way script conversion */
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录