Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
f7144704
X
Xts Acts
项目概览
OpenHarmony
/
Xts Acts
1 年多 前同步成功
通知
9
Star
22
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
X
Xts Acts
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
f7144704
编写于
5月 24, 2023
作者:
O
openharmony_ci
提交者:
Gitee
5月 24, 2023
浏览文件
操作
浏览文件
下载
差异文件
!8743 The issue of modifying XML test cases failed
Merge pull request !8743 from bihu/OpenHarmony-3.2-Release
上级
245f68a0
31fab1d7
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
314 addition
and
238 deletion
+314
-238
commonlibrary/ets_utils/xml_lib_standard/src/main/js/test/xml.test.js
...y/ets_utils/xml_lib_standard/src/main/js/test/xml.test.js
+314
-238
未找到文件。
commonlibrary/ets_utils/xml_lib_standard/src/main/js/test/xml.test.js
浏览文件 @
f7144704
...
...
@@ -14,6 +14,7 @@
*/
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
@ohos/hypium
'
import
xml
from
'
@ohos.xml
'
import
util
from
'
@ohos.util
'
export
default
function
XmlSerializerXmlPullParserTest
()
{
describe
(
'
XmlSerializerXmlPullParserTest
'
,
function
()
{
...
...
@@ -1046,46 +1047,17 @@ describe('XmlSerializerXmlPullParserTest', function () {
'
</h:tr>
'
+
'
</h:table>
'
+
'
</note>
'
;
var
arrayBuffer
=
new
ArrayBuffer
(
strXml
.
length
);
var
bufView
=
new
Uint8Array
(
arrayBuffer
);
var
strLen
=
strXml
.
length
;
for
(
var
i
=
0
;
i
<
strLen
;
++
i
)
{
bufView
[
i
]
=
strXml
.
charCodeAt
(
i
);
}
var
that
=
new
xml
.
XmlPullParser
(
arrayBuffer
,
'
UTF-8
'
);
var
arr
=
{};
var
i
=
0
;
function
func3
(
key
,
info
){
arr
[
i
]
=
'
key:
'
+
JSON
.
stringify
(
key
)
+
info
.
getDepth
()
+
info
.
getColumnNumber
()
+
info
.
getLineNumber
()
+
info
.
getAttributeCount
()
+
info
.
getName
()
+
info
.
getNamespace
()
+
info
.
getPrefix
()
+
info
.
getText
()
+
info
.
isEmptyElementTag
()
+
info
.
isWhitespace
();
i
++
;
let
textEncoder
=
new
util
.
TextEncoder
();
let
arrbuffer
=
textEncoder
.
encodeInto
(
strXml
);
let
that
=
new
xml
.
XmlPullParser
(
arrbuffer
.
buffer
,
'
UTF-8
'
);
var
str
=
''
;
function
func2
(
name
,
value
){
str
+=
name
+
'
:
'
+
value
;
return
true
;
}
var
options
=
{
supportDoctype
:
true
,
ignoreNameSpace
:
false
,
tokenValueCallbackFunction
:
func3
}
var
options
=
{
supportDoctype
:
true
,
ignoreNameSpace
:
true
,
attributeValueCallbackFunction
:
func2
}
that
.
parse
(
options
);
var
str
=
''
;
for
(
var
j
=
0
;
j
<
i
;
++
j
)
{
str
=
str
+
arr
[
j
];
}
var
str1
=
'
key:00110falsetruekey:702220 note [
\n
<!ENTITY foo "baa">]falsefalsekey:216022notefalsefalsekey:
'
+
'
1016420 falsetruekey:51470
\r\n
funcrion matchwo(a,6)
\r\n
{
\r\n
return 1;
\r\n
}
\r\n
falsetruekey:101870
'
+
'
falsetruekey:612870Hello, World!falsetruekey:1013270 falsetruekey:224170companyfalsetruekey:424670John
'
+
'
falsefalsekey:925170amp;amp;falsetruekey:425670 Hansfalsefalsekey:326670companyfalsetruekey:1017070
'
+
'
falsetruekey:227770titlefalsetruekey:428270Happyfalsefalsekey:329070titlefalsetruekey:1019470
'
+
'
falsetruekey:2210170titlefalsetruekey:4210670Happyfalsefalsekey:3211470titlefalsetruekey:10111870
'
+
'
falsetruekey:2212470lensfalsetruekey:4212870Workfalsefalsekey:3213570lensfalsetruekey:10113970
'
+
'
falsetruekey:2214570lensfalsetruekey:4214970Playfalsefalsekey:3215670lensfalsetruekey:10116070
'
+
'
falsetruekey:8117270go therefalsetruekey:10117670 falsetruekey:2217970afalsetruekey:
'
+
'
2318370btruetruekey:3318370bfalsetruekey:3218770afalsetruekey:10119170 falsetruekey:2223870table
'
+
'
http://www.w3.org/TR/html4/hfalsefalsekey:10224670
'
+
'
falsetruekey:2325270trhttp://www.w3.org/TR/html4/hfalsetruekey:10326470
'
+
'
falsetruekey:2427070tdhttp://www.w3.org/TR/html4/hfalsetruekey:4427670Applesfalsefalsekey:3428370td
'
+
'
http://www.w3.org/TR/html4/hfalsetruekey:10329570
'
+
'
falsetruekey:2430170tdhttp://www.w3.org/TR/html4/hfalsetruekey:4430870Bananasfalsefalsekey:3431570td
'
+
'
http://www.w3.org/TR/html4/hfalsetruekey:10332370 falsetruekey:3333070tr
'
+
'
http://www.w3.org/TR/html4/hfalsetruekey:10233470 falsetruekey:3234470table
'
+
'
http://www.w3.org/TR/html4/hfalsetruekey:3135170notefalsetruekey:10351130falsetrue
'
;
var
str1
=
'
importance:highlogged:truexmlns:h:http://www.w3.org/TR/html4/
'
;
expect
(
str
).
assertEqual
(
str1
);
})
...
...
@@ -1114,44 +1086,22 @@ describe('XmlSerializerXmlPullParserTest', function () {
'
</h:tr>
'
+
'
</h:table>
'
+
'
</note>
'
;
var
arrayBuffer
=
new
ArrayBuffer
(
strXml
.
length
);
var
bufView
=
new
Uint8Array
(
arrayBuffer
);
var
strLen
=
strXml
.
length
;
for
(
var
i
=
0
;
i
<
strLen
;
++
i
)
{
bufView
[
i
]
=
strXml
.
charCodeAt
(
i
);
}
var
that
=
new
xml
.
XmlPullParser
(
arrayBuffer
);
var
arr
=
{};
var
i
=
0
;
function
func3
(
key
,
info
){
arr
[
i
]
=
'
key:
'
+
JSON
.
stringify
(
key
)
+
info
.
getDepth
()
+
info
.
getColumnNumber
()
+
info
.
getLineNumber
()
+
info
.
getAttributeCount
()
+
info
.
getName
()
+
info
.
getNamespace
()
+
info
.
getPrefix
()
+
info
.
getText
()
+
info
.
isEmptyElementTag
()
+
info
.
isWhitespace
();
i
++
;
let
textEncoder
=
new
util
.
TextEncoder
();
let
arrbuffer
=
textEncoder
.
encodeInto
(
strXml
);
let
that
=
new
xml
.
XmlPullParser
(
arrbuffer
.
buffer
);
var
str1
=
''
;
function
func1
(
name
,
value
){
str1
+=
name
+
value
+
'
'
;
return
true
;
}
var
options
=
{
supportDoctype
:
true
,
ignoreNameSpace
:
true
,
t
okenValueCallbackFunction
:
func3
}
var
options
=
{
supportDoctype
:
true
,
ignoreNameSpace
:
true
,
t
agValueCallbackFunction
:
func1
}
that
.
parse
(
options
);
var
str
=
''
;
for
(
var
j
=
0
;
j
<
i
;
++
j
)
{
str
=
str
+
arr
[
j
];
}
var
str1
=
'
key:00110falsetruekey:702220 note [
\n
<!ENTITY foo "baa">]falsefalsekey:216022notefalsefalsekey:
'
+
'
1016420 falsetruekey:51470
\r\n
funcrion matchwo(a,6)
\r\n
{
\r\n
return 1;
\r\n
}
\r\n
falsetruekey:101870
'
+
'
falsetruekey:612870Hello, World!falsetruekey:1013270 falsetruekey:224170companyfalsetruekey:424670
'
+
'
John falsefalsekey:925170amp;amp;falsetruekey:425670 Hansfalsefalsekey:326670companyfalsetruekey:1017070
'
+
'
falsetruekey:227770titlefalsetruekey:428270Happyfalsefalsekey:329070titlefalsetruekey:1019470
'
+
'
falsetruekey:2210170titlefalsetruekey:4210670Happyfalsefalsekey:3211470titlefalsetruekey:10111870
'
+
'
falsetruekey:2212470lensfalsetruekey:4212870Workfalsefalsekey:3213570lensfalsetruekey:10113970
'
+
'
falsetruekey:2214570lensfalsetruekey:4214970Playfalsefalsekey:3215670lensfalsetruekey:10116070
'
+
'
falsetruekey:8117270go therefalsetruekey:10117670 falsetruekey:2217970afalsetruekey:
'
+
'
2318370btruetruekey:3318370bfalsetruekey:3218770afalsetruekey:10119170 falsetruekey:
'
+
'
2223871h:tablefalsefalsekey:10224670 falsetruekey:2325270h:trfalsetruekey:10326470
'
+
'
falsetruekey:2427070h:tdfalsetruekey:4427670Applesfalsefalsekey:3428370h:tdfalsetruekey:
'
+
'
10329570 falsetruekey:2430170h:tdfalsetruekey:4430870Bananasfalsefalsekey:3431570h:
'
+
'
tdfalsetruekey:10332370 falsetruekey:3333070h:trfalsetruekey:10233470 falsetruekey:3234470h:
'
+
'
tablefalsetruekey:3135170notefalsetruekey:10351130falsetrue
'
expect
(
str
).
assertEqual
(
str1
);
var
str3
=
'
note [<!ENTITY foo "baa">] note funcrion matchwo(a,6){return 1;} Hello, World!
'
+
'
company John amp;amp; Hans company title Happy title title Happy title
'
+
'
lens Work lens lens Play lens go there a b b a h:table
'
+
'
h:tr h:td Apples h:td h:td Bananas h:td h:tr
'
+
'
h:table note
'
;
expect
(
str1
).
assertEqual
(
str3
)
})
/**
...
...
@@ -1159,65 +1109,27 @@ describe('XmlSerializerXmlPullParserTest', function () {
* @tc.desc: Starts parsing the XML file.
*/
it
(
'
testParse003
'
,
0
,
function
()
{
var
strXml
=
'
<?xml version="1.0" encoding="utf-8"?>
'
+
'
<!DOCTYPE note [
\n
<!ENTITY foo "baa">]>
'
+
'
<note importance="high" logged="true">
'
+
'
<![CDATA[
\r\n
funcrion matchwo(a,6)
\r\n
{
\r\n
return 1;
\r\n
}
\r\n
]]>
'
+
'
<!--Hello, World!-->
'
+
'
<company>John & Hans</company>
'
+
'
<title>Happy</title>
'
+
'
<title>Happy</title>
'
+
'
<lens>Work</lens>
'
+
'
<lens>Play</lens>
'
+
'
<?go there?>
'
+
'
<a><b/></a>
'
+
'
<h:table xmlns:h="http://www.w3.org/TR/html4/">
'
+
'
<h:tr>
'
+
'
<h:td>Apples</h:td>
'
+
'
<h:td>Bananas</h:td>
'
+
'
</h:tr>
'
+
'
</h:table>
'
+
'
</note>
'
;
var
arrayBuffer
=
new
ArrayBuffer
(
strXml
.
length
);
var
bufView
=
new
Uint8Array
(
arrayBuffer
);
var
strLen
=
strXml
.
length
;
for
(
var
i
=
0
;
i
<
strLen
;
++
i
)
{
bufView
[
i
]
=
strXml
.
charCodeAt
(
i
);
}
var
that
=
new
xml
.
XmlPullParser
(
arrayBuffer
,
'
UTF-8
'
);
var
arr
=
{};
var
i
=
0
;
function
func3
(
key
,
info
){
arr
[
i
]
=
'
key:
'
+
JSON
.
stringify
(
key
)
+
info
.
getDepth
()
+
info
.
getColumnNumber
()
+
info
.
getLineNumber
()
+
info
.
getAttributeCount
()
+
info
.
getName
()
+
info
.
getNamespace
()
+
info
.
getPrefix
()
+
info
.
getText
()
+
info
.
isEmptyElementTag
()
+
info
.
isWhitespace
();
i
++
;
return
true
;
}
var
options
=
{
supportDoctype
:
false
,
ignoreNameSpace
:
true
,
tokenValueCallbackFunction
:
func3
}
let
strXml
=
'
<?xml version="1.0" encoding="utf-8"?>
'
+
'
<note importance="high" logged="true">
'
+
'
<title>Happy</title>
'
+
'
<todo>Work</todo>
'
+
'
<todo>Play</todo>
'
+
'
</note>
'
;
let
textEncoder
=
new
util
.
TextEncoder
();
let
arrbuffer
=
textEncoder
.
encodeInto
(
strXml
);
let
that
=
new
xml
.
XmlPullParser
(
arrbuffer
.
buffer
);
let
str
=
""
;
function
func
(
key
,
value
){
str
+=
'
key:
'
+
key
+
'
value:
'
+
value
.
getColumnNumber
()
+
'
'
;
return
true
;
}
let
options
=
{
supportDoctype
:
true
,
ignoreNameSpace
:
true
,
tokenValueCallbackFunction
:
func
}
that
.
parse
(
options
);
var
str
=
''
;
for
(
var
j
=
0
;
j
<
i
;
++
j
)
{
str
=
str
+
arr
[
j
];
}
var
str1
=
'
key:00110falsetruekey:216022notefalsefalsekey:1016420 falsetruekey:51470
\r\n
funcrion
'
+
'
matchwo(a,6)
\r\n
{
\r\n
return 1;
\r\n
}
\r\n
falsetruekey:101870 falsetruekey:612870Hello, World!falsetruekey
'
+
'
:1013270 falsetruekey:224170companyfalsetruekey:424670John falsefalsekey:925170amp;amp;falsetruekey
'
+
'
:425670 Hansfalsefalsekey:326670companyfalsetruekey:1017070 falsetruekey:227770titlefalsetruekey:428
'
+
'
270Happyfalsefalsekey:329070titlefalsetruekey:1019470 falsetruekey:2210170titlefalsetruekey:4210670
'
+
'
Happyfalsefalsekey:3211470titlefalsetruekey:10111870 falsetruekey:2212470lensfalsetruekey:4212870
'
+
'
Workfalsefalsekey:3213570lensfalsetruekey:10113970 falsetruekey:2214570lensfalsetruekey:4214970
'
+
'
Playfalsefalsekey:3215670lensfalsetruekey:10116070 falsetruekey:8117270go therefalsetruekey
'
+
'
:10117670 falsetruekey:2217970afalsetruekey:2318370btruetruekey:3318370bfalsetruekey
'
+
'
:3218770afalsetruekey:10119170 falsetruekey:2223871h:tablefalsefalsekey:10224670
'
+
'
falsetruekey:2325270h:trfalsetruekey:10326470 falsetruekey:
'
+
'
2427070h:tdfalsetruekey:4427670Applesfalsefalsekey:3428370h:tdfalsetruekey:10329570
'
+
'
falsetruekey:2430170h:tdfalsetruekey:4430870Bananasfalsefalsekey:3431570h:tdfalsetruekey:10332370
'
+
'
falsetruekey:3333070h:trfalsetruekey:10233470 falsetruekey:3234470h:tablefalsetruekey:
'
+
'
3135170notefalsetruekey:10351130falsetrue
'
expect
(
str
).
assertEqual
(
str1
);
let
result
=
'
key:0 value:1 key:2 value:77 key:10 value:81 key:2 value:88 key:4 value:93
'
+
'
key:3 value:101 key:10 value:105 key:2 value:111 key:4 value:115 key:3 value:122 key:10 value:126
'
+
'
key:2 value:132 key:4 value:136 key:3 value:143 key:3 value:150 key:1 value:299
'
;
expect
(
str
).
assertEqual
(
result
);
})
/**
...
...
@@ -1225,42 +1137,27 @@ describe('XmlSerializerXmlPullParserTest', function () {
* @tc.desc: Starts parsing the XML file.
*/
it
(
'
testParse004
'
,
0
,
function
()
{
var
strXml
=
'
<?xml version="1.0" encoding="utf-8"?>
'
+
'
<!DOCTYPE note [
\n
<!ENTITY foo "baa">]>
'
+
'
<note importance="high" logged="true">
'
+
'
<![CDATA[
\r\n
funcrion matchwo(a,6)
\r\n
{
\r\n
return 1;
\r\n
}
\r\n
]]>
'
+
'
<!--Hello, World!-->
'
+
'
<company>John & Hans</company>
'
+
'
<title>Happy</title>
'
+
'
<title>Happy</title>
'
+
'
<lens>Work</lens>
'
+
'
<lens>Play</lens>
'
+
'
<?go there?>
'
+
'
<a><b/></a>
'
+
'
<h:table xmlns:h="http://www.w3.org/TR/html4/">
'
+
'
<h:tr>
'
+
'
<h:td>Apples</h:td>
'
+
'
<h:td>Bananas</h:td>
'
+
'
</h:tr>
'
+
'
</h:table>
'
+
'
</note>
'
;
var
arrayBuffer
=
new
ArrayBuffer
(
strXml
.
length
);
var
bufView
=
new
Uint8Array
(
arrayBuffer
);
var
strLen
=
strXml
.
length
;
for
(
var
i
=
0
;
i
<
strLen
;
++
i
)
{
bufView
[
i
]
=
strXml
.
charCodeAt
(
i
);
}
var
that
=
new
xml
.
XmlPullParser
(
arrayBuffer
,
'
UTF-8
'
);
var
str
=
''
;
function
func2
(
name
,
value
){
str
+=
name
+
'
:
'
+
value
;
return
true
;
}
var
options
=
{
supportDoctype
:
true
,
ignoreNameSpace
:
true
,
attributeValueCallbackFunction
:
func2
}
let
strXml
=
'
<?xml version="1.0" encoding="utf-8"?>
'
+
'
<note importance="high" logged="true">
'
+
'
<title>Happy</title>
'
+
'
<todo>Work</todo>
'
+
'
<todo>Play</todo>
'
+
'
</note>
'
;
let
textEncoder
=
new
util
.
TextEncoder
();
let
arrbuffer
=
textEncoder
.
encodeInto
(
strXml
);
let
that
=
new
xml
.
XmlPullParser
(
arrbuffer
.
buffer
);
let
str
=
""
;
function
func
(
key
,
value
){
str
+=
'
key:
'
+
key
+
'
value:
'
+
value
.
getDepth
()
+
'
'
;
return
true
;
}
let
options
=
{
supportDoctype
:
true
,
ignoreNameSpace
:
true
,
tokenValueCallbackFunction
:
func
}
that
.
parse
(
options
);
var
str1
=
'
importance:highlogged:truexmlns:h:http://www.w3.org/TR/html4/
'
;
expect
(
str
).
assertEqual
(
str1
);
let
result
=
'
key:0 value:0 key:2 value:1 key:10 value:1 key:2 value:2 key:4 value:2 key:3 value:2
'
+
'
key:10 value:1 key:2 value:2 key:4 value:2 key:3 value:2 key:10 value:1 key:2 value:2
'
+
'
key:4 value:2 key:3 value:2 key:3 value:1 key:1 value:0
'
;
expect
(
str
).
assertEqual
(
result
);
})
/**
...
...
@@ -1268,42 +1165,225 @@ describe('XmlSerializerXmlPullParserTest', function () {
* @tc.desc: Starts parsing the XML file.
*/
it
(
'
testParse005
'
,
0
,
function
()
{
var
strXml
=
'
<?xml version="1.0" encoding="utf-8"?>
'
+
'
<!DOCTYPE note [
\n
<!ENTITY foo "baa">]>
'
+
'
<note importance="high" logged="true">
'
+
'
<![CDATA[
\r\n
funcrion matchwo(a,6)
\r\n
{
\r\n
return 1;
\r\n
}
\r\n
]]>
'
+
'
<!--Hello, World!-->
'
+
'
<company>John & Hans</company>
'
+
'
<title>Happy</title>
'
+
'
<title>Happy</title>
'
+
'
<lens>Work</lens>
'
+
'
<lens>Play</lens>
'
+
'
<?go there?>
'
+
'
<a><b/></a>
'
+
'
<h:table xmlns:h="http://www.w3.org/TR/html4/">
'
+
'
<h:tr>
'
+
'
<h:td>Apples</h:td>
'
+
'
<h:td>Bananas</h:td>
'
+
'
</h:tr>
'
+
'
</h:table>
'
+
'
</note>
'
;
var
arrayBuffer
=
new
ArrayBuffer
(
strXml
.
length
);
var
bufView
=
new
Uint8Array
(
arrayBuffer
);
var
strLen
=
strXml
.
length
;
for
(
var
i
=
0
;
i
<
strLen
;
++
i
)
{
bufView
[
i
]
=
strXml
.
charCodeAt
(
i
);
}
var
that
=
new
xml
.
XmlPullParser
(
arrayBuffer
,
'
UTF-8
'
);
var
str1
=
''
;
function
func1
(
name
,
value
){
str1
+=
name
+
'
:
'
+
value
;
return
true
;
}
var
options
=
{
supportDoctype
:
true
,
ignoreNameSpace
:
true
,
tagValueCallbackFunction
:
func1
}
let
strXml
=
'
<?xml version="1.0" encoding="utf-8"?>
'
+
'
<note importance="high" logged="true">
'
+
'
<title>Happy</title>
'
+
'
<todo>Work</todo>
'
+
'
<todo>Play</todo>
'
+
'
</note>
'
;
let
textEncoder
=
new
util
.
TextEncoder
();
let
arrbuffer
=
textEncoder
.
encodeInto
(
strXml
);
let
that
=
new
xml
.
XmlPullParser
(
arrbuffer
.
buffer
);
let
str
=
""
;
function
func
(
key
,
value
){
str
+=
'
key:
'
+
key
+
'
value:
'
+
value
.
getLineNumber
()
+
'
'
;
return
true
;
}
let
options
=
{
supportDoctype
:
true
,
ignoreNameSpace
:
true
,
tokenValueCallbackFunction
:
func
}
that
.
parse
(
options
);
var
str3
=
'
note:company:title:title:lens:lens:a:b:h:table:h:tr:h:td:h:td:
'
expect
(
str1
).
assertEqual
(
str3
)
let
result
=
'
key:0 value:1 key:2 value:1 key:10 value:1 key:2 value:1 key:4 value:1 key:3 value:1
'
+
'
key:10 value:1 key:2 value:1 key:4 value:1 key:3 value:1 key:10 value:1 key:2 value:1
'
+
'
key:4 value:1 key:3 value:1 key:3 value:1 key:1 value:1
'
;
expect
(
str
).
assertEqual
(
result
);
})
/**
* @tc.name: testParse006
* @tc.desc: Starts parsing the XML file.
*/
it
(
'
testParse006
'
,
0
,
function
()
{
let
strXml
=
'
<?xml version="1.0" encoding="utf-8"?>
'
+
'
<note importance="high" logged="true">
'
+
'
<title>Happy</title>
'
+
'
<todo>Work</todo>
'
+
'
<todo>Play</todo>
'
+
'
</note>
'
;
let
textEncoder
=
new
util
.
TextEncoder
();
let
arrbuffer
=
textEncoder
.
encodeInto
(
strXml
);
let
that
=
new
xml
.
XmlPullParser
(
arrbuffer
.
buffer
);
let
str
=
""
;
function
func
(
key
,
value
){
str
+=
'
key:
'
+
key
+
'
value:
'
+
value
.
getName
()
+
'
'
;
return
true
;
}
let
options
=
{
supportDoctype
:
true
,
ignoreNameSpace
:
true
,
tokenValueCallbackFunction
:
func
}
that
.
parse
(
options
);
let
result
=
'
key:0 value: key:2 value:note key:10 value: key:2 value:title key:4 value:
'
+
'
key:3 value:title key:10 value: key:2 value:todo key:4 value: key:3 value:todo key:10 value:
'
+
'
key:2 value:todo key:4 value: key:3 value:todo key:3 value:note key:1 value:
'
;
expect
(
str
).
assertEqual
(
result
);
})
/**
* @tc.name: testParse007
* @tc.desc: Starts parsing the XML file.
*/
it
(
'
testParse007
'
,
0
,
function
()
{
let
strXml
=
'
<?xml version="1.0" encoding="utf-8"?>
'
+
'
<note importance="high" logged="true">
'
+
'
<title>Happy</title>
'
+
'
<todo>Work</todo>
'
+
'
<todo>Play</todo>
'
+
'
</note>
'
;
let
textEncoder
=
new
util
.
TextEncoder
();
let
arrbuffer
=
textEncoder
.
encodeInto
(
strXml
);
let
that
=
new
xml
.
XmlPullParser
(
arrbuffer
.
buffer
);
let
str
=
""
;
function
func
(
key
,
value
){
str
+=
'
key:
'
+
key
+
'
value:
'
+
value
.
getNamespace
()
+
'
'
;
return
true
;
}
let
options
=
{
supportDoctype
:
true
,
ignoreNameSpace
:
true
,
tokenValueCallbackFunction
:
func
}
that
.
parse
(
options
);
let
result
=
'
key:0 value: key:2 value: key:10 value: key:2 value: key:4 value: key:3 value:
'
+
'
key:10 value: key:2 value: key:4 value: key:3 value: key:10 value: key:2 value: key:4 value:
'
+
'
key:3 value: key:3 value: key:1 value:
'
;
expect
(
str
).
assertEqual
(
result
);
})
/**
* @tc.name: testParse008
* @tc.desc: Starts parsing the XML file.
*/
it
(
'
testParse008
'
,
0
,
function
()
{
let
strXml
=
'
<?xml version="1.0" encoding="utf-8"?>
'
+
'
<note importance="high" logged="true">
'
+
'
<title>Happy</title>
'
+
'
<todo>Work</todo>
'
+
'
<todo>Play</todo>
'
+
'
</note>
'
;
let
textEncoder
=
new
util
.
TextEncoder
();
let
arrbuffer
=
textEncoder
.
encodeInto
(
strXml
);
let
that
=
new
xml
.
XmlPullParser
(
arrbuffer
.
buffer
);
let
str
=
""
;
function
func
(
key
,
value
){
str
+=
'
key:
'
+
key
+
'
value:
'
+
value
.
getPrefix
()
+
'
'
;
return
true
;
}
let
options
=
{
supportDoctype
:
true
,
ignoreNameSpace
:
true
,
tokenValueCallbackFunction
:
func
}
that
.
parse
(
options
);
let
result
=
'
key:0 value: key:2 value: key:10 value: key:2 value: key:4 value: key:3 value:
'
+
'
key:10 value: key:2 value: key:4 value: key:3 value: key:10 value: key:2 value: key:4 value:
'
+
'
key:3 value: key:3 value: key:1 value:
'
;
expect
(
str
).
assertEqual
(
result
);
})
/**
* @tc.name: testParse009
* @tc.desc: Starts parsing the XML file.
*/
it
(
'
testParse009
'
,
0
,
function
()
{
let
strXml
=
'
<?xml version="1.0" encoding="utf-8"?>
'
+
'
<note importance="high" logged="true">
'
+
'
<title>Happy</title>
'
+
'
<todo>Work</todo>
'
+
'
<todo>Play</todo>
'
+
'
</note>
'
;
let
textEncoder
=
new
util
.
TextEncoder
();
let
arrbuffer
=
textEncoder
.
encodeInto
(
strXml
);
let
that
=
new
xml
.
XmlPullParser
(
arrbuffer
.
buffer
);
let
str
=
""
;
function
func
(
key
,
value
){
str
+=
'
key:
'
+
key
+
'
value:
'
+
value
.
getText
()
+
'
'
;
return
true
;
}
let
options
=
{
supportDoctype
:
true
,
ignoreNameSpace
:
true
,
tokenValueCallbackFunction
:
func
}
that
.
parse
(
options
);
let
result
=
'
key:0 value: key:2 value: key:10 value: key:2 value: key:4 value:Happy
'
+
'
key:3 value: key:10 value: key:2 value: key:4 value:Work key:3 value: key:10 value:
'
+
'
key:2 value: key:4 value:Play key:3 value: key:3 value: key:1 value:
'
;
expect
(
str
).
assertEqual
(
result
);
})
/**
* @tc.name: testParse010
* @tc.desc: Starts parsing the XML file.
*/
it
(
'
testParse010
'
,
0
,
function
()
{
let
strXml
=
'
<?xml version="1.0" encoding="utf-8"?>
'
+
'
<note importance="high" logged="true">
'
+
'
<title>Happy</title>
'
+
'
<todo>Work</todo>
'
+
'
<todo>Play</todo>
'
+
'
</note>
'
;
let
textEncoder
=
new
util
.
TextEncoder
();
let
arrbuffer
=
textEncoder
.
encodeInto
(
strXml
);
let
that
=
new
xml
.
XmlPullParser
(
arrbuffer
.
buffer
);
let
str
=
""
;
function
func
(
key
,
value
){
str
+=
'
key:
'
+
key
+
'
value:
'
+
value
.
isEmptyElementTag
()
+
'
'
;
return
true
;
}
let
options
=
{
supportDoctype
:
true
,
ignoreNameSpace
:
true
,
tokenValueCallbackFunction
:
func
}
that
.
parse
(
options
);
let
result
=
'
key:0 value:false key:2 value:false key:10 value:false key:2 value:false
'
+
'
key:4 value:false key:3 value:false key:10 value:false key:2 value:false key:4 value:false
'
+
'
key:3 value:false key:10 value:false key:2 value:false key:4 value:false key:3 value:false
'
+
'
key:3 value:false key:1 value:false
'
;
expect
(
str
).
assertEqual
(
result
);
})
/**
* @tc.name: testParse011
* @tc.desc: Starts parsing the XML file.
*/
it
(
'
testParse011
'
,
0
,
function
()
{
let
strXml
=
'
<?xml version="1.0" encoding="utf-8"?>
'
+
'
<note importance="high" logged="true">
'
+
'
<title>Happy</title>
'
+
'
<todo>Work</todo>
'
+
'
<todo>Play</todo>
'
+
'
</note>
'
;
let
textEncoder
=
new
util
.
TextEncoder
();
let
arrbuffer
=
textEncoder
.
encodeInto
(
strXml
);
let
that
=
new
xml
.
XmlPullParser
(
arrbuffer
.
buffer
);
let
str
=
""
;
function
func
(
key
,
value
){
str
+=
'
key:
'
+
key
+
'
value:
'
+
value
.
isWhitespace
()
+
'
'
;
return
true
;
}
let
options
=
{
supportDoctype
:
true
,
ignoreNameSpace
:
true
,
tokenValueCallbackFunction
:
func
}
that
.
parse
(
options
);
let
result
=
'
key:0 value:true key:2 value:false key:10 value:true key:2 value:true
'
+
'
key:4 value:false key:3 value:true key:10 value:true key:2 value:true key:4 value:false
'
+
'
key:3 value:true key:10 value:true key:2 value:true key:4 value:false key:3 value:true
'
+
'
key:3 value:true key:1 value:true
'
;
expect
(
str
).
assertEqual
(
result
);
})
/**
* @tc.name: testParse012
* @tc.desc: Starts parsing the XML file.
*/
it
(
'
testParse012
'
,
0
,
function
()
{
let
strXml
=
'
<?xml version="1.0" encoding="utf-8"?>
'
+
'
<note importance="high" logged="true">
'
+
'
<title>Happy</title>
'
+
'
<todo>Work</todo>
'
+
'
<todo>Play</todo>
'
+
'
</note>
'
;
let
textEncoder
=
new
util
.
TextEncoder
();
let
arrbuffer
=
textEncoder
.
encodeInto
(
strXml
);
let
that
=
new
xml
.
XmlPullParser
(
arrbuffer
.
buffer
);
let
str
=
""
;
function
func
(
key
,
value
){
str
+=
'
key:
'
+
key
+
'
value:
'
+
value
.
getAttributeCount
()
+
'
'
;
return
true
;
}
let
options
=
{
supportDoctype
:
true
,
ignoreNameSpace
:
true
,
tokenValueCallbackFunction
:
func
}
that
.
parse
(
options
);
let
result
=
'
key:0 value:0 key:2 value:2 key:10 value:0 key:2 value:0 key:4 value:0
'
+
'
key:3 value:0 key:10 value:0 key:2 value:0 key:4 value:0 key:3 value:0 key:10 value:0
'
+
'
key:2 value:0 key:4 value:0 key:3 value:0 key:3 value:0 key:1 value:0
'
;
expect
(
str
).
assertEqual
(
result
);
})
/**
...
...
@@ -1406,10 +1486,10 @@ describe('XmlSerializerXmlPullParserTest', function () {
})
/**
* @tc.name: testBusinessError001
* @tc.name: test
Xml
BusinessError001
* @tc.desc: To XML text to JavaScript object.
*/
it
(
'
testBusinessError001
'
,
0
,
function
()
{
it
(
'
test
Xml
BusinessError001
'
,
0
,
function
()
{
try
{
new
xml
.
XmlSerializer
(
123
,
"
utf-8
"
);
}
catch
(
e
)
{
...
...
@@ -1418,10 +1498,10 @@ describe('XmlSerializerXmlPullParserTest', function () {
})
/**
* @tc.name: testBusinessError002
* @tc.name: test
Xml
BusinessError002
* @tc.desc: To XML text to JavaScript object.
*/
it
(
'
testBusinessError002
'
,
0
,
function
()
{
it
(
'
test
Xml
BusinessError002
'
,
0
,
function
()
{
try
{
var
arrayBuffer
=
new
ArrayBuffer
(
2048
);
new
xml
.
XmlSerializer
(
arrayBuffer
,
123
);
...
...
@@ -1431,10 +1511,10 @@ describe('XmlSerializerXmlPullParserTest', function () {
})
/**
* @tc.name: testBusinessError003
* @tc.name: test
Xml
BusinessError003
* @tc.desc: To XML text to JavaScript object.
*/
it
(
'
testBusinessError003
'
,
0
,
function
()
{
it
(
'
test
Xml
BusinessError003
'
,
0
,
function
()
{
try
{
var
arrayBuffer
=
new
ArrayBuffer
(
2048
);
var
thatSer
=
new
xml
.
XmlSerializer
(
arrayBuffer
,
"
utf-8
"
);
...
...
@@ -1445,10 +1525,10 @@ describe('XmlSerializerXmlPullParserTest', function () {
})
/**
* @tc.name: testBusinessError004
* @tc.name: test
Xml
BusinessError004
* @tc.desc: To XML text to JavaScript object.
*/
it
(
'
testBusinessError004
'
,
0
,
function
()
{
it
(
'
test
Xml
BusinessError004
'
,
0
,
function
()
{
try
{
var
arrayBuffer
=
new
ArrayBuffer
(
2048
);
var
thatSer
=
new
xml
.
XmlSerializer
(
arrayBuffer
,
"
utf-8
"
);
...
...
@@ -1460,10 +1540,10 @@ describe('XmlSerializerXmlPullParserTest', function () {
})
/**
* @tc.name: testBusinessError005
* @tc.name: test
Xml
BusinessError005
* @tc.desc: To XML text to JavaScript object.
*/
it
(
'
testBusinessError005
'
,
0
,
function
()
{
it
(
'
test
Xml
BusinessError005
'
,
0
,
function
()
{
try
{
var
arrayBuffer
=
new
ArrayBuffer
(
2048
);
var
thatSer
=
new
xml
.
XmlSerializer
(
arrayBuffer
,
"
utf-8
"
);
...
...
@@ -1475,10 +1555,10 @@ describe('XmlSerializerXmlPullParserTest', function () {
})
/**
* @tc.name: testBusinessError006
* @tc.name: test
Xml
BusinessError006
* @tc.desc: To XML text to JavaScript object.
*/
it
(
'
testBusinessError006
'
,
0
,
function
()
{
it
(
'
test
Xml
BusinessError006
'
,
0
,
function
()
{
try
{
var
arrayBuffer
=
new
ArrayBuffer
(
2048
);
var
thatSer
=
new
xml
.
XmlSerializer
(
arrayBuffer
,
"
utf-8
"
);
...
...
@@ -1491,10 +1571,10 @@ describe('XmlSerializerXmlPullParserTest', function () {
})
/**
* @tc.name: testBusinessError007
* @tc.name: test
Xml
BusinessError007
* @tc.desc: To XML text to JavaScript object.
*/
it
(
'
testBusinessError007
'
,
0
,
function
()
{
it
(
'
test
Xml
BusinessError007
'
,
0
,
function
()
{
try
{
var
arrayBuffer
=
new
ArrayBuffer
(
2048
);
var
thatSer
=
new
xml
.
XmlSerializer
(
arrayBuffer
,
"
utf-8
"
);
...
...
@@ -1506,10 +1586,10 @@ describe('XmlSerializerXmlPullParserTest', function () {
})
/**
* @tc.name: testBusinessError008
* @tc.name: test
Xml
BusinessError008
* @tc.desc: To XML text to JavaScript object.
*/
it
(
'
testBusinessError008
'
,
0
,
function
()
{
it
(
'
test
Xml
BusinessError008
'
,
0
,
function
()
{
try
{
var
arrayBuffer
=
new
ArrayBuffer
(
2048
);
var
thatSer
=
new
xml
.
XmlSerializer
(
arrayBuffer
,
"
utf-8
"
);
...
...
@@ -1521,10 +1601,10 @@ describe('XmlSerializerXmlPullParserTest', function () {
})
/**
* @tc.name: testBusinessError009
* @tc.name: test
Xml
BusinessError009
* @tc.desc: To XML text to JavaScript object.
*/
it
(
'
testBusinessError009
'
,
0
,
function
()
{
it
(
'
test
Xml
BusinessError009
'
,
0
,
function
()
{
try
{
var
arrayBuffer
=
new
ArrayBuffer
(
2048
);
var
thatSer
=
new
xml
.
XmlSerializer
(
arrayBuffer
,
"
utf-8
"
);
...
...
@@ -1536,10 +1616,10 @@ describe('XmlSerializerXmlPullParserTest', function () {
})
/**
* @tc.name: testBusinessError010
* @tc.name: test
Xml
BusinessError010
* @tc.desc: To XML text to JavaScript object.
*/
it
(
'
testBusinessError010
'
,
0
,
function
()
{
it
(
'
test
Xml
BusinessError010
'
,
0
,
function
()
{
try
{
var
arrayBuffer
=
new
ArrayBuffer
(
2048
);
var
thatSer
=
new
xml
.
XmlSerializer
(
arrayBuffer
,
"
utf-8
"
);
...
...
@@ -1551,10 +1631,10 @@ describe('XmlSerializerXmlPullParserTest', function () {
})
/**
* @tc.name: testBusinessError011
* @tc.name: test
Xml
BusinessError011
* @tc.desc: To XML text to JavaScript object.
*/
it
(
'
test
BusinessError0
011
'
,
0
,
function
()
{
it
(
'
test
XmlBusinessError
011
'
,
0
,
function
()
{
try
{
var
arrayBuffer
=
new
ArrayBuffer
(
2048
);
var
thatSer
=
new
xml
.
XmlSerializer
(
arrayBuffer
,
"
utf-8
"
);
...
...
@@ -1565,10 +1645,10 @@ describe('XmlSerializerXmlPullParserTest', function () {
})
/**
* @tc.name: testBusinessError012
* @tc.name: test
Xml
BusinessError012
* @tc.desc: To XML text to JavaScript object.
*/
it
(
'
test
BusinessError0
012
'
,
0
,
function
()
{
it
(
'
test
XmlBusinessError
012
'
,
0
,
function
()
{
try
{
var
arrayBuffer
=
new
ArrayBuffer
(
2048
);
var
thatSer
=
new
xml
.
XmlSerializer
(
arrayBuffer
,
"
utf-8
"
);
...
...
@@ -1579,10 +1659,10 @@ describe('XmlSerializerXmlPullParserTest', function () {
})
/**
* @tc.name: testBusinessError013
* @tc.name: test
Xml
BusinessError013
* @tc.desc: To XML text to JavaScript object.
*/
it
(
'
test
BusinessError0
013
'
,
0
,
function
()
{
it
(
'
test
XmlBusinessError
013
'
,
0
,
function
()
{
try
{
new
xml
.
XmlPullParser
(
111
,
'
UTF-8
'
);
}
catch
(
e
)
{
...
...
@@ -1591,10 +1671,10 @@ describe('XmlSerializerXmlPullParserTest', function () {
})
/**
* @tc.name: testBusinessError014
* @tc.name: test
Xml
BusinessError014
* @tc.desc: To XML text to JavaScript object.
*/
it
(
'
test
BusinessError0
014
'
,
0
,
function
()
{
it
(
'
test
XmlBusinessError
014
'
,
0
,
function
()
{
try
{
var
arrayBuffer
=
new
ArrayBuffer
(
2048
);
new
xml
.
XmlPullParser
(
arrayBuffer
,
111
);
...
...
@@ -1604,10 +1684,10 @@ describe('XmlSerializerXmlPullParserTest', function () {
})
/**
* @tc.name: testBusinessError015
* @tc.name: test
Xml
BusinessError015
* @tc.desc: To XML text to JavaScript object.
*/
it
(
'
test
BusinessError0
015
'
,
0
,
function
()
{
it
(
'
test
XmlBusinessError
015
'
,
0
,
function
()
{
try
{
var
strXml
=
'
<?xml version="1.0" encoding="utf-8"?>
'
+
...
...
@@ -1629,19 +1709,15 @@ describe('XmlSerializerXmlPullParserTest', function () {
'
</h:tr>
'
+
'
</h:table>
'
+
'
</note>
'
;
var
arrayBuffer
=
new
ArrayBuffer
(
strXml
.
length
*
2
);
var
bufView
=
new
Uint8Array
(
arrayBuffer
);
var
strLen
=
strXml
.
length
;
for
(
var
i
=
0
;
i
<
strLen
;
++
i
)
{
bufView
[
i
]
=
strXml
.
charCodeAt
(
i
);
}
var
that
=
new
xml
.
XmlPullParser
(
arrayBuffer
,
'
UTF-8
'
);
let
textEncoder
=
new
util
.
TextEncoder
();
let
arrbuffer
=
textEncoder
.
encodeInto
(
strXml
);
let
that
=
new
xml
.
XmlPullParser
(
arrbuffer
.
buffer
,
'
UTF-8
'
);
var
str1
=
''
;
function
func1
(
name
,
value
){
str1
+=
name
+
'
:
'
+
value
;
return
true
;
}
var
options
=
{
supportDoctype
:
true
,
ignoreNameSpace
:
true
,
tagValueCallbackFunction
:
func1
}
var
options
=
111
that
.
parse
(
options
);
}
catch
(
e
)
{
expect
(
e
.
toString
()).
assertEqual
(
"
BusinessError: Parameter error.The type of 111 must be object
"
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录