diff --git a/interfaces/test/unittest/BUILD.gn b/interfaces/test/unittest/BUILD.gn index ad71b6a7c3ec7328ead3a67d291d22428f19a795..6ab0c22a3f9f080d2f51fe818b80ccdf2b780566 100644 --- a/interfaces/test/unittest/BUILD.gn +++ b/interfaces/test/unittest/BUILD.gn @@ -13,8 +13,9 @@ group("unittest") { testonly = true + deps = [ - "filemgmt_libn_test:filemgmt_libn_test", + "class_file:class_file_test", "remote_uri:remote_uri_test", ] } diff --git a/interfaces/test/unittest/filemgmt_libn_test/BUILD.gn b/interfaces/test/unittest/class_file/BUILD.gn similarity index 59% rename from interfaces/test/unittest/filemgmt_libn_test/BUILD.gn rename to interfaces/test/unittest/class_file/BUILD.gn index 0203cfe9b0174a6c5f6e03499e4e1c4cbc384b32..e6f2f9266a6a40261feec4e705761b7c1e032d71 100644 --- a/interfaces/test/unittest/filemgmt_libn_test/BUILD.gn +++ b/interfaces/test/unittest/class_file/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (C) 2023 Huawei Device Co., Ltd. +# Copyright (c) 2023 Huawei Device Co., Ltd. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at @@ -14,29 +14,17 @@ import("//build/test.gni") import("//foundation/filemanagement/file_api/file_api.gni") -group("unittest") { - testonly = true - deps = [ ":filemgmt_libn_test" ] -} - -ohos_unittest("filemgmt_libn_test") { +ohos_unittest("class_file_test") { module_out_path = "filemanagement/file_api" - include_dirs = [ "./include" ] - sources = [ "./src/n_class_test.cpp" ] + resource_config_file = "../resource/ohos_test.xml" + + sources = [ "rust_test.cpp" ] + + include_dirs = [ "${file_api_path}/interfaces/kits/rust/include" ] deps = [ - "${utils_path}/filemgmt_libhilog:filemgmt_libhilog", - "${utils_path}/filemgmt_libn:filemgmt_libn", + "${file_api_path}/interfaces/kits/rust:rust_file", "//third_party/googletest:gtest_main", ] - - external_deps = [ - "access_token:libaccesstoken_sdk", - "c_utils:utils", - "c_utils:utilsbase", - "hilog:libhilog", - "ipc:ipc_core", - "napi:ace_napi", - ] -} +} \ No newline at end of file diff --git a/interfaces/test/unittest/class_file/rust_test.cpp b/interfaces/test/unittest/class_file/rust_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..9284b1c2af654a5437dfab83712ee881eb4d6427 --- /dev/null +++ b/interfaces/test/unittest/class_file/rust_test.cpp @@ -0,0 +1,595 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include +#include + +#include "rust_file.h" + +namespace OHOS { +namespace FileManagement { +namespace ModuleFileIO { +using namespace std; +class RustTest : public testing::Test { +public: + static void SetUpTestCase(void) {}; + static void TearDownTestCase() {}; + void SetUp() {}; + void TearDown() {}; +}; +/** +* @tc.name: RustTest_ReaderIterator_0001 +* @tc.desc: Test function of ReaderIterator() interface for SUCCESS. +* @tc.size: MEDIUM +* @tc.type: FUNC +* @tc.level Level 1 +* @tc.require: AR000IGDNF +*/ +HWTEST_F(RustTest, RustTest_ReaderIterator_0001, testing::ext::TestSize.Level1) +{ + GTEST_LOG_(INFO) << "RustTest-begin RustTest_ReaderIterator_0001"; + + char filePath[] = "/data/test/rust_test.txt"; + void *iter = ReaderIterator(filePath); + EXPECT_TRUE(iter != nullptr); + + GTEST_LOG_(INFO) << "RustTest-end RustTest_ReaderIterator_0001"; +} + +/** +* @tc.name: RustTest_ReaderIterator_0002 +* @tc.desc: Test function of ReaderIterator() interface for SUCCESS. +* @tc.size: MEDIUM +* @tc.type: FUNC +* @tc.level Level 1 +* @tc.require: AR000IGDNF +*/ +HWTEST_F(RustTest, RustTest_ReaderIterator_0002, testing::ext::TestSize.Level1) +{ + GTEST_LOG_(INFO) << "RustTest-begin RustTest_ReaderIterator_0002"; + + char filePath[] = "/data/test/rust_false.txt"; + void *iter = ReaderIterator(filePath); + ASSERT_TRUE(errno == 2); + EXPECT_TRUE(iter == nullptr); + + GTEST_LOG_(INFO) << "RustTest-end RustTest_ReaderIterator_0002"; +} + +/** +* @tc.name: RustTest_ReaderIterator_0003 +* @tc.desc: Test function of ReaderIterator() interface for SUCCESS. +* @tc.size: MEDIUM +* @tc.type: FUNC +* @tc.level Level 1 +* @tc.require: AR000IGDNF +*/ +HWTEST_F(RustTest, RustTest_ReaderIterator_0003, testing::ext::TestSize.Level1) +{ + GTEST_LOG_(INFO) << "RustTest-begin RustTest_ReaderIterator_0003"; + + void *iter = ReaderIterator(nullptr); + ASSERT_TRUE(errno = 22); + EXPECT_TRUE(iter == nullptr); + + GTEST_LOG_(INFO) << "RustTest-end RustTest_ReaderIterator_0003"; +} + +/** +* @tc.name: RustTest_NextLine_0001 +* @tc.desc: Test function of NextLine() interface for SUCCESS. +* @tc.size: MEDIUM +* @tc.type: FUNC +* @tc.level Level 1 +* @tc.require: AR000IGDNF +*/ +HWTEST_F(RustTest, RustTest_NextLine_0001, testing::ext::TestSize.Level1) +{ + GTEST_LOG_(INFO) << "RustTest-begin RustTest_NextLine_0001"; + + char filePath[] = "/data/test/rust_test.txt"; + void *iter = ReaderIterator(filePath); + Str *ret = NextLine(iter); + ASSERT_TRUE(ret != nullptr); + int result = strcmp(ret->str, "abc\n"); + EXPECT_TRUE(result == 0); + EXPECT_TRUE(ret->len == 4); + StrFree(ret); + + GTEST_LOG_(INFO) << "RustTest-end RustTest_NextLine_0001"; +} + +/** +* @tc.name: RustTest_NextLine_0002 +* @tc.desc: Test function of NextLine() interface for SUCCESS. +* @tc.size: MEDIUM +* @tc.type: FUNC +* @tc.level Level 1 +* @tc.require: AR000IGDNF +*/ +HWTEST_F(RustTest, RustTest_NextLine_0002, testing::ext::TestSize.Level1) +{ + GTEST_LOG_(INFO) << "RustTest-begin RustTest_NextLine_0002"; + + char filePath[] = "/data/test/false.txt"; + void *iter = ReaderIterator(filePath); + Str *ret = NextLine(iter); + EXPECT_TRUE(ret == nullptr); + StrFree(ret); + + GTEST_LOG_(INFO) << "RustTest-end RustTest_NextLine_0002"; +} + +/** +* @tc.name: RustTest_NextLine_0003 +* @tc.desc: Test function of NextLine() interface for SUCCESS. +* @tc.size: MEDIUM +* @tc.type: FUNC +* @tc.level Level 1 +* @tc.require: AR000IGDNF +*/ +HWTEST_F(RustTest, RustTest_NextLine_0003, testing::ext::TestSize.Level1) +{ + GTEST_LOG_(INFO) << "RustTest-begin RustTest_NextLine_0003"; + + Str *ret = NextLine(nullptr); + EXPECT_TRUE(ret == nullptr); + StrFree(ret); + + GTEST_LOG_(INFO) << "RustTest-end RustTest_NextLine_0003"; +} + +/** +* @tc.name: RustTest_Lseek_0001 +* @tc.desc: Test function of Lseek() interface for SUCCESS. +* @tc.size: MEDIUM +* @tc.type: FUNC +* @tc.level Level 1 +* @tc.require: AR000IGCS3 +*/ +HWTEST_F(RustTest, RustTest_Lseek_0001, testing::ext::TestSize.Level1) +{ + GTEST_LOG_(INFO) << "RustTest-begin RustTest_Lseek_0001"; + + const char fileStr[] = "/data/test/rust_test.txt"; + int fd = open(fileStr, O_RDWR); + ASSERT_TRUE(fd >= 0); + long long offset = -15; + long long ret = Lseek(fd, offset, END); + EXPECT_TRUE(ret == 105); + close(fd); + + GTEST_LOG_(INFO) << "RustTest-end RustTest_Lseek_0001"; +} + +/** +* @tc.name: RustTest_Lseek_0002 +* @tc.desc: Test function of Lseek() interface for SUCCESS. +* @tc.size: MEDIUM +* @tc.type: FUNC +* @tc.level Level 1 +* @tc.require: AR000IGCS3 +*/ +HWTEST_F(RustTest, RustTest_Lseek_0002, testing::ext::TestSize.Level1) +{ + GTEST_LOG_(INFO) << "RustTest-begin RustTest_Lseek_0002"; + + const char fileStr[] = "/data/test/rust_test.txt"; + int fd = open(fileStr, O_RDWR); + ASSERT_TRUE(fd >= 0); + long long offset = -15; + long long ret = Lseek(fd, offset, END); + EXPECT_TRUE(ret == 105); + offset = -10; + ret = Lseek(fd, offset, CURRENT); + EXPECT_TRUE(ret == 95); + close(fd); + + GTEST_LOG_(INFO) << "RustTest-end RustTest_Lseek_0002"; +} + +/** +* @tc.name: RustTest_Lseek_0003 +* @tc.desc: Test function of Lseek() interface for SUCCESS. +* @tc.size: MEDIUM +* @tc.type: FUNC +* @tc.level Level 1 +* @tc.require: AR000IGCS3 +*/ +HWTEST_F(RustTest, RustTest_Lseek_0003, testing::ext::TestSize.Level1) +{ + GTEST_LOG_(INFO) << "RustTest-begin RustTest_Lseek_0003"; + + const char fileStr[] = "/data/test/rust_test.txt"; + int fd = open(fileStr, O_RDWR); + ASSERT_TRUE(fd >= 0); + long long offset = 20; + long long ret = Lseek(fd, offset, START); + EXPECT_TRUE(ret == 20); + close(fd); + + GTEST_LOG_(INFO) << "RustTest-end RustTest_Lseek_0003"; +} + +/** +* @tc.name: RustTest_Lseek_0004 +* @tc.desc: Test function of Lseek() interface for SUCCESS. +* @tc.size: MEDIUM +* @tc.type: FUNC +* @tc.level Level 1 +* @tc.require: AR000IGCS3 +*/ +HWTEST_F(RustTest, RustTest_Lseek_0004, testing::ext::TestSize.Level1) +{ + GTEST_LOG_(INFO) << "RustTest-begin RustTest_Lseek_0004"; + + const char fileStr[] = "/data/test/rust_test.txt"; + int fd = open(fileStr, O_RDWR); + ASSERT_TRUE(fd >= 0); + long long offset = -10; + long long ret = Lseek(fd, offset, START); + EXPECT_TRUE(ret == -1); + close(fd); + + GTEST_LOG_(INFO) << "RustTest-end RustTest_Lseek_0004"; +} + +/** +* @tc.name: RustTest_Lseek_0005 +* @tc.desc: Test function of Lseek() interface for SUCCESS. +* @tc.size: MEDIUM +* @tc.type: FUNC +* @tc.level Level 1 +* @tc.require: AR000IGCS3 +*/ +HWTEST_F(RustTest, RustTest_Lseek_0005, testing::ext::TestSize.Level1) +{ + GTEST_LOG_(INFO) << "RustTest-begin RustTest_Lseek_0005"; + + const char fileStr[] = "/data/test/rust_test.txt"; + int fd = open(fileStr, O_RDWR); + ASSERT_TRUE(fd >= 0); + long long offset = 20; + long long ret = Lseek(fd, offset, START); + EXPECT_TRUE(ret == 20); + offset = 18; + ret = Lseek(fd, offset, CURRENT); + EXPECT_TRUE(ret == 38); + close(fd); + + GTEST_LOG_(INFO) << "RustTest-end RustTest_Lseek_0005"; +} + +/** +* @tc.name: RustTest_Lseek_0006 +* @tc.desc: Test function of Lseek() interface for SUCCESS. +* @tc.size: MEDIUM +* @tc.type: FUNC +* @tc.level Level 1 +* @tc.require: AR000IGCS3 +*/ +HWTEST_F(RustTest, RustTest_Lseek_0006, testing::ext::TestSize.Level1) +{ + GTEST_LOG_(INFO) << "RustTest-begin RustTest_Lseek_0006"; + + const char fileStr[] = "/data/test/rust_test.txt"; + int fd = open(fileStr, O_RDWR); + ASSERT_TRUE(fd >= 0); + long long offset = 30; + long long ret = Lseek(fd, offset, END); + EXPECT_TRUE(ret == 150); + close(fd); + + GTEST_LOG_(INFO) << "RustTest-end RustTest_Lseek_0006"; +} + +/** +* @tc.name: RustTest_Lseek_0007 +* @tc.desc: Test function of Lseek() interface for SUCCESS. +* @tc.size: MEDIUM +* @tc.type: FUNC +* @tc.level Level 1 +* @tc.require: AR000IGCS3 +*/ +HWTEST_F(RustTest, RustTest_Lseek_0007, testing::ext::TestSize.Level1) +{ + GTEST_LOG_(INFO) << "RustTest-begin RustTest_Lseek_0007"; + + long long offset = 30; + long long ret = Lseek(34, offset, END); + EXPECT_TRUE(ret == -1); + + GTEST_LOG_(INFO) << "RustTest-end RustTest_Lseek_0007"; +} + +/** +* @tc.name: RustTest_Mkdirs_0001 +* @tc.desc: Test function of Mkdirs() interface for SUCCESS. +* @tc.size: MEDIUM +* @tc.type: FUNC +* @tc.level Level 1 +* @tc.require: AR000IGDNJ +*/ +HWTEST_F(RustTest, RustTest_Mkdirs_0001, testing::ext::TestSize.Level1) +{ + GTEST_LOG_(INFO) << "RustTest-begin RustTest_Mkdirs_0001"; + + char filePathSingle[] = "/data/test/test1"; + int ret1 = access(filePathSingle, F_OK); + ASSERT_TRUE(ret1 == -1); + int ret = Mkdirs(filePathSingle, SINGLE); + EXPECT_TRUE(ret == 0); + ret1 = access(filePathSingle, F_OK); + ASSERT_TRUE(ret1 == 0); + int ret2 = remove(filePathSingle); + EXPECT_TRUE(ret2 == 0); + + GTEST_LOG_(INFO) << "RustTest-end RustTest_Mkdirs_0001"; +} + +/** +* @tc.name: RustTest_Mkdirs_0002 +* @tc.desc: Test function of Mkdirs() interface for SUCCESS. +* @tc.size: MEDIUM +* @tc.type: FUNC +* @tc.level Level 1 +* @tc.require: AR000IGDNJ +*/ +HWTEST_F(RustTest, RustTest_Mkdirs_0002, testing::ext::TestSize.Level1) +{ + GTEST_LOG_(INFO) << "RustTest-begin RustTest_Mkdirs_0002"; + + char filePathMultiple[] = "/data/test/test2/test3"; + int ret1 = access(filePathMultiple, F_OK); + ASSERT_TRUE(ret1 == -1); + int ret = Mkdirs(filePathMultiple, MULTIPLE); + EXPECT_TRUE(ret == 0); + ret1 = access(filePathMultiple, F_OK); + ASSERT_TRUE(ret1 == 0); + int ret2 = remove(filePathMultiple); + EXPECT_TRUE(ret2 == 0); + + GTEST_LOG_(INFO) << "RustTest-end RustTest_Mkdirs_0002"; +} + +/** +* @tc.name: RustTest_Mkdirs_0003 +* @tc.desc: Test function of Mkdirs() interface for SUCCESS. +* @tc.size: MEDIUM +* @tc.type: FUNC +* @tc.level Level 1 +* @tc.require: AR000IGDNJ +*/ +HWTEST_F(RustTest, RustTest_Mkdirs_0003, testing::ext::TestSize.Level1) +{ + GTEST_LOG_(INFO) << "RustTest-begin RustTest_Mkdirs_0003"; + + char filePathSingle[] = "/data/test/testfalse/test"; + int ret1 = access(filePathSingle, F_OK); + ASSERT_TRUE(ret1 == -1); + int ret = Mkdirs(filePathSingle, SINGLE); + EXPECT_TRUE(ret == -1); + + GTEST_LOG_(INFO) << "RustTest-end RustTest_Mkdirs_0003"; +} + +/** +* @tc.name: RustTest_Mkdirs_0004 +* @tc.desc: Test function of Mkdirs() interface for SUCCESS. +* @tc.size: MEDIUM +* @tc.type: FUNC +* @tc.level Level 1 +* @tc.require: AR000IGDNJ +*/ +HWTEST_F(RustTest, RustTest_Mkdirs_0004, testing::ext::TestSize.Level1) +{ + GTEST_LOG_(INFO) << "RustTest-begin RustTest_Mkdirs_0004"; + + char filePathMultiplr[] = "/data/test"; + int ret = Mkdirs(filePathMultiplr, MULTIPLE); + EXPECT_TRUE(ret == 0); + + GTEST_LOG_(INFO) << "RustTest-end RustTest_Mkdirs_0004"; +} + +/** +* @tc.name: RustTest_Mkdirs_0005 +* @tc.desc: Test function of Mkdirs() interface for SUCCESS. +* @tc.size: MEDIUM +* @tc.type: FUNC +* @tc.level Level 1 +* @tc.require: AR000IGDNJ +*/ +HWTEST_F(RustTest, RustTest_Mkdirs_0005, testing::ext::TestSize.Level1) +{ + GTEST_LOG_(INFO) << "RustTest-begin RustTest_Mkdirs_0005"; + + char filePath[] = ""; + int ret = Mkdirs(filePath, SINGLE); + ASSERT_TRUE(errno == 2); + EXPECT_TRUE(ret == -1); + + GTEST_LOG_(INFO) << "RustTest-end RustTest_Mkdirs_0005"; +} + +/** +* @tc.name: RustTest_Mkdirs_0006 +* @tc.desc: Test function of Mkdirs() interface for SUCCESS. +* @tc.size: MEDIUM +* @tc.type: FUNC +* @tc.level Level 1 +* @tc.require: AR000IGDNJ +*/ +HWTEST_F(RustTest, RustTest_Mkdirs_0006, testing::ext::TestSize.Level1) +{ + GTEST_LOG_(INFO) << "RustTest-begin RustTest_Mkdirs_0006"; + + char filePath[] = ""; + int ret = Mkdirs(filePath, MULTIPLE); + ASSERT_TRUE(errno == 2); + EXPECT_TRUE(ret == 0); + + GTEST_LOG_(INFO) << "RustTest-end RustTest_Mkdirs_0006"; +} + +/** +* @tc.name: RustTest_Mkdirs_0007 +* @tc.desc: Test function of Mkdirs() interface for SUCCESS. +* @tc.size: MEDIUM +* @tc.type: FUNC +* @tc.level Level 1 +* @tc.require: AR000IGDNJ +*/ +HWTEST_F(RustTest, RustTest_Mkdirs_0007, testing::ext::TestSize.Level1) +{ + GTEST_LOG_(INFO) << "RustTest-begin RustTest_Mkdirs_0007"; + + char filePath[] = "/data/test/rust_test.txt"; + int ret = Mkdirs(filePath, SINGLE); + ASSERT_TRUE(errno == 17); + EXPECT_TRUE(ret == -1); + + GTEST_LOG_(INFO) << "RustTest-end RustTest_Mkdirs_0007"; +} + +/** +* @tc.name: RustTest_Mkdirs_0008 +* @tc.desc: Test function of Mkdirs() interface for SUCCESS. +* @tc.size: MEDIUM +* @tc.type: FUNC +* @tc.level Level 1 +* @tc.require: AR000IGDNJ +*/ +HWTEST_F(RustTest, RustTest_Mkdirs_0008, testing::ext::TestSize.Level1) +{ + GTEST_LOG_(INFO) << "RustTest-begin RustTest_Mkdirs_0008"; + + char filePath[] = "/data/test/rust_test.txt"; + int ret = Mkdirs(filePath, MULTIPLE); + ASSERT_TRUE(errno == 17); + EXPECT_TRUE(ret == -1); + + GTEST_LOG_(INFO) << "RustTest-end RustTest_Mkdirs_0008"; +} + +/** +* @tc.name: RustTest_GetParent_0001 +* @tc.desc: Test function of GetParent() interface for SUCCESS. +* @tc.size: MEDIUM +* @tc.type: FUNC +* @tc.level Level 1 +* @tc.require: AR000IGDNL +*/ +HWTEST_F(RustTest, RustTest_GetParent_0001, testing::ext::TestSize.Level1) +{ + GTEST_LOG_(INFO) << "RustTest-begin RustTest_GetParent_0001"; + + const char fileStr[] = "/data/test/rust_test.txt"; + int fd = open(fileStr, O_RDWR); + Str *str = GetParent(fd); + ASSERT_TRUE(str != nullptr); + int result = strcmp(str->str, "/data/test"); + EXPECT_TRUE(result == 0); + StrFree(str); + close(fd); + + GTEST_LOG_(INFO) << "RustTest-end RustTest_GetParent_0001"; +} + +/** +* @tc.name: RustTest_GetParent_0002 +* @tc.desc: Test function of GetParent() interface for SUCCESS. +* @tc.size: MEDIUM +* @tc.type: FUNC +* @tc.level Level 1 +* @tc.require: AR000IGDNL +*/ +HWTEST_F(RustTest, RustTest_GetParent_0002, testing::ext::TestSize.Level1) +{ + GTEST_LOG_(INFO) << "RustTest-begin RustTest_GetParent_0002"; + + Str *str = GetParent(-1); + ASSERT_TRUE(errno != 0); + EXPECT_TRUE(str == nullptr); + + GTEST_LOG_(INFO) << "RustTest-end RustTest_GetParent_0002"; +} + +/** +* @tc.name: RustTest_GetParent_0003 +* @tc.desc: Test function of GetParent() interface for SUCCESS. +* @tc.size: MEDIUM +* @tc.type: FUNC +* @tc.level Level 1 +* @tc.require: AR000IGDNL +*/ +HWTEST_F(RustTest, RustTest_GetParent_0003, testing::ext::TestSize.Level1) +{ + GTEST_LOG_(INFO) << "RustTest-begin RustTest_GetParent_0003"; + + Str *str = GetParent(34); + ASSERT_TRUE(errno == 2); + EXPECT_TRUE(str == nullptr); + + GTEST_LOG_(INFO) << "RustTest-end RustTest_GetParent_0003"; +} + +/** +* @tc.name: RustTest_StrFree_0001 +* @tc.desc: Test function of StrFree() interface for SUCCESS. +* @tc.size: MEDIUM +* @tc.type: FUNC +* @tc.level Level 1 +* @tc.require: AR000IGDNF +*/ +HWTEST_F(RustTest, RustTest_StrFree_0001, testing::ext::TestSize.Level1) +{ + GTEST_LOG_(INFO) << "RustTest-begin RustTest_StrFree_0001"; + + const char fileStr[] = "/data/test/rust_test.txt"; + int fd = open(fileStr, O_RDWR); + Str *str1 = GetParent(fd); + int result = strcmp(str1->str, "/data/test"); + EXPECT_TRUE(result == 0); + StrFree(str1); + close(fd); + + GTEST_LOG_(INFO) << "RustTest-end RustTest_StrFree_0001"; +} + +/** +* @tc.name: RustTest_StrFree_0002 +* @tc.desc: Test function of StrFree() interface for SUCCESS. +* @tc.size: MEDIUM +* @tc.type: FUNC +* @tc.level Level 1 +* @tc.require: AR000IGDNF +*/ +HWTEST_F(RustTest, RustTest_StrFree_0002, testing::ext::TestSize.Level1) +{ + GTEST_LOG_(INFO) << "RustTest-begin RustTest_StrFree_0002"; + + Str *str = nullptr; + StrFree(str); + EXPECT_TRUE(str == nullptr); + + GTEST_LOG_(INFO) << "RustTest-end RustTest_StrFree_0002"; +} + +} +} +} \ No newline at end of file diff --git a/interfaces/test/unittest/filemgmt_libn_test/include/n_class_test.h b/interfaces/test/unittest/filemgmt_libn_test/include/n_class_test.h deleted file mode 100644 index 200927e492b48befaf026e4d7582bff59335a6b6..0000000000000000000000000000000000000000 --- a/interfaces/test/unittest/filemgmt_libn_test/include/n_class_test.h +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (C) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef FILEMGMT_LIBN_TEST_H -#define FILEMGMT_LIBN_TEST_H - -#include - -namespace OHOS { -namespace Media { -class FilemangementLibnTest : public testing::Test { -public: - static void SetUpTestCase(void); - static void TearDownTestCase(void); - void SetUp(); - void TearDown(); -}; -} -} -#endif \ No newline at end of file diff --git a/interfaces/test/unittest/filemgmt_libn_test/src/n_class_test.cpp b/interfaces/test/unittest/filemgmt_libn_test/src/n_class_test.cpp deleted file mode 100644 index a39ef98067971eac9c678e2da4f810cdfd5e9556..0000000000000000000000000000000000000000 --- a/interfaces/test/unittest/filemgmt_libn_test/src/n_class_test.cpp +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (C) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "n_class_test.h" -#include "n_class.h" - -using namespace std; -using namespace OHOS; -using namespace testing::ext; - -namespace OHOS { -namespace Media { -void FilemangementLibnTest::SetUpTestCase(void) {} - -void FilemangementLibnTest::TearDownTestCase(void) {} - -void FilemangementLibnTest::SetUp() {} - -void FilemangementLibnTest::TearDown() {} - -HWTEST_F(FilemangementLibnTest, NClassTest_DefineClass_001, TestSize.Level1) -{ - string className = "TestClassAB"; - napi_callback vlaue = nullptr; - vector props = {}; - bool succ = false; - napi_value classValue = nullptr; - napi_env envTest = nullptr; - tie(succ, classValue) = FileManagement::LibN::NClass::DefineClass(envTest, className, vlaue, std::move(props)); - EXPECT_EQ(succ, false); - EXPECT_EQ((classValue == nullptr), true); -} - -HWTEST_F(FilemangementLibnTest, NClassTest_SaveClass_001, TestSize.Level1) -{ - string className = "TestClassAB"; - bool succ = false; - napi_value classValue = nullptr; - napi_env envTest = nullptr; - succ = FileManagement::LibN::NClass::SaveClass(envTest, className, classValue); - EXPECT_EQ(succ, false); -} -} // namespace Media -} // namespace OHOS \ No newline at end of file diff --git a/interfaces/test/unittest/resource/ohos_test.xml b/interfaces/test/unittest/resource/ohos_test.xml index 0cd4027072d2ae4d7b3bb968faa67ab6ab26b069..658e8b2854be28dcf6160bb766fc705fbace6b68 100644 --- a/interfaces/test/unittest/resource/ohos_test.xml +++ b/interfaces/test/unittest/resource/ohos_test.xml @@ -19,4 +19,9 @@