提交 b01bff56 编写于 作者: J jiangkai43
上级 c6713999
...@@ -977,20 +977,17 @@ describe('XmlTest', function () { ...@@ -977,20 +977,17 @@ describe('XmlTest', function () {
* @tc.desc: To convert XML text to JavaScript object. * @tc.desc: To convert XML text to JavaScript object.
*/ */
it('testConvert028', 0, function () { it('testConvert028', 0, function () {
let xml = '<![CDATA[ \t <foo></bar> \t ]]>'; let xml = '<?xml version="1.0" encoding="utf-8"?><![CDATA[ \t <foo>\r\n</bar> \t ]]>';
let conv = new convertxml.ConvertXML(); let conv = new convertxml.ConvertXML();
let options = {trim : false, declarationKey:"_declaration", let options = {trim : false, declarationKey:"_declaration",
instructionKey : "_instruction", attributesKey : "_attributes", instructionKey : "_instruction", attributesKey : "_attributes",
textKey : "_text", cdataKey:"_cdata", doctypeKey : "_doctype", textKey : "_text", cdataKey:"_cdata", doctypeKey : "_doctype",
commentKey : "_comment", parentKey : "_parent", typeKey : "_type", commentKey : "_comment", parentKey : "_parent", typeKey : "_type",
nameKey : "_name", elementsKey : "_elements"} nameKey : "_name", elementsKey : "_elements"}
let result = JSON.stringify(conv.convert(xml, options)); let result = conv.convertToJSObject(xml, options);
let str1 = '{"_elements":[{"_type":"cdata","_cdata":"'+ let cdata = result._elements[0]._cdata;
' \\t'+ let str1 = ' \\t <foo>\\r\\n</bar> \\t ';
' <foo></bar> '+ expect(cdata).assertEqual(str1);
'\\t '+
'"}]}'
expect(result).assertEqual(str1);
}) })
/** /**
...@@ -998,26 +995,17 @@ describe('XmlTest', function () { ...@@ -998,26 +995,17 @@ describe('XmlTest', function () {
* @tc.desc: To convert XML text to JavaScript object. * @tc.desc: To convert XML text to JavaScript object.
*/ */
it('testConvert029', 0, function () { it('testConvert029', 0, function () {
let xml = '<![CDATA[ \t data]]><![CDATA[< > " and & \t ]]>'; let xml = '<?xml version="1.0" encoding="utf-8"?><![CDATA[ \t data\n]]><![CDATA[< > " and & \t ]]>';
let conv = new convertxml.ConvertXML(); let conv = new convertxml.ConvertXML();
let options = {trim : false, declarationKey:"_declaration", let options = {trim : false, declarationKey:"_declaration",
instructionKey : "_instruction", attributesKey : "_attributes", instructionKey : "_instruction", attributesKey : "_attributes",
textKey : "_text", cdataKey:"_cdata", doctypeKey : "_doctype", textKey : "_text", cdataKey:"_cdata", doctypeKey : "_doctype",
commentKey : "_comment", parentKey : "_parent", typeKey : "_type", commentKey : "_comment", parentKey : "_parent", typeKey : "_type",
nameKey : "_name", elementsKey : "_elements"} nameKey : "_name", elementsKey : "_elements"}
let result = JSON.stringify(conv.convert(xml, options)); let result = conv.convertToJSObject(xml, options);
console.log("LHC..." + result); let cdata = result._elements[0]._cdata;
let str1 = '{"_elements":[{"_type":"cdata","_cdata":"'+ let str = ' \\t data\\n< > \" and & \\t ';
' \\t'+ expect(cdata).assertEqual(str);
' data"},{"_type":"cdata","_cdata":"< '+
'> '+
'\\"'+
' and'+
' & '+
'\\t '+
'"}]}';
console.log("LHC..." + str1);
expect(result).assertEqual(str1);
}) })
/** /**
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册