!62 Modify uri/xml/convertxml

Merge pull request !62 from 史凯/master
This commit is contained in:
openharmony_ci
2022-02-09 07:30:54 +00:00
committed by Gitee
6 changed files with 42 additions and 42 deletions
+1 -1
View File
@@ -377,7 +377,7 @@ namespace OHOS::Xml {
void ConvertXml::DealIgnore(const napi_value napiObj)
{
std::vector<std::string> vctIgnore = {"compact", "trim", "ignoreDeclaration", "ignoreInstruction",
"ignoreAttributes", "ignoreComment", "ignoreCdata",
"ignoreAttributes", "ignoreComment", "ignoreCDATA",
"ignoreDoctype", "ignoreText"};
size_t vctLength = vctIgnore.size();
for (size_t i = 0; i < vctLength; ++i) {
+29 -29
View File
@@ -603,11 +603,11 @@ HWTEST_F(NativeEngineTest, SetNamespaceTest005, testing::ext::TestSize.Level0)
ASSERT_STREQ(reinterpret_cast<char*>(pBuffer), strEnd.c_str());
}
/* @tc.name: SetCommnetTest001
* @tc.desc: Test write the commnet successfully.
/* @tc.name: SetCommentTest001
* @tc.desc: Test write the comment successfully.
* @tc.type: FUNC
*/
HWTEST_F(NativeEngineTest, SetCommnetTest001, testing::ext::TestSize.Level0)
HWTEST_F(NativeEngineTest, SetCommentTest001, testing::ext::TestSize.Level0)
{
napi_env env = (napi_env)engine_;
napi_value arrayBuffer = nullptr;
@@ -616,16 +616,16 @@ HWTEST_F(NativeEngineTest, SetCommnetTest001, testing::ext::TestSize.Level0)
napi_create_arraybuffer(env, size, &pBuffer, &arrayBuffer);
OHOS::xml::XmlSerializer xmlSerializer(reinterpret_cast<char*>(pBuffer), size, "utf-8");
xmlSerializer.StartElement("note");
xmlSerializer.SetCommnet("Hi!");
xmlSerializer.SetComment("Hi!");
xmlSerializer.EndElement();
ASSERT_STREQ(reinterpret_cast<char*>(pBuffer), "<note>\r\n <!--Hi!-->\r\n</note>");
}
/* @tc.name: SetCommnetTest002
* @tc.desc: Test write the commnet successfully.
/* @tc.name: SetCommentTest002
* @tc.desc: Test write the comment successfully.
* @tc.type: FUNC
*/
HWTEST_F(NativeEngineTest, SetCommnetTest002, testing::ext::TestSize.Level0)
HWTEST_F(NativeEngineTest, SetCommentTest002, testing::ext::TestSize.Level0)
{
napi_env env = (napi_env)engine_;
napi_value arrayBuffer = nullptr;
@@ -634,16 +634,16 @@ HWTEST_F(NativeEngineTest, SetCommnetTest002, testing::ext::TestSize.Level0)
napi_create_arraybuffer(env, size, &pBuffer, &arrayBuffer);
OHOS::xml::XmlSerializer xmlSerializer(reinterpret_cast<char*>(pBuffer), size, "utf-8");
xmlSerializer.StartElement("note");
xmlSerializer.SetCommnet("Hello, World!");
xmlSerializer.SetComment("Hello, World!");
xmlSerializer.EndElement();
ASSERT_STREQ(reinterpret_cast<char*>(pBuffer), "<note>\r\n <!--Hello, World!-->\r\n</note>");
}
/* @tc.name: SetCommnetTest003
* @tc.desc: Test write the commnet successfully.
/* @tc.name: SetCommentTest003
* @tc.desc: Test write the comment successfully.
* @tc.type: FUNC
*/
HWTEST_F(NativeEngineTest, SetCommnetTest003, testing::ext::TestSize.Level0)
HWTEST_F(NativeEngineTest, SetCommentTest003, testing::ext::TestSize.Level0)
{
napi_env env = (napi_env)engine_;
napi_value arrayBuffer = nullptr;
@@ -651,15 +651,15 @@ HWTEST_F(NativeEngineTest, SetCommnetTest003, testing::ext::TestSize.Level0)
size_t size = 1024;
napi_create_arraybuffer(env, size, &pBuffer, &arrayBuffer);
OHOS::xml::XmlSerializer xmlSerializer(reinterpret_cast<char*>(pBuffer), size, "utf-8");
xmlSerializer.SetCommnet("Hello, World!");
xmlSerializer.SetComment("Hello, World!");
ASSERT_STREQ(reinterpret_cast<char*>(pBuffer), "<!--Hello, World!-->");
}
/* @tc.name: SetCommnetTest004
* @tc.desc: Test write the commnet successfully.
/* @tc.name: SetCommentTest004
* @tc.desc: Test write the comment successfully.
* @tc.type: FUNC
*/
HWTEST_F(NativeEngineTest, SetCommnetTest004, testing::ext::TestSize.Level0)
HWTEST_F(NativeEngineTest, SetCommentTest004, testing::ext::TestSize.Level0)
{
napi_env env = (napi_env)engine_;
napi_value arrayBuffer = nullptr;
@@ -667,15 +667,15 @@ HWTEST_F(NativeEngineTest, SetCommnetTest004, testing::ext::TestSize.Level0)
size_t size = 1024;
napi_create_arraybuffer(env, size, &pBuffer, &arrayBuffer);
OHOS::xml::XmlSerializer xmlSerializer(reinterpret_cast<char*>(pBuffer), size, "utf-8");
xmlSerializer.SetCommnet("Hello, World!");
xmlSerializer.SetComment("Hello, World!");
ASSERT_STREQ(reinterpret_cast<char*>(pBuffer), "<!--Hello, World!-->");
}
/* @tc.name: SetCommnetTest005
* @tc.desc: Test write the commnet successfully.
/* @tc.name: SetCommentTest005
* @tc.desc: Test write the comment successfully.
* @tc.type: FUNC
*/
HWTEST_F(NativeEngineTest, SetCommnetTest005, testing::ext::TestSize.Level0)
HWTEST_F(NativeEngineTest, SetCommentTest005, testing::ext::TestSize.Level0)
{
napi_env env = (napi_env)engine_;
napi_value arrayBuffer = nullptr;
@@ -683,7 +683,7 @@ HWTEST_F(NativeEngineTest, SetCommnetTest005, testing::ext::TestSize.Level0)
size_t size = 1024;
napi_create_arraybuffer(env, size, &pBuffer, &arrayBuffer);
OHOS::xml::XmlSerializer xmlSerializer(reinterpret_cast<char*>(pBuffer), size, "utf-8");
xmlSerializer.SetCommnet("Hello, World!");
xmlSerializer.SetComment("Hello, World!");
xmlSerializer.StartElement("note");
xmlSerializer.EndElement();
ASSERT_STREQ(reinterpret_cast<char*>(pBuffer), "<!--Hello, World!-->\r\n<note/>");
@@ -693,7 +693,7 @@ HWTEST_F(NativeEngineTest, SetCommnetTest005, testing::ext::TestSize.Level0)
* @tc.desc: Test .
* @tc.type: FUNC
*/
HWTEST_F(NativeEngineTest, SetCDataTest001, testing::ext::TestSize.Level0)
HWTEST_F(NativeEngineTest, SetCDATATest001, testing::ext::TestSize.Level0)
{
napi_env env = (napi_env)engine_;
napi_value arrayBuffer = nullptr;
@@ -705,11 +705,11 @@ HWTEST_F(NativeEngineTest, SetCDataTest001, testing::ext::TestSize.Level0)
ASSERT_STREQ(reinterpret_cast<char*>(pBuffer), "<![CDATA[root SYSTEM]]>");
}
/* @tc.name: SetCDataTest002
/* @tc.name: SetCDATATest002
* @tc.desc: Test whether Writes the CDATA successfully.
* @tc.type: FUNC
*/
HWTEST_F(NativeEngineTest, SetCDataTest002, testing::ext::TestSize.Level0)
HWTEST_F(NativeEngineTest, SetCDATATest002, testing::ext::TestSize.Level0)
{
napi_env env = (napi_env)engine_;
napi_value arrayBuffer = nullptr;
@@ -721,11 +721,11 @@ HWTEST_F(NativeEngineTest, SetCDataTest002, testing::ext::TestSize.Level0)
ASSERT_STREQ(reinterpret_cast<char*>(pBuffer), "<![CDATA[root SYSTEM \"http://www.test.org/test.dtd\"]]>");
}
/* @tc.name: SetCDataTest003
/* @tc.name: SetCDATATest003
* @tc.desc: Test whether Writes the CDATA successfully.
* @tc.type: FUNC
*/
HWTEST_F(NativeEngineTest, SetCDataTest003, testing::ext::TestSize.Level0)
HWTEST_F(NativeEngineTest, SetCDATATest003, testing::ext::TestSize.Level0)
{
napi_env env = (napi_env)engine_;
napi_value arrayBuffer = nullptr;
@@ -740,11 +740,11 @@ HWTEST_F(NativeEngineTest, SetCDataTest003, testing::ext::TestSize.Level0)
"<note/>\r\n<![CDATA[root SYSTEM \"http://www.test.org/test.dtd\"]]>");
}
/* @tc.name: SetCDataTest004
/* @tc.name: SetCDATATest004
* @tc.desc: Test whether Writes the CDATA successfully.
* @tc.type: FUNC
*/
HWTEST_F(NativeEngineTest, SetCDataTest004, testing::ext::TestSize.Level0)
HWTEST_F(NativeEngineTest, SetCDATATest004, testing::ext::TestSize.Level0)
{
napi_env env = (napi_env)engine_;
napi_value arrayBuffer = nullptr;
@@ -759,11 +759,11 @@ HWTEST_F(NativeEngineTest, SetCDataTest004, testing::ext::TestSize.Level0)
"<![CDATA[root SYSTEM \"http://www.test.org/test.dtd\"]]>\r\n<note/>");
}
/* @tc.name: SetCDataTest005
/* @tc.name: SetCDATATest005
* @tc.desc: Test whether Writes the CDATA successfully.
* @tc.type: FUNC
*/
HWTEST_F(NativeEngineTest, SetCDataTest005, testing::ext::TestSize.Level0)
HWTEST_F(NativeEngineTest, SetCDATATest005, testing::ext::TestSize.Level0)
{
napi_env env = (napi_env)engine_;
napi_value arrayBuffer = nullptr;
+1 -1
View File
@@ -239,7 +239,7 @@ namespace OHOS::xml {
}
}
}
void XmlSerializer::SetCommnet(std::string comment)
void XmlSerializer::SetComment(std::string comment)
{
out_ = "";
if (type == "isStart" || type == "isAttri") {
+1 -1
View File
@@ -36,7 +36,7 @@ namespace OHOS::xml {
void StartElement(std::string name);
void EndElement();
void SetNamespace(std::string prefix, std::string nsTemp);
void SetCommnet(std::string comment);
void SetComment(std::string comment);
void SetCData(std::string data);
void SetText(std::string text);
void SetDocType(std::string text);
+4 -4
View File
@@ -245,7 +245,7 @@ namespace OHOS::xml {
return result;
}
static napi_value SetCommnet(napi_env env, napi_callback_info info)
static napi_value SetComment(napi_env env, napi_callback_info info)
{
napi_value thisVar = nullptr;
size_t argc = 0;
@@ -261,7 +261,7 @@ namespace OHOS::xml {
NAPI_CALL(env, napi_unwrap(env, thisVar, reinterpret_cast<void**>(&object)));
std::string comment;
object->DealNapiStrValue(env, args[0], comment);
object->SetCommnet(comment);
object->SetComment(comment);
napi_value result = nullptr;
NAPI_CALL(env, napi_get_undefined(env, &result));
return result;
@@ -356,8 +356,8 @@ namespace OHOS::xml {
DECLARE_NAPI_FUNCTION("startElement", StartElement),
DECLARE_NAPI_FUNCTION("endElement", EndElement),
DECLARE_NAPI_FUNCTION("setNamespace", SetNamespace),
DECLARE_NAPI_FUNCTION("setCommnet", SetCommnet),
DECLARE_NAPI_FUNCTION("setCData", SetCData),
DECLARE_NAPI_FUNCTION("setComment", SetComment),
DECLARE_NAPI_FUNCTION("setCDATA", SetCData),
DECLARE_NAPI_FUNCTION("setText", SetText),
DECLARE_NAPI_FUNCTION("setDocType", SetDocType),
DECLARE_NAPI_FUNCTION("XmlSerializerError", XmlSerializerError)
+6 -6
View File
@@ -26,8 +26,8 @@ interface NativeXMLSerializer{
startElement(name : string) : void;
endElement() : void;
setNamespace(prefix : string, namespace : string) : void;
setCommnet(text : string) : void;
setCData(text : string) : void;
setComment(text : string) : void;
setCDATA(text : string) : void;
setText(text : string) : void;
setDocType(text : string) : void;
XmlSerializerError() : string;
@@ -115,21 +115,21 @@ class XmlSerializer {
throw new Error(errStr);
}
}
setCommnet(text : string) {
setComment(text : string) {
if (typeof text !== 'string' || text.length === 0) {
throw new Error("text type err");
}
this.xmlSerializerClass.setCommnet(text);
this.xmlSerializerClass.setComment(text);
let errStr = this.xmlSerializerClass.XmlSerializerError();
if (errStr.length !== 0) {
throw new Error(errStr);
}
}
setCData(text : string) {
setCDATA(text : string) {
if (typeof text !== 'string' || text.length === 0) {
throw new Error("text type err");
}
this.xmlSerializerClass.setCData(text);
this.xmlSerializerClass.setCDATA(text);
let errStr = this.xmlSerializerClass.XmlSerializerError();
if (errStr.length !== 0) {
throw new Error(errStr);