From 195abce47836c6a153469fc3c2faac6138d928aa Mon Sep 17 00:00:00 2001 From: chenxuihui Date: Wed, 22 Jun 2022 09:34:38 +0800 Subject: [PATCH] xts code check bugfix Signed-off-by: chenxuihui --- .../hiappeventcpptest/HiAppEventCPPTest.cpp | 60 +++++++++---------- 1 file changed, 28 insertions(+), 32 deletions(-) diff --git a/hiviewdfx/hiappeventtest/hiappeventcpptest/HiAppEventCPPTest.cpp b/hiviewdfx/hiappeventtest/hiappeventcpptest/HiAppEventCPPTest.cpp index dec588819..310901c38 100755 --- a/hiviewdfx/hiappeventtest/hiappeventcpptest/HiAppEventCPPTest.cpp +++ b/hiviewdfx/hiappeventtest/hiappeventcpptest/HiAppEventCPPTest.cpp @@ -32,8 +32,7 @@ using namespace testing; using namespace testing::ext; using namespace OHOS::HiviewDFX; -namespace -{ +namespace { const char* TEST_DOMAIN_NAME = "test_domain"; const char* TEST_EVENT_NAME = "test_event"; string g_reDiRectTimeout = "5"; @@ -41,14 +40,11 @@ namespace string delelogPath = "/data/test/hiappevent/*"; } -class HiAppEventCPPTest : public testing::Test -{ +class HiAppEventCPPTest : public testing::Test { public: void TearDown(); - private: }; -void HiAppEventCPPTest::TearDown() -{ +void HiAppEventCPPTest::TearDown() { std::cout << "TearDown" << std::endl; std::vector cmdret; string cmd = "rm -f " + delelogPath; @@ -79,7 +75,7 @@ HWTEST_F(HiAppEventCPPTest, DFX_DFT_HiviewKit_HiAppEvent_Native_0100, Function|M path = logPath + getlogFile; string fileinfo = ""; fileinfo = ReadFile(path); - std::vector para = {"test_event","\"type_\":1","\"bool_key\":false"}; + std::vector para = {"test_event", "\"type_\":1", "\"bool_key\":false"}; if (fileinfo != "") { result = CheckInfo(para, fileinfo); } else { @@ -114,7 +110,7 @@ HWTEST_F(HiAppEventCPPTest, DFX_DFT_HiviewKit_HiAppEvent_Native_0200, Function|M path = logPath + getlogFile; string fileinfo = ""; fileinfo = ReadFile(path); - std::vector para = {"test_event","\"type_\":1","\"bool_key\":true"}; + std::vector para = {"test_event", "\"type_\":1", "\"bool_key\":true"}; if (fileinfo != "") { result = CheckInfo(para, fileinfo); } else { @@ -148,7 +144,7 @@ HWTEST_F(HiAppEventCPPTest, DFX_DFT_HiviewKit_HiAppEvent_Native_0300, Function|M path = logPath + getlogFile; string fileinfo = ""; fileinfo = ReadFile(path); - std::vector para = {"test_event","\"type_\":1","\"bool_arr_key\":[true,true]"}; + std::vector para = {"test_event", "\"type_\":1", "\"bool_arr_key\":[true,true]"}; if (fileinfo != "") { result = CheckInfo(para, fileinfo); } else { @@ -182,7 +178,7 @@ HWTEST_F(HiAppEventCPPTest, DFX_DFT_HiviewKit_HiAppEvent_Native_0400, Function|M path = logPath + getlogFile; string fileinfo = ""; fileinfo = ReadFile(path); - std::vector para = {"test_event","\"type_\":4","\"str_key\":\"hello\""}; + std::vector para = {"test_event", "\"type_\":4", "\"str_key\":\"hello\""}; if (fileinfo != "") { result = CheckInfo(para, fileinfo); } else { @@ -218,7 +214,7 @@ HWTEST_F(HiAppEventCPPTest, DFX_DFT_HiviewKit_HiAppEvent_Native_0500, Function|M path = logPath + getlogFile; string fileinfo = ""; fileinfo = ReadFile(path); - std::vector para = {"test_event","\"type_\":4","\"str_arr_key\":[\"hello\",\"world\"]"}; + std::vector para = {"test_event", "\"type_\":4", "\"str_arr_key\":[\"hello\",\"world\"]"}; if (fileinfo != "") { result = CheckInfo(para, fileinfo); } else { @@ -252,7 +248,7 @@ HWTEST_F(HiAppEventCPPTest, DFX_DFT_HiviewKit_HiAppEvent_Native_0800, Function|M path = logPath + getlogFile; string fileinfo = ""; fileinfo = ReadFile(path); - std::vector para = {"test_event","\"type_\":1","\"double_key\":30949.374"}; + std::vector para = {"test_event", "\"type_\":1", "\"double_key\":30949.374"}; if (fileinfo != "") { result = CheckInfo(para, fileinfo); } else { @@ -286,7 +282,7 @@ HWTEST_F(HiAppEventCPPTest, DFX_DFT_HiviewKit_HiAppEvent_Native_0900, Function|M path = logPath + getlogFile; string fileinfo = ""; fileinfo = ReadFile(path); - std::vector para = {"test_event","\"type_\":2","\"double_arr_key\":[123.22,30949.374,131312.46464]"}; + std::vector para = {"test_event", "\"type_\":2", "\"double_arr_key\":[123.22,30949.374,131312.46464]"}; if (fileinfo != "") { result = CheckInfo(para, fileinfo); } else { @@ -320,7 +316,7 @@ HWTEST_F(HiAppEventCPPTest, DFX_DFT_HiviewKit_HiAppEvent_Native_1000, Function|M path = logPath + getlogFile; string fileinfo = ""; fileinfo = ReadFile(path); - std::vector para = {"test_event","\"type_\":2","\"float_key\":234.5"}; + std::vector para = {"test_event", "\"type_\":2", "\"float_key\":234.5"}; if (fileinfo != "") { result = CheckInfo(para, fileinfo); } else { @@ -354,7 +350,7 @@ HWTEST_F(HiAppEventCPPTest, DFX_DFT_HiviewKit_HiAppEvent_Native_1100, Function|M path = logPath + getlogFile; string fileinfo = ""; fileinfo = ReadFile(path); - std::vector para = {"test_event","\"type_\":2","\"float_arr_key\":[123.22", "234.5", "131312.46"}; + std::vector para = {"test_event", "\"type_\":2", "\"float_arr_key\":[123.22", "234.5", "131312.46"}; if (fileinfo != "") { result = CheckInfo(para, fileinfo); } else { @@ -422,7 +418,7 @@ HWTEST_F(HiAppEventCPPTest, DFX_DFT_HiviewKit_HiAppEvent_Native_1300, Function|M path = logPath + getlogFile; string fileinfo = ""; fileinfo = ReadFile(path); - std::vector para = {"test_event","\"type_\":3","\"int8_arr_key\":[1,10,100]"}; + std::vector para = {"test_event", "\"type_\":3", "\"int8_arr_key\":[1,10,100]"}; if (fileinfo != "") { result = CheckInfo(para, fileinfo); } else { @@ -558,7 +554,7 @@ HWTEST_F(HiAppEventCPPTest, DFX_DFT_HiviewKit_HiAppEvent_Native_1700, Function|M path = logPath + getlogFile; string fileinfo = ""; fileinfo = ReadFile(path); - std::vector para = {"test_event","\"type_\":3","\"int32_arr_key\":[1,100000,500000]"}; + std::vector para = {"test_event", "\"type_\":3", "\"int32_arr_key\":[1,100000,500000]"}; if (fileinfo != "") { result = CheckInfo(para, fileinfo); } else { @@ -626,7 +622,7 @@ HWTEST_F(HiAppEventCPPTest, DFX_DFT_HiviewKit_HiAppEvent_Native_1900, Function|M path = logPath + getlogFile; string fileinfo = ""; fileinfo = ReadFile(path); - std::vector para = {"test_event","\"type_\":3","\"int64_arr_key\":[1,10000000,50000000]"}; + std::vector para = {"test_event", "\"type_\":3", "\"int64_arr_key\":[1,10000000,50000000]"}; if (fileinfo != "") { result = CheckInfo(para, fileinfo); } else { @@ -647,9 +643,9 @@ HWTEST_F(HiAppEventCPPTest, DFX_DFT_HiviewKit_HiAppEvent_Native_2100, Function|M GTEST_LOG_(INFO) << "DFX_DFT_HiviewKit_HiAppEvent_Native_2100 start" << endl; bool result = false; char* strs[100]; - for (int i = 0; i < 100; i++){ + for (int i = 0; i < 100; i++) { strs[i] = new char[32]; - sprintf(strs[i],"hello_world_%d",i); + sprintf(strs[i], "hello_world_%d", i); } string getlogFile; string path; @@ -685,7 +681,7 @@ HWTEST_F(HiAppEventCPPTest, DFX_DFT_HiviewKit_HiAppEvent_Native_2200, Function|M GTEST_LOG_(INFO) << "DFX_DFT_HiviewKit_HiAppEvent_Native_2200 start" << endl; bool result = false; string strs = ""; - for (int i = 0; i < 1024; i++){ + for (int i = 0; i < 1024; i++) { strs.append("abcdefgh"); } string getlogFile; @@ -785,7 +781,7 @@ HWTEST_F(HiAppEventCPPTest, DFX_DFT_HiviewKit_HiAppEvent_Native_2700, Function|M string values[maxLen]; OHOS::HiviewDFX::HiAppEventConfig::GetInstance().SetStorageDir("/data/test/hiappevent/"); ParamList list = OH_HiAppEvent_CreateParamList(); - for (int i = 0; i <= maxLen; i++){ + for (int i = 0; i <= maxLen; i++) { keys[i] = "key" + std::to_string(i); values[i] = "value" + std::to_string(i); OH_HiAppEvent_AddStringParam(list, keys[i].c_str(), values[i].c_str()); @@ -798,7 +794,7 @@ HWTEST_F(HiAppEventCPPTest, DFX_DFT_HiviewKit_HiAppEvent_Native_2700, Function|M path = logPath + getlogFile; string fileinfo = ""; fileinfo = ReadFile(path); - std::vector para = {"test_event","\"type_\":1","\"key31\":\"value31\"","\"key15\":\"value15\""}; + std::vector para = {"test_event", "\"type_\":1", "\"key31\":\"value31\"", "\"key15\":\"value15\""}; if (fileinfo != "") { result = CheckInfo(para, fileinfo); } else { @@ -922,7 +918,7 @@ HWTEST_F(HiAppEventCPPTest, DFX_DFT_HiviewKit_HiAppEvent_Native_3100, Function|M GTEST_LOG_(INFO) << "DFX_DFT_HiviewKit_HiAppEvent_Native_3100 start" << endl; bool result = false; string strs = ""; - for (int i = 0; i < 1024; i++){ + for (int i = 0; i < 1024; i++) { strs.append("abcdefgh"); } strs.append("a"); @@ -995,7 +991,7 @@ HWTEST_F(HiAppEventCPPTest, DFX_DFT_HiviewKit_HiAppEvent_Native_3300, Function|M GTEST_LOG_(INFO) << "DFX_DFT_HiviewKit_HiAppEvent_Native_3300 start" << endl; bool result = false; char* strs[101]; - for (int i = 0; i < 101; i++){ + for (int i = 0; i < 101; i++) { strs[i] = new char[32]; sprintf(strs[i], "hello_world_%d", i); } @@ -1041,7 +1037,7 @@ HWTEST_F(HiAppEventCPPTest, DFX_DFT_HiviewKit_HiAppEvent_Native_3400, Function|M string values[maxLen+1]; OHOS::HiviewDFX::HiAppEventConfig::GetInstance().SetStorageDir("/data/test/hiappevent/"); ParamList list = OH_HiAppEvent_CreateParamList(); - for (int i = 0; i <= maxLen; i++){ + for (int i = 0; i <= maxLen; i++) { keys[i] = "key" + std::to_string(i); values[i] = "value" + std::to_string(i); OH_HiAppEvent_AddStringParam(list, keys[i].c_str(), values[i].c_str()); @@ -1054,7 +1050,7 @@ HWTEST_F(HiAppEventCPPTest, DFX_DFT_HiviewKit_HiAppEvent_Native_3400, Function|M path = logPath + getlogFile; string fileinfo = ""; fileinfo = ReadFile(path); - std::vector para = {"test_event", "\"type_\":1", "\"key31\":\"value31\"","\"key15\":\"value15\"", + std::vector para = {"test_event", "\"type_\":1", "\"key31\":\"value31\"", "\"key15\":\"value15\"", "\"key0\":\"value0\""}; if (fileinfo != "") { result = CheckInfo(para, fileinfo); @@ -1093,7 +1089,7 @@ HWTEST_F(HiAppEventCPPTest, DFX_DFT_HiviewKit_HiAppEvent_Native_3500, Function|M string cmd = "dd if=/dev/zero of=/data/test/hiappevent/" + fname + " bs=11M count=1"; ExecCmdWithRet(cmd, cmdret); ParamList list = OH_HiAppEvent_CreateParamList(); - for (int i = 0; i <= maxLen; i++){ + for (int i = 0; i <= maxLen; i++) { keys[i] = "key" + std::to_string(i); values[i] = "value" + std::to_string(i); OH_HiAppEvent_AddStringParam(list, keys[i].c_str(), values[i].c_str()); @@ -1106,7 +1102,7 @@ HWTEST_F(HiAppEventCPPTest, DFX_DFT_HiviewKit_HiAppEvent_Native_3500, Function|M path = logPath + getlogFile; bool result = false; string fileinfo = ReadFile(path); - std::vector para = {"test_event", "\"type_\":1", "\"key31\":\"value31\"","\"key15\":\"value15\"", + std::vector para = {"test_event", "\"type_\":1", "\"key31\":\"value31\"", "\"key15\":\"value15\"", "\"key0\":\"value0\""}; if (fileinfo != "") { result = CheckInfo(para, fileinfo); @@ -1142,7 +1138,7 @@ HWTEST_F(HiAppEventCPPTest, DFX_DFT_HiviewKit_HiAppEvent_Native_3600, Function|M string cmd = "dd if=/dev/zero of=/data/test/hiappevent/" + fname + " bs=1.5M count=1"; ExecCmdWithRet(cmd, cmdret); ParamList list = OH_HiAppEvent_CreateParamList(); - for (int i = 0; i <= maxLen; i++){ + for (int i = 0; i <= maxLen; i++) { keys[i] = "key" + std::to_string(i); values[i] = "value" + std::to_string(i); OH_HiAppEvent_AddStringParam(list, keys[i].c_str(), values[i].c_str()); @@ -1155,7 +1151,7 @@ HWTEST_F(HiAppEventCPPTest, DFX_DFT_HiviewKit_HiAppEvent_Native_3600, Function|M path = logPath + getlogFile; bool result = false; string fileinfo = ReadFile(path); - std::vector para = {"test_event", "\"type_\":1", "\"key31\":\"value31\"","\"key15\":\"value15\"", + std::vector para = {"test_event", "\"type_\":1", "\"key31\":\"value31\"", "\"key15\":\"value15\"", "\"key0\":\"value0\""}; if (fileinfo != "") { result = CheckInfo(para, fileinfo); -- GitLab