diff --git a/distributeddatamgr/relationalStoretest/BUILD.gn b/distributeddatamgr/relationalStoretest/BUILD.gn index a62aeb6da3838e560449af3eb6b839483389a5d5..f795178ff52f393f267952fe53a97a41ba905329 100644 --- a/distributeddatamgr/relationalStoretest/BUILD.gn +++ b/distributeddatamgr/relationalStoretest/BUILD.gn @@ -18,6 +18,7 @@ group("relationalStoretest") { if (is_standard_system) { deps = [ "RdbJstest/hap:rdb_js_test", + "rdbnapitest:ActsRdbNapiEtsTest", "relationalStoreJstest/hap:relationalstore_js_test", "relationalStoreStagetest:relationalstore_ets_test", ] diff --git a/distributeddatamgr/relationalStoretest/rdbnapitest/BUILD.gn b/distributeddatamgr/relationalStoretest/rdbnapitest/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..d0c05e4710f434da9299e98d8d8e2722e1cc41bc --- /dev/null +++ b/distributeddatamgr/relationalStoretest/rdbnapitest/BUILD.gn @@ -0,0 +1,47 @@ +# 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. + +import("//build/ohos.gni") +import("//test/xts/tools/build/suite.gni") +ohos_js_hap_suite("ActsRdbNapiEtsTest") { + hap_profile = "./entry/src/main/config.json" + deps = [ + ":ace_third_ets_assets", + ":ace_third_ets_resources", + ":ace_third_ets_test_assets", + ] + ets2abc = true + certificate_profile = "./signature/openharmony_sx.p7b" + hap_name = "ActsRdbNapiEtsTest" + subsystem_name = "distributeddatamgr" + part_name = "relational_store" + shared_libraries = [ + "./entry/src/main/cpp:backup", + "./entry/src/main/cpp:encrypt", + "./entry/src/main/cpp:level", + "./entry/src/main/cpp:cursor", + "./entry/src/main/cpp:predicates", + "./entry/src/main/cpp:rdbstore", + ] +} + +ohos_js_assets("ace_third_ets_assets") { + source_dir = "./entry/src/main/ets/MainAbility" +} +ohos_js_assets("ace_third_ets_test_assets") { + source_dir = "./entry/src/main/ets/TestAbility" +} +ohos_resources("ace_third_ets_resources") { + sources = [ "./entry/src/main/resources" ] + hap_profile = "./entry/src/main/config.json" +} diff --git a/distributeddatamgr/relationalStoretest/rdbnapitest/Test.json b/distributeddatamgr/relationalStoretest/rdbnapitest/Test.json new file mode 100644 index 0000000000000000000000000000000000000000..92c3e7078e99633e3b060fa1e780253bf9395a80 --- /dev/null +++ b/distributeddatamgr/relationalStoretest/rdbnapitest/Test.json @@ -0,0 +1,23 @@ +{ + "description": "Configuration for hjunit demo Tests", + "driver": { + "type": "OHJSUnitTest", + "test-timeout": "600000", + "bundle-name": "com.acts.rdb.napitest", + "package-name": "com.acts.rdb.napitest", + "shell-timeout": "600000" + }, + "kits": [ + { + "test-file-name": [ + "ActsRdbNapiEtsTest.hap" + ], + "type": "AppInstallKit", + "cleanup-apps": true + }, + { + "type": "ShellKit", + "run-command": [] + } + ] +} diff --git a/distributeddatamgr/relationalStoretest/rdbnapitest/entry/src/main/config.json b/distributeddatamgr/relationalStoretest/rdbnapitest/entry/src/main/config.json new file mode 100644 index 0000000000000000000000000000000000000000..1e2c88c4e15bf0b273d7d5aba644ed738b1942c2 --- /dev/null +++ b/distributeddatamgr/relationalStoretest/rdbnapitest/entry/src/main/config.json @@ -0,0 +1,101 @@ +{ + "app": { + "bundleName": "com.acts.rdb.napitest", + "vendor": "open", + "version": { + "code": 1000000, + "name": "1.0.0" + }, + "apiVersion": { + "compatible": 7, + "releaseType": "Release", + "target": 8 + } + }, + "deviceConfig": {}, + "module": { + "package": "com.acts.rdb.napitest", + "name": ".MyApplication", + "mainAbility": "com.acts.rdb.napitest.MainAbility", + "deviceType": [ + "tablet", + "default", + "phone", + "2in1" + ], + "distro": { + "deliveryWithInstall": true, + "moduleName": "entry", + "moduleType": "entry", + "installationFree": false + }, + "abilities": [ + { + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ], + "orientation": "unspecified", + "visible": true, + "srcPath": "MainAbility", + "name": ".MainAbility", + "srcLanguage": "ets", + "icon": "$media:icon", + "description": "$string:description_mainability", + "formsEnabled": false, + "label": "$string:entry_MainAbility", + "type": "page", + "launchType": "standard" + }, + { + "orientation": "unspecified", + "visible": true, + "srcPath": "TestAbility", + "name": ".TestAbility", + "srcLanguage": "ets", + "icon": "$media:icon", + "description": "$string:TestAbility_desc", + "formsEnabled": false, + "label": "$string:TestAbility_label", + "type": "page", + "launchType": "standard" + } + ], + "js": [ + { + "mode": { + "syntax": "ets", + "type": "pageAbility" + }, + "pages": [ + "pages/index" + ], + "name": ".MainAbility", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } + }, + { + "mode": { + "syntax": "ets", + "type": "pageAbility" + }, + "pages": [ + "pages/index" + ], + "name": ".TestAbility", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } + } + ] + } +} \ No newline at end of file diff --git a/distributeddatamgr/relationalStoretest/rdbnapitest/entry/src/main/cpp/BUILD.gn b/distributeddatamgr/relationalStoretest/rdbnapitest/entry/src/main/cpp/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..980226904c43ae9844756800e216adf75bc3da46 --- /dev/null +++ b/distributeddatamgr/relationalStoretest/rdbnapitest/entry/src/main/cpp/BUILD.gn @@ -0,0 +1,228 @@ +# 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. + +import("//build/config/ohos/config.gni") +import("//build/ohos.gni") +import("//foundation/arkui/napi/napi.gni") +import("//foundation/distributeddatamgr/relational_store/relational_store.gni") + +relational_store_ndk_path = "${relational_store_base_path}/interfaces" + +config("config") { + visibility = [ ":*" ] + + cflags = [ + "-Wall", + "-Werror", + "-g3", + "-Wunused-variable", + ] +} + +## backup ############################################################### +ohos_shared_library("backup") { + subsystem_name = "distributeddatamgr" + part_name = "relational_store" + sources = [ "./napi/rdb_store_backup_test.cpp" ] + + include_dirs = [ + "../cpp", + "../cpp/common", + "${relational_store_common_path}/include", + "${relational_store_native_path}/rdb/include", + "${relational_store_ndk_path}/ndk/include/", + "${relational_store_ndk_path}/ndk/src/", + "${relational_store_base_path}/interfaces/ndk/include/oh_cursor.h", + "${relational_store_base_path}/interfaces/ndk/include/oh_predicates.h", + "${relational_store_base_path}/interfaces/ndk/include/oh_values_object.h", + "${relational_store_base_path}/interfaces/ndk/include/oh_values_bucket.h", + "${relational_store_base_path}/interfaces/ndk/include/relational_store.h", + "${relational_store_base_path}/interfaces/ndk/include/relational_store_error_code.h", + "${relational_store_base_path}/interfaces/ndk/src/relational_cursor.cpp", + "${relational_store_base_path}/interfaces/ndk/src/relational_predicates.cpp", + "${relational_store_base_path}/interfaces/ndk/src/relational_store.cpp", + "${relational_store_base_path}/interfaces/ndk/src/relational_value_object.cpp", + "${relational_store_base_path}/interfaces/ndk/src/relational_values_bucket.cpp", + "${relational_store_base_path}/interfaces/ndk/include", + ] + configs = [ ":config" ] + deps = [ "${relational_store_ndk_path}/ndk/src:native_rdb_ndk" ] + external_deps = [ "napi:ace_napi" ] + + output_extension = "so" +} + +## encrypt ############################################################### +ohos_shared_library("encrypt") { + subsystem_name = "distributeddatamgr" + part_name = "relational_store" + sources = [ "./napi/rdb_store_encrypt_test.cpp" ] + + include_dirs = [ + "../cpp", + "../cpp/common", + "${relational_store_common_path}/include", + "${relational_store_native_path}/rdb/include", + "${relational_store_ndk_path}/ndk/include/", + "${relational_store_ndk_path}/ndk/src/", + "${relational_store_base_path}/interfaces/ndk/include/oh_cursor.h", + "${relational_store_base_path}/interfaces/ndk/include/oh_predicates.h", + "${relational_store_base_path}/interfaces/ndk/include/oh_values_object.h", + "${relational_store_base_path}/interfaces/ndk/include/oh_values_bucket.h", + "${relational_store_base_path}/interfaces/ndk/include/relational_store.h", + "${relational_store_base_path}/interfaces/ndk/include/relational_store_error_code.h", + "${relational_store_base_path}/interfaces/ndk/src/relational_cursor.cpp", + "${relational_store_base_path}/interfaces/ndk/src/relational_predicates.cpp", + "${relational_store_base_path}/interfaces/ndk/src/relational_store.cpp", + "${relational_store_base_path}/interfaces/ndk/src/relational_value_object.cpp", + "${relational_store_base_path}/interfaces/ndk/src/relational_values_bucket.cpp", + "${relational_store_base_path}/interfaces/ndk/include", + ] + configs = [ ":config" ] + deps = [ "${relational_store_ndk_path}/ndk/src:native_rdb_ndk" ] + external_deps = [ "napi:ace_napi" ] + + output_extension = "so" +} + +## level ############################################################### +ohos_shared_library("level") { + subsystem_name = "distributeddatamgr" + part_name = "relational_store" + sources = [ "./napi/rdb_store_level_test.cpp" ] + + include_dirs = [ + "../cpp", + "../cpp/common", + "${relational_store_common_path}/include", + "${relational_store_native_path}/rdb/include", + "${relational_store_ndk_path}/ndk/include/", + "${relational_store_ndk_path}/ndk/src/", + "${relational_store_base_path}/interfaces/ndk/include/oh_cursor.h", + "${relational_store_base_path}/interfaces/ndk/include/oh_predicates.h", + "${relational_store_base_path}/interfaces/ndk/include/oh_values_object.h", + "${relational_store_base_path}/interfaces/ndk/include/oh_values_bucket.h", + "${relational_store_base_path}/interfaces/ndk/include/relational_store.h", + "${relational_store_base_path}/interfaces/ndk/include/relational_store_error_code.h", + "${relational_store_base_path}/interfaces/ndk/src/relational_cursor.cpp", + "${relational_store_base_path}/interfaces/ndk/src/relational_predicates.cpp", + "${relational_store_base_path}/interfaces/ndk/src/relational_store.cpp", + "${relational_store_base_path}/interfaces/ndk/src/relational_value_object.cpp", + "${relational_store_base_path}/interfaces/ndk/src/relational_values_bucket.cpp", + "${relational_store_base_path}/interfaces/ndk/include", + ] + configs = [ ":config" ] + deps = [ "${relational_store_ndk_path}/ndk/src:native_rdb_ndk" ] + external_deps = [ "napi:ace_napi" ] + + output_extension = "so" +} + +## cursor ############################################################### +ohos_shared_library("cursor") { + subsystem_name = "distributeddatamgr" + part_name = "relational_store" + sources = [ "./napi/rdb_store_cursor_test.cpp" ] + + include_dirs = [ + "../cpp", + "../cpp/common", + "${relational_store_common_path}/include", + "${relational_store_native_path}/rdb/include", + "${relational_store_ndk_path}/ndk/include/", + "${relational_store_ndk_path}/ndk/src/", + "${relational_store_base_path}/interfaces/ndk/include/oh_cursor.h", + "${relational_store_base_path}/interfaces/ndk/include/oh_predicates.h", + "${relational_store_base_path}/interfaces/ndk/include/oh_values_object.h", + "${relational_store_base_path}/interfaces/ndk/include/oh_values_bucket.h", + "${relational_store_base_path}/interfaces/ndk/include/relational_store.h", + "${relational_store_base_path}/interfaces/ndk/include/relational_store_error_code.h", + "${relational_store_base_path}/interfaces/ndk/src/relational_cursor.cpp", + "${relational_store_base_path}/interfaces/ndk/src/relational_predicates.cpp", + "${relational_store_base_path}/interfaces/ndk/src/relational_store.cpp", + "${relational_store_base_path}/interfaces/ndk/src/relational_value_object.cpp", + "${relational_store_base_path}/interfaces/ndk/src/relational_values_bucket.cpp", + "${relational_store_base_path}/interfaces/ndk/include", + ] + configs = [ ":config" ] + deps = [ "${relational_store_ndk_path}/ndk/src:native_rdb_ndk" ] + external_deps = [ "napi:ace_napi" ] + + output_extension = "so" +} + +## predicates ############################################################### +ohos_shared_library("predicates") { + subsystem_name = "distributeddatamgr" + part_name = "relational_store" + sources = [ "./napi/rdb_store_predicates_test.cpp" ] + + include_dirs = [ + "../cpp", + "../cpp/common", + "${relational_store_common_path}/include", + "${relational_store_native_path}/rdb/include", + "${relational_store_ndk_path}/ndk/include/", + "${relational_store_ndk_path}/ndk/src/", + "${relational_store_base_path}/interfaces/ndk/include/oh_cursor.h", + "${relational_store_base_path}/interfaces/ndk/include/oh_predicates.h", + "${relational_store_base_path}/interfaces/ndk/include/oh_values_object.h", + "${relational_store_base_path}/interfaces/ndk/include/oh_values_bucket.h", + "${relational_store_base_path}/interfaces/ndk/include/relational_store.h", + "${relational_store_base_path}/interfaces/ndk/include/relational_store_error_code.h", + "${relational_store_base_path}/interfaces/ndk/src/relational_cursor.cpp", + "${relational_store_base_path}/interfaces/ndk/src/relational_predicates.cpp", + "${relational_store_base_path}/interfaces/ndk/src/relational_store.cpp", + "${relational_store_base_path}/interfaces/ndk/src/relational_value_object.cpp", + "${relational_store_base_path}/interfaces/ndk/src/relational_values_bucket.cpp", + "${relational_store_base_path}/interfaces/ndk/include", + ] + configs = [ ":config" ] + deps = [ "${relational_store_ndk_path}/ndk/src:native_rdb_ndk" ] + external_deps = [ "napi:ace_napi" ] + + output_extension = "so" +} + +## rdbstore ############################################################### +ohos_shared_library("rdbstore") { + subsystem_name = "distributeddatamgr" + part_name = "relational_store" + sources = [ "./napi/rdb_store_test.cpp" ] + + include_dirs = [ + "../cpp", + "../cpp/common", + "${relational_store_common_path}/include", + "${relational_store_native_path}/rdb/include", + "${relational_store_ndk_path}/ndk/include/", + "${relational_store_ndk_path}/ndk/src/", + "${relational_store_base_path}/interfaces/ndk/include/oh_cursor.h", + "${relational_store_base_path}/interfaces/ndk/include/oh_predicates.h", + "${relational_store_base_path}/interfaces/ndk/include/oh_values_object.h", + "${relational_store_base_path}/interfaces/ndk/include/oh_values_bucket.h", + "${relational_store_base_path}/interfaces/ndk/include/relational_store.h", + "${relational_store_base_path}/interfaces/ndk/include/relational_store_error_code.h", + "${relational_store_base_path}/interfaces/ndk/src/relational_cursor.cpp", + "${relational_store_base_path}/interfaces/ndk/src/relational_predicates.cpp", + "${relational_store_base_path}/interfaces/ndk/src/relational_store.cpp", + "${relational_store_base_path}/interfaces/ndk/src/relational_value_object.cpp", + "${relational_store_base_path}/interfaces/ndk/src/relational_values_bucket.cpp", + "${relational_store_base_path}/interfaces/ndk/include", + ] + configs = [ ":config" ] + deps = [ "${relational_store_ndk_path}/ndk/src:native_rdb_ndk" ] + external_deps = [ "napi:ace_napi" ] + + output_extension = "so" +} diff --git a/distributeddatamgr/relationalStoretest/rdbnapitest/entry/src/main/cpp/common/common.h b/distributeddatamgr/relationalStoretest/rdbnapitest/entry/src/main/cpp/common/common.h new file mode 100644 index 0000000000000000000000000000000000000000..1da36855b787a1a6be77b726036a77e3a966dd49 --- /dev/null +++ b/distributeddatamgr/relationalStoretest/rdbnapitest/entry/src/main/cpp/common/common.h @@ -0,0 +1,103 @@ +/* + * 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 FOUNDATION_ACE_NAPI_INTERFACES_KITS_NAPI_NATIVE_COMMON_H +#define FOUNDATION_ACE_NAPI_INTERFACES_KITS_NAPI_NATIVE_COMMON_H + +#define DEPRECATED __attribute__((__deprecated__)) + +#define NAPI_VERSION 8 + +#define NAPI_RETVAL_NOTHING + +#define GET_AND_THROW_LAST_ERROR(env) \ + do { \ + const napi_extended_error_info* errorInfo = nullptr; \ + napi_get_last_error_info((env), &errorInfo); \ + bool isPending = false; \ + napi_is_exception_pending((env), &isPending); \ + if (!isPending && errorInfo != nullptr) { \ + const char* errorMessage = \ + errorInfo->error_message != nullptr ? errorInfo->error_message : "empty error message"; \ + napi_throw_error((env), nullptr, errorMessage); \ + } \ + } while (0) + +#define NAPI_ASSERT_BASE(env, assertion, message, retVal) \ + do { \ + if (!(assertion)) { \ + napi_throw_error((env), nullptr, "assertion (" #assertion ") failed: " message); \ + return retVal; \ + } \ + } while (0) + +#define NAPI_ASSERT(env, assertion, message) NAPI_ASSERT_BASE(env, assertion, message, nullptr) + +#define NAPI_ASSERT_RETURN_VOID(env, assertion, message) NAPI_ASSERT_BASE(env, assertion, message, NAPI_RETVAL_NOTHING) + +#define NAPI_CALL_BASE(env, theCall, retVal) \ + do { \ + if ((theCall) != napi_ok) { \ + GET_AND_THROW_LAST_ERROR((env)); \ + return retVal; \ + } \ + } while (0) + +#define NAPI_CALL(env, theCall) NAPI_CALL_BASE(env, theCall, nullptr) + +#define NAPI_CALL_RETURN_VOID(env, theCall) NAPI_CALL_BASE(env, theCall, NAPI_RETVAL_NOTHING) + +#define DECLARE_NAPI_PROPERTY(name, val) \ + { \ + (name), nullptr, nullptr, nullptr, nullptr, val, napi_default, nullptr \ + } + +#define DECLARE_NAPI_STATIC_PROPERTY(name, val) \ + { \ + (name), nullptr, nullptr, nullptr, nullptr, val, napi_static, nullptr \ + } + +#define DECLARE_NAPI_FUNCTION(name, func) \ + { \ + (name), nullptr, (func), nullptr, nullptr, nullptr, napi_default, nullptr \ + } + +#define DECLARE_NAPI_FUNCTION_WITH_DATA(name, func, data) \ + { \ + (name), nullptr, (func), nullptr, nullptr, nullptr, napi_default, data \ + } + +#define DECLARE_NAPI_STATIC_FUNCTION(name, func) \ + { \ + (name), nullptr, (func), nullptr, nullptr, nullptr, napi_static, nullptr \ + } + +#define DECLARE_NAPI_GETTER(name, getter) \ + { \ + (name), nullptr, nullptr, (getter), nullptr, nullptr, napi_default, nullptr \ + } + +#define DECLARE_NAPI_SETTER(name, setter) \ + { \ + (name), nullptr, nullptr, nullptr, (setter), nullptr, napi_default, nullptr \ + } + +#define DECLARE_NAPI_GETTER_SETTER(name, getter, setter) \ + { \ + (name), nullptr, nullptr, (getter), (setter), nullptr, napi_default, nullptr \ + } + +#endif /* FOUNDATION_ACE_NAPI_INTERFACES_KITS_NAPI_NATIVE_COMMON_H */ \ No newline at end of file diff --git a/distributeddatamgr/relationalStoretest/rdbnapitest/entry/src/main/cpp/napi/rdb_store_backup_test.cpp b/distributeddatamgr/relationalStoretest/rdbnapitest/entry/src/main/cpp/napi/rdb_store_backup_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..44b5735fefc95249c91364bb09caad0f8da7fdbe --- /dev/null +++ b/distributeddatamgr/relationalStoretest/rdbnapitest/entry/src/main/cpp/napi/rdb_store_backup_test.cpp @@ -0,0 +1,682 @@ +/* + * 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 +#include +#include +#include +#include +#include +#include + +#include "napi/native_api.h" +#include "common/common.h" +#include "relational_store.h" +#include "relational_store_error_code.h" +#include "oh_cursor.h" +#include "oh_predicates.h" +#include "oh_value_object.h" +#include "oh_values_bucket.h" + +char RDB_TEST_PATH[] = "/data/storage/el2/database/"; +char RDB_STORE_NAME[] = "rdb_store_test.db"; +char BUNDLE_NAME[] = "com.acts.rdb.napitest"; +char MODULE_NAME[] = "com.acts.rdb.napitest"; + +OH_Rdb_Store *storeBackupTestRdbStore_ = NULL; +static OH_Rdb_Config config_; +static void InitRdbConfig() +{ + config_.dataBaseDir = RDB_TEST_PATH; + config_.storeName = RDB_STORE_NAME; + config_.bundleName = BUNDLE_NAME; + config_.moduleName = MODULE_NAME; + config_.securityLevel = OH_Rdb_SecurityLevel::S1; + config_.isEncrypt = false; + config_.selfSize = sizeof(OH_Rdb_Config); +} + +static napi_value RdbstoreSetUpTestCase(napi_env env, napi_callback_info info) { + + InitRdbConfig(); + mkdir(config_.dataBaseDir, 0770); + + int errCode = 0; + storeBackupTestRdbStore_ = OH_Rdb_GetOrOpen(&config_, &errCode); + NAPI_ASSERT(env, errCode == 0, "OH_Rdb_GetOrOpen is fail."); + NAPI_ASSERT(env, storeBackupTestRdbStore_ != NULL, "OH_Rdb_GetOrOpen config is fail."); + + char createTableSql[] = "CREATE TABLE test (id INTEGER PRIMARY KEY AUTOINCREMENT, data1 TEXT, data2 INTEGER, " + "data3 FLOAT, data4 BLOB, data5 TEXT);"; + errCode = OH_Rdb_Execute(storeBackupTestRdbStore_, createTableSql); + NAPI_ASSERT(env, errCode == 0, "createTable is fail."); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} + +static napi_value RdbstoreTearDownTestCase(napi_env env, napi_callback_info info) { + int errCode = 0; + char dropTableSql[] = "DROP TABLE IF EXISTS test"; + errCode = OH_Rdb_Execute(storeBackupTestRdbStore_, dropTableSql); + NAPI_ASSERT(env, errCode == 0, "OH_Rdb_Execute is fail."); + errCode = OH_Rdb_CloseStore(storeBackupTestRdbStore_); + NAPI_ASSERT(env, errCode == 0, "OH_Rdb_CloseStore is fail."); + errCode = OH_Rdb_DeleteStore(&config_); + NAPI_ASSERT(env, errCode == 0, "OH_Rdb_DeleteStore is fail."); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} + +static napi_value SUB_DDM_RDB_BackupRestoreTest_0100(napi_env env, napi_callback_info info) { + + OH_VBucket *valueBucket = OH_Rdb_CreateValuesBucket(); + valueBucket->putText(valueBucket, "data1", "zhangSan"); + valueBucket->putInt64(valueBucket, "data2", 12800); + valueBucket->putReal(valueBucket, "data3", 100.1); + uint8_t arr[] = {1, 2, 3, 4, 5}; + int len = sizeof(arr) / sizeof(arr[0]); + valueBucket->putBlob(valueBucket, "data4", arr, len); + valueBucket->putText(valueBucket, "data5", "ABCDEFG"); + + int errCode = OH_Rdb_Insert(storeBackupTestRdbStore_, "test", valueBucket); + NAPI_ASSERT(env, errCode == 1, "OH_Rdb_Insert is fail."); + + char querySql[] = "SELECT * FROM test"; + OH_Cursor *cursor = OH_Rdb_ExecuteQuery(storeBackupTestRdbStore_, querySql); + + int rowCount = 0; + cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 1, "getRowCount is fail."); + cursor->destroy(cursor); + + char dbpath[] = ""; + char backupPath[100]; + sprintf(backupPath, "%s%s", RDB_TEST_PATH, dbpath); + errCode = OH_Rdb_Backup(storeBackupTestRdbStore_, backupPath); + NAPI_ASSERT(env, errCode == 14800011, "OH_Rdb_Backup is success."); + + errCode = valueBucket->destroy(valueBucket); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} + +static napi_value SUB_DDM_RDB_BackupRestoreTest_0300(napi_env env, napi_callback_info info) { + OH_VBucket *valueBucket = OH_Rdb_CreateValuesBucket(); + valueBucket->putInt64(valueBucket, "id", 1); + valueBucket->putText(valueBucket, "data1", "zhangSan"); + valueBucket->putInt64(valueBucket, "data2", 12800); + valueBucket->putReal(valueBucket, "data3", 100.1); + uint8_t arr[] = {1, 2, 3, 4, 5}; + int len = sizeof(arr) / sizeof(arr[0]); + valueBucket->putBlob(valueBucket, "data4", arr, len); + valueBucket->putText(valueBucket, "data5", "ABCDEFG"); + int errCode = OH_Rdb_Insert(storeBackupTestRdbStore_, "test", valueBucket); + NAPI_ASSERT(env, errCode == 1, "OH_Rdb_Insert is fail."); + + char querySql[] = "SELECT * FROM test"; + OH_Cursor *cursor = OH_Rdb_ExecuteQuery(storeBackupTestRdbStore_, querySql); + + int rowCount = 0; + cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 1, "getRowCount is fail."); + cursor->destroy(cursor); + + char dbpath[] = "backup.db"; + char backupPath[100]; + sprintf(backupPath, "%s%s", RDB_TEST_PATH, dbpath); + errCode = OH_Rdb_Backup(storeBackupTestRdbStore_, backupPath); + NAPI_ASSERT(env, errCode == 0, "OH_Rdb_Backup1 is fail."); + + errCode = OH_Rdb_Backup(storeBackupTestRdbStore_, backupPath); + NAPI_ASSERT(env, errCode == 0, "OH_Rdb_Backup2 is fail."); + + // delete data before restore + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + errCode = OH_Rdb_Delete(storeBackupTestRdbStore_, predicates); + NAPI_ASSERT(env, errCode == 1, "OH_Rdb_Delete is fail."); + + errCode = OH_Rdb_Restore(storeBackupTestRdbStore_, backupPath); + NAPI_ASSERT(env, errCode == 0, "OH_Rdb_Restore is fail."); + + cursor = OH_Rdb_ExecuteQuery(storeBackupTestRdbStore_, querySql); + cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 1, "getRowCount is fail."); + + errCode = cursor->goToNextRow(cursor); + NAPI_ASSERT(env, errCode == 0, "goToNextRow is fail."); + + size_t size = 0; + cursor->getSize(cursor, 1, &size); + char data1Value[size + 1]; + cursor->getText(cursor, 1, data1Value, size + 1); + NAPI_ASSERT(env, strncmp(data1Value, "zhangSan", 8) == 0, "getText is fail."); + + int64_t data2Value; + cursor->getInt64(cursor, 2, &data2Value); + NAPI_ASSERT(env, data2Value == 12800, "getInt64 is fail."); + + double data3Value; + cursor->getReal(cursor, 3, &data3Value); + NAPI_ASSERT(env, data3Value == 100.1, "getReal is fail."); + + cursor->getSize(cursor, 4, &size); + unsigned char data4Value[size]; + cursor->getBlob(cursor, 4, data4Value, size); + NAPI_ASSERT(env, data4Value[0] == 1, "getBlob1 is fail."); + NAPI_ASSERT(env, data4Value[1] == 2, "getBlob2 is fail."); + + cursor->getSize(cursor, 5, &size); + char data5Value[size + 1]; + cursor->getText(cursor, 5, data5Value, size + 1); + NAPI_ASSERT(env, strncmp(data5Value, "ABCDEFG", 7) == 0, "getText is fail."); + + valueBucket->destroy(valueBucket); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} + +static napi_value SUB_DDM_RDB_BackupRestoreTest_0400(napi_env env, napi_callback_info info) { + OH_VBucket *valueBucket = OH_Rdb_CreateValuesBucket(); + valueBucket->putInt64(valueBucket, "id", 1); + valueBucket->putText(valueBucket, "data1", "zhangSan"); + valueBucket->putInt64(valueBucket, "data2", 12800); + valueBucket->putReal(valueBucket, "data3", 100.1); + uint8_t arr[] = {1, 2, 3, 4, 5}; + int len = sizeof(arr) / sizeof(arr[0]); + valueBucket->putBlob(valueBucket, "data4", arr, len); + valueBucket->putText(valueBucket, "data5", "ABCDEFG"); + int errCode = OH_Rdb_Insert(storeBackupTestRdbStore_, "test", valueBucket); + NAPI_ASSERT(env, errCode == 1, "OH_Rdb_Insert is fail."); + + char querySql[] = "SELECT * FROM test"; + OH_Cursor *cursor = OH_Rdb_ExecuteQuery(storeBackupTestRdbStore_, querySql); + + int rowCount = 0; + cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 1, "getRowCount is fail."); + cursor->destroy(cursor); + + char dbpath1[] = "backup1.db"; + char backupPath1[100]; + sprintf(backupPath1, "%s%s", RDB_TEST_PATH, dbpath1); + errCode = OH_Rdb_Backup(storeBackupTestRdbStore_, backupPath1); + NAPI_ASSERT(env, errCode == 0, "OH_Rdb_Backup1 is fail."); + + char dbpath2[] = "backup2.db"; + char backupPath2[100]; + sprintf(backupPath2, "%s%s", RDB_TEST_PATH, dbpath2); + errCode = OH_Rdb_Backup(storeBackupTestRdbStore_, backupPath2); + NAPI_ASSERT(env, errCode == 0, "OH_Rdb_Backup2 is fail."); + + // delete data before restore + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + errCode = OH_Rdb_Delete(storeBackupTestRdbStore_, predicates); + NAPI_ASSERT(env, errCode == 1, "OH_Rdb_Delete is fail."); + + errCode = OH_Rdb_Restore(storeBackupTestRdbStore_, backupPath1); + NAPI_ASSERT(env, errCode == 0, "OH_Rdb_Restore1 is fail."); + + errCode = OH_Rdb_Restore(storeBackupTestRdbStore_, backupPath2); + NAPI_ASSERT(env, errCode == 0, "OH_Rdb_Restore2 is fail."); + + cursor = OH_Rdb_ExecuteQuery(storeBackupTestRdbStore_, querySql); + cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 1, "getRowCount is fail."); + + errCode = cursor->goToNextRow(cursor); + NAPI_ASSERT(env, errCode == 0, "goToNextRow is fail."); + + valueBucket->destroy(valueBucket); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} + + +static napi_value SUB_DDM_RDB_BackupRestoreTest_0500(napi_env env, napi_callback_info info) { + OH_VBucket *valueBucket = OH_Rdb_CreateValuesBucket(); + valueBucket->putInt64(valueBucket, "id", 1); + valueBucket->putText(valueBucket, "data1", "zhangSan"); + valueBucket->putInt64(valueBucket, "data2", 12800); + valueBucket->putReal(valueBucket, "data3", 100.1); + uint8_t arr[] = {1, 2, 3, 4, 5}; + int len = sizeof(arr) / sizeof(arr[0]); + valueBucket->putBlob(valueBucket, "data4", arr, len); + valueBucket->putText(valueBucket, "data5", "ABCDEFG"); + int errCode = OH_Rdb_Insert(storeBackupTestRdbStore_, "test", valueBucket); + NAPI_ASSERT(env, errCode == 1, "Insert data is fail."); + + char querySql[] = "SELECT * FROM test"; + OH_Cursor *cursor = OH_Rdb_ExecuteQuery(storeBackupTestRdbStore_, querySql); + + int rowCount = 0; + cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 1, "getRowCount is fail."); + cursor->destroy(cursor); + + char dbpath[] = "backup.db"; + char backupPath[100]; + sprintf(backupPath, "%s%s", RDB_TEST_PATH, dbpath); + + errCode = OH_Rdb_Backup(storeBackupTestRdbStore_, backupPath); + NAPI_ASSERT(env, errCode == 0, "OH_Rdb_Backup is fail."); + + // delete data before restore + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + errCode = OH_Rdb_Delete(storeBackupTestRdbStore_, predicates); + NAPI_ASSERT(env, errCode == 1, "DeleteData is fail."); + + errCode = OH_Rdb_Restore(storeBackupTestRdbStore_, backupPath); + NAPI_ASSERT(env, errCode == 0, "OH_Rdb_Restore is fail."); + + cursor = OH_Rdb_ExecuteQuery(storeBackupTestRdbStore_, querySql); + cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 1, "getRowCount is fail."); + + errCode = cursor->goToNextRow(cursor); + NAPI_ASSERT(env, errCode == 0, "goToNextRow is fail."); + + size_t size = 0; + cursor->getSize(cursor, 1, &size); + char data1Value[size + 1]; + cursor->getText(cursor, 1, data1Value, size + 1); + NAPI_ASSERT(env, strncmp(data1Value, "zhangSan", 8) == 0, "getText is fail."); + + int64_t data2Value; + cursor->getInt64(cursor, 2, &data2Value); + NAPI_ASSERT(env, data2Value == 12800, "getInt64 is fail."); + + double data3Value; + cursor->getReal(cursor, 3, &data3Value); + NAPI_ASSERT(env, data3Value == 100.1, "getReal is fail."); + + cursor->getSize(cursor, 4, &size); + unsigned char data4Value[size]; + cursor->getBlob(cursor, 4, data4Value, size); + NAPI_ASSERT(env, data4Value[0] == 1, "getBlob1 is fail."); + NAPI_ASSERT(env, data4Value[1] == 2, "getBlob2 is fail."); + + cursor->getSize(cursor, 5, &size); + char data5Value[size + 1]; + cursor->getText(cursor, 5, data5Value, size + 1); + NAPI_ASSERT(env, strncmp(data5Value, "ABCDEFG", 7) == 0, "getText is fail."); + + valueBucket->destroy(valueBucket); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} + + +static napi_value SUB_DDM_RDB_BackupRestoreTest_0600(napi_env env, napi_callback_info info) { + OH_VBucket *valueBucket = OH_Rdb_CreateValuesBucket(); + valueBucket->putInt64(valueBucket, "id", 1); + valueBucket->putText(valueBucket, "data1", "zhangSan"); + valueBucket->putInt64(valueBucket, "data2", 12800); + valueBucket->putReal(valueBucket, "data3", 100.1); + uint8_t arr[] = {1, 2, 3, 4, 5}; + int len = sizeof(arr) / sizeof(arr[0]); + valueBucket->putBlob(valueBucket, "data4", arr, len); + valueBucket->putText(valueBucket, "data5", "ABCDEFG"); + int errCode = OH_Rdb_Insert(storeBackupTestRdbStore_, "test", valueBucket); + NAPI_ASSERT(env, errCode == 1, "Insert data is fail."); + + char querySql[] = "SELECT * FROM test"; + OH_Cursor *cursor = OH_Rdb_ExecuteQuery(storeBackupTestRdbStore_, querySql); + + int rowCount = 0; + cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 1, "getRowCount is fail."); + cursor->destroy(cursor); + + char dbpath[] = " "; + char backupPath[100]; + sprintf(backupPath, "%s%s", RDB_TEST_PATH, dbpath); + errCode = OH_Rdb_Backup(storeBackupTestRdbStore_, backupPath); + NAPI_ASSERT(env, errCode == 0, "OH_Rdb_Backup is fail."); + + // delete data before restore + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + errCode = OH_Rdb_Delete(storeBackupTestRdbStore_, predicates); + NAPI_ASSERT(env, errCode == 1, "DeleteData is fail."); + + errCode = OH_Rdb_Restore(storeBackupTestRdbStore_, backupPath); + NAPI_ASSERT(env, errCode == 0, "OH_Rdb_Restore is fail."); + + cursor = OH_Rdb_ExecuteQuery(storeBackupTestRdbStore_, querySql); + cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 1, "getRowCount is fail."); + + errCode = cursor->goToNextRow(cursor); + NAPI_ASSERT(env, errCode == 0, "goToNextRow is fail."); + + size_t size = 0; + cursor->getSize(cursor, 1, &size); + char data1Value[size + 1]; + cursor->getText(cursor, 1, data1Value, size + 1); + NAPI_ASSERT(env, strncmp(data1Value, "zhangSan", 8) == 0, "getText is fail."); + + int64_t data2Value; + cursor->getInt64(cursor, 2, &data2Value); + NAPI_ASSERT(env, data2Value == 12800, "getInt64 is fail."); + + double data3Value; + cursor->getReal(cursor, 3, &data3Value); + NAPI_ASSERT(env, data3Value == 100.1, "getReal is fail."); + + cursor->getSize(cursor, 4, &size); + unsigned char data4Value[size]; + cursor->getBlob(cursor, 4, data4Value, size); + NAPI_ASSERT(env, data4Value[0] == 1, "getBlob1 is fail."); + NAPI_ASSERT(env, data4Value[1] == 2, "getBlob2 is fail."); + + cursor->getSize(cursor, 5, &size); + char data5Value[size + 1]; + cursor->getText(cursor, 5, data5Value, size + 1); + NAPI_ASSERT(env, strncmp(data5Value, "ABCDEFG", 7) == 0, "getText is fail."); + + valueBucket->destroy(valueBucket); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} + +static napi_value SUB_DDM_RDB_BackupRestoreTest_0700(napi_env env, napi_callback_info info) { + OH_VBucket *valueBucket = OH_Rdb_CreateValuesBucket(); + valueBucket->putInt64(valueBucket, "id", 1); + valueBucket->putText(valueBucket, "data1", "zhangSan"); + valueBucket->putInt64(valueBucket, "data2", 12800); + valueBucket->putReal(valueBucket, "data3", 100.1); + uint8_t arr[] = {1, 2, 3, 4, 5}; + int len = sizeof(arr) / sizeof(arr[0]); + valueBucket->putBlob(valueBucket, "data4", arr, len); + valueBucket->putText(valueBucket, "data5", "ABCDEFG"); + int errCode = OH_Rdb_Insert(storeBackupTestRdbStore_, "test", valueBucket); + NAPI_ASSERT(env, errCode == 1, "Insert data is fail."); + + char querySql[] = "SELECT * FROM test"; + OH_Cursor *cursor = OH_Rdb_ExecuteQuery(storeBackupTestRdbStore_, querySql); + + int rowCount = 0; + cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 1, "getRowCount is fail."); + cursor->destroy(cursor); + + errCode = OH_Rdb_Backup(storeBackupTestRdbStore_, NULL); + NAPI_ASSERT(env, errCode == 14800001, "OH_Rdb_Backup is success."); + + errCode = valueBucket->destroy(valueBucket); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} + +static napi_value SUB_DDM_RDB_BackupRestoreTest_0800(napi_env env, napi_callback_info info) { + OH_VBucket *valueBucket = OH_Rdb_CreateValuesBucket(); + valueBucket->putInt64(valueBucket, "id", 1); + valueBucket->putText(valueBucket, "data1", "zhangSan"); + valueBucket->putInt64(valueBucket, "data2", 12800); + valueBucket->putReal(valueBucket, "data3", 100.1); + uint8_t arr[] = {1, 2, 3, 4, 5}; + int len = sizeof(arr) / sizeof(arr[0]); + valueBucket->putBlob(valueBucket, "data4", arr, len); + valueBucket->putText(valueBucket, "data5", "ABCDEFG"); + int errCode = OH_Rdb_Insert(storeBackupTestRdbStore_, "test", valueBucket); + NAPI_ASSERT(env, errCode == 1, "Insert data is fail."); + + char querySql[] = "SELECT * FROM test"; + OH_Cursor *cursor = OH_Rdb_ExecuteQuery(storeBackupTestRdbStore_, querySql); + + int rowCount = 0; + cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 1, "getRowCount is fail."); + cursor->destroy(cursor); + + char dbpath[] = "backupNull.db"; + char backupPath[100]; + sprintf(backupPath, "%s%s", RDB_TEST_PATH, dbpath); + errCode = OH_Rdb_Backup(storeBackupTestRdbStore_, backupPath); + NAPI_ASSERT(env, errCode == 0, "OH_Rdb_Backup is fail."); + + // delete data before restore + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + errCode = OH_Rdb_Delete(storeBackupTestRdbStore_, predicates); + NAPI_ASSERT(env, errCode == 1, "DeleteData is fail."); + + errCode = OH_Rdb_Restore(storeBackupTestRdbStore_, NULL); + NAPI_ASSERT(env, errCode == 14800001, "OH_Rdb_Restore is success."); + + cursor = OH_Rdb_ExecuteQuery(storeBackupTestRdbStore_, querySql); + cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 0, "getRowCount is success."); + + errCode = OH_Rdb_Restore(storeBackupTestRdbStore_, backupPath); + NAPI_ASSERT(env, errCode == 0, "OH_Rdb_Restore is fail."); + + cursor = OH_Rdb_ExecuteQuery(storeBackupTestRdbStore_, querySql); + cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 1, "getRowCount is fail."); + + errCode = cursor->goToNextRow(cursor); + NAPI_ASSERT(env, errCode == 0, "goToNextRow is fail."); + + size_t size = 0; + cursor->getSize(cursor, 1, &size); + char data1Value[size + 1]; + cursor->getText(cursor, 1, data1Value, size + 1); + NAPI_ASSERT(env, strncmp(data1Value, "zhangSan", 8) == 0, "getText is fail."); + + int64_t data2Value; + cursor->getInt64(cursor, 2, &data2Value); + NAPI_ASSERT(env, data2Value == 12800, "getInt64 is fail."); + + double data3Value; + cursor->getReal(cursor, 3, &data3Value); + NAPI_ASSERT(env, data3Value == 100.1, "getReal is fail."); + + cursor->getSize(cursor, 4, &size); + unsigned char data4Value[size]; + cursor->getBlob(cursor, 4, data4Value, size); + NAPI_ASSERT(env, data4Value[0] == 1, "getBlob1 is fail."); + NAPI_ASSERT(env, data4Value[1] == 2, "getBlob2 is fail."); + + cursor->getSize(cursor, 5, &size); + char data5Value[size + 1]; + cursor->getText(cursor, 5, data5Value, size + 1); + NAPI_ASSERT(env, strncmp(data5Value, "ABCDEFG", 7) == 0, "getText is fail."); + + valueBucket->destroy(valueBucket); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} + + + +static napi_value SUB_DDM_RDB_BackupRestoreTest_0900(napi_env env, napi_callback_info info) { + OH_VBucket *valueBucket = OH_Rdb_CreateValuesBucket(); + valueBucket->putText(valueBucket, "data1", "zhangSan"); + valueBucket->putInt64(valueBucket, "data2", 12800); + valueBucket->putReal(valueBucket, "data3", 100.1); + uint8_t arr[] = {1, 2, 3, 4, 5}; + int len = sizeof(arr) / sizeof(arr[0]); + valueBucket->putBlob(valueBucket, "data4", arr, len); + valueBucket->putText(valueBucket, "data5", "ABCDEFG"); + + int errCode = OH_Rdb_Insert(storeBackupTestRdbStore_, "test", valueBucket); + NAPI_ASSERT(env, errCode == 1, "OH_Rdb_Insert is fail."); + + char querySql[] = "SELECT * FROM test"; + OH_Cursor *cursor = OH_Rdb_ExecuteQuery(storeBackupTestRdbStore_, querySql); + + int rowCount = 0; + cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 1, "getRowCount is fail."); + cursor->destroy(cursor); + + char dbpath[] = "backupEmpty.db"; + char backupPath[100]; + sprintf(backupPath, "%s%s", RDB_TEST_PATH, dbpath); + errCode = OH_Rdb_Backup(storeBackupTestRdbStore_, backupPath); + NAPI_ASSERT(env, errCode == 0, "OH_Rdb_Backup is fail."); + + // delete data before restore + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + errCode = OH_Rdb_Delete(storeBackupTestRdbStore_, predicates); + NAPI_ASSERT(env, errCode == 1, "OH_Rdb_Delete is fail."); + + char dbpath1[] = ""; + char reStorePath[100]; + sprintf(reStorePath, "%s%s", RDB_TEST_PATH, dbpath1); + + errCode = OH_Rdb_Restore(storeBackupTestRdbStore_, reStorePath); + NAPI_ASSERT(env, errCode == 14800011, "OH_Rdb_Restore is success."); + + cursor = OH_Rdb_ExecuteQuery(storeBackupTestRdbStore_, querySql); + cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 0, "getRowCount is fail."); + + errCode = OH_Rdb_Restore(storeBackupTestRdbStore_, backupPath); + NAPI_ASSERT(env, errCode == 0, "OH_Rdb_Restore is fail."); + + cursor = OH_Rdb_ExecuteQuery(storeBackupTestRdbStore_, querySql); + cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 1, "getRowCount is fail."); + + valueBucket->destroy(valueBucket); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} + +static napi_value SUB_DDM_RDB_BackupRestoreTest_0110(napi_env env, napi_callback_info info) { + OH_VBucket *valueBucket = OH_Rdb_CreateValuesBucket(); + valueBucket->putText(valueBucket, "data1", "zhangSan"); + valueBucket->putInt64(valueBucket, "data2", 12800); + valueBucket->putReal(valueBucket, "data3", 100.1); + uint8_t arr[] = {1, 2, 3, 4, 5}; + int len = sizeof(arr) / sizeof(arr[0]); + valueBucket->putBlob(valueBucket, "data4", arr, len); + valueBucket->putText(valueBucket, "data5", "ABCDEFG"); + + int errCode = OH_Rdb_Insert(storeBackupTestRdbStore_, "test", valueBucket); + NAPI_ASSERT(env, errCode == 1, "OH_Rdb_Insert is fail."); + + char querySql[] = "SELECT * FROM test"; + OH_Cursor *cursor = OH_Rdb_ExecuteQuery(storeBackupTestRdbStore_, querySql); + + int rowCount = 0; + cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 1, "getRowCount is fail."); + cursor->destroy(cursor); + + char dbpath[] = "backupWrong.db"; + char backupPath[100]; + sprintf(backupPath, "%s%s", RDB_TEST_PATH, dbpath); + + errCode = OH_Rdb_Backup(storeBackupTestRdbStore_, backupPath); + NAPI_ASSERT(env, errCode == 0, "OH_Rdb_Backup is fail."); + + // delete data before restore + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + errCode = OH_Rdb_Delete(storeBackupTestRdbStore_, predicates); + NAPI_ASSERT(env, errCode == 1, "OH_Rdb_Delete is fail."); + + char dbpath2[] = "wrong.db"; + char reStorePath[100]; + sprintf(reStorePath, "%s%s", RDB_TEST_PATH, dbpath2); + errCode = OH_Rdb_Restore(storeBackupTestRdbStore_, reStorePath); + NAPI_ASSERT(env, errCode == 14800011, "OH_Rdb_Restore is success."); + + cursor = OH_Rdb_ExecuteQuery(storeBackupTestRdbStore_, querySql); + cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 0, "getRowCount is fail."); + + errCode = OH_Rdb_Restore(storeBackupTestRdbStore_, backupPath); + NAPI_ASSERT(env, errCode == 0, "OH_Rdb_Restore is fail."); + + cursor = OH_Rdb_ExecuteQuery(storeBackupTestRdbStore_, querySql); + cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 1, "getRowCount is fail."); + + valueBucket->destroy(valueBucket); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} + + + + +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) { + napi_property_descriptor desc[] = { + {"RdbstoreSetUpTestCase", nullptr, RdbstoreSetUpTestCase, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"RdbstoreTearDownTestCase", nullptr, RdbstoreTearDownTestCase, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_BackupRestoreTest_0100", nullptr, SUB_DDM_RDB_BackupRestoreTest_0100, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_BackupRestoreTest_0300", nullptr, SUB_DDM_RDB_BackupRestoreTest_0300, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_BackupRestoreTest_0400", nullptr, SUB_DDM_RDB_BackupRestoreTest_0400, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_BackupRestoreTest_0500", nullptr, SUB_DDM_RDB_BackupRestoreTest_0500, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_BackupRestoreTest_0600", nullptr, SUB_DDM_RDB_BackupRestoreTest_0600, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_BackupRestoreTest_0700", nullptr, SUB_DDM_RDB_BackupRestoreTest_0700, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_BackupRestoreTest_0800", nullptr, SUB_DDM_RDB_BackupRestoreTest_0800, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_BackupRestoreTest_0900", nullptr, SUB_DDM_RDB_BackupRestoreTest_0900, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_BackupRestoreTest_0110", nullptr, SUB_DDM_RDB_BackupRestoreTest_0110, nullptr, nullptr, nullptr, napi_default, nullptr} + }; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END + + + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "backup", + .nm_priv = ((void *)0), + .reserved = {0}, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { + napi_module_register(&demoModule); +} diff --git a/distributeddatamgr/relationalStoretest/rdbnapitest/entry/src/main/cpp/napi/rdb_store_cursor_test.cpp b/distributeddatamgr/relationalStoretest/rdbnapitest/entry/src/main/cpp/napi/rdb_store_cursor_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..be86f796f528b23f95d0f40c7dbc53e790e71f7f --- /dev/null +++ b/distributeddatamgr/relationalStoretest/rdbnapitest/entry/src/main/cpp/napi/rdb_store_cursor_test.cpp @@ -0,0 +1,772 @@ +/* + * 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 +#include +#include +#include +#include +#include +#include + +#include "napi/native_api.h" +#include "common/common.h" +#include "relational_store.h" +#include "relational_store_error_code.h" +#include "oh_cursor.h" +#include "oh_predicates.h" +#include "oh_value_object.h" +#include "oh_values_bucket.h" + +OH_Rdb_Store *cursorTestRdbStore_ = NULL; + +char RDB_TEST_PATH[] = "/data/storage/el2/database/"; +char RDB_STORE_NAME[] = "rdb_store_cursor_test.db"; +char BUNDLE_NAME[] = "com.acts.rdb.napitest"; +char MODULE_NAME[] = "com.acts.rdb.napitest"; + +static OH_Rdb_Config config_; +static void InitRdbConfig() +{ + config_.dataBaseDir = RDB_TEST_PATH; + config_.storeName = RDB_STORE_NAME; + config_.bundleName = BUNDLE_NAME; + config_.moduleName = MODULE_NAME; + config_.securityLevel = OH_Rdb_SecurityLevel::S1; + config_.isEncrypt = false; + config_.selfSize = sizeof(OH_Rdb_Config); +} + +static napi_value CursorSetUpTestCase(napi_env env, napi_callback_info info) { + InitRdbConfig(); + mkdir(config_.dataBaseDir, 0770); + + int errCode = 0; + char table[] = "test"; + cursorTestRdbStore_ = OH_Rdb_GetOrOpen(&config_, &errCode); + NAPI_ASSERT(env, errCode == 0, "OH_Rdb_GetOrOpen is fail."); + NAPI_ASSERT(env, cursorTestRdbStore_ != NULL, "OH_Rdb_GetOrOpen config is fail."); + + char createTableSql[] = "CREATE TABLE test (id INTEGER PRIMARY KEY AUTOINCREMENT, data1 TEXT, data2 INTEGER, " + "data3 FLOAT, data4 BLOB, data5 TEXT);"; + errCode = OH_Rdb_Execute(cursorTestRdbStore_, createTableSql); + + OH_VBucket *valueBucket = OH_Rdb_CreateValuesBucket(); + valueBucket->putInt64(valueBucket, "id", 1); + valueBucket->putText(valueBucket, "data1", "zhangSan"); + valueBucket->putInt64(valueBucket, "data2", 12800); + valueBucket->putReal(valueBucket, "data3", 100.1); + uint8_t arr[] = {1, 2, 3, 4, 5}; + int len = sizeof(arr) / sizeof(arr[0]); + valueBucket->putBlob(valueBucket, "data4", arr, len); + valueBucket->putText(valueBucket, "data5", "ABCDEFG"); + errCode = OH_Rdb_Insert(cursorTestRdbStore_, table, valueBucket); + NAPI_ASSERT(env, errCode == 1, "OH_Rdb_Insert 1 is fail."); + + valueBucket->clear(valueBucket); + valueBucket->putInt64(valueBucket, "id", 2); + valueBucket->putText(valueBucket, "data1", "liSi"); + valueBucket->putInt64(valueBucket, "data2", 13800); + valueBucket->putReal(valueBucket, "data3", 200.1); + valueBucket->putText(valueBucket, "data5", "ABCDEFGH"); + errCode = OH_Rdb_Insert(cursorTestRdbStore_, table, valueBucket); + NAPI_ASSERT(env, errCode == 2, "OH_Rdb_Insert 2 is fail."); + + valueBucket->clear(valueBucket); + valueBucket->putInt64(valueBucket, "id", 3); + valueBucket->putText(valueBucket, "data1", "wangWu"); + valueBucket->putInt64(valueBucket, "data2", 14800); + valueBucket->putReal(valueBucket, "data3", 300.1); + valueBucket->putText(valueBucket, "data5", "ABCDEFGHI"); + errCode = OH_Rdb_Insert(cursorTestRdbStore_, table, valueBucket); + NAPI_ASSERT(env, errCode == 3, "OH_Rdb_Insert 3 is fail."); + + errCode = valueBucket->destroy(valueBucket); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} + +static napi_value CursorTearDownTestCase(napi_env env, napi_callback_info info) { + int errCode = 0; + char dropTableSql[] = "DROP TABLE IF EXISTS test"; + errCode = OH_Rdb_Execute(cursorTestRdbStore_, dropTableSql); + NAPI_ASSERT(env, errCode == 0, "OH_Rdb_Execute is fail."); + errCode = OH_Rdb_CloseStore(cursorTestRdbStore_); + NAPI_ASSERT(env, errCode == 0, "OH_Rdb_CloseStore is fail."); + errCode = OH_Rdb_DeleteStore(&config_); + NAPI_ASSERT(env, errCode == 0, "OH_Rdb_DeleteStore is fail."); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} + +/** + * @tc.name: SUB_DDM_RDB_CURSOR_0100 + * @tc.desc: napi test RDB cursor for GetColumnType. + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_CURSOR_0100(napi_env env, napi_callback_info info) { + + int errCode = 0; + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + + OH_Cursor *cursor = OH_Rdb_Query(cursorTestRdbStore_, predicates, NULL, 0); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query config is fail."); + + cursor->goToNextRow(cursor); + + OH_ColumnType type; + errCode = cursor->getColumnType(cursor, 0, &type); + NAPI_ASSERT(env, type == OH_ColumnType::TYPE_INT64, "getColumnType 0 is fail."); + + errCode = cursor->getColumnType(cursor, 1, &type);; + NAPI_ASSERT(env, type == OH_ColumnType::TYPE_TEXT, "getColumnType 1 is fail."); + + errCode = cursor->getColumnType(cursor, 2, &type); + NAPI_ASSERT(env, type == OH_ColumnType::TYPE_INT64, "getColumnType 2 is fail."); + + errCode = cursor->getColumnType(cursor, 3, &type); + NAPI_ASSERT(env, type == OH_ColumnType::TYPE_REAL, "getColumnType 3 is fail."); + + errCode = cursor->getColumnType(cursor, 4, &type); + NAPI_ASSERT(env, type == OH_ColumnType::TYPE_BLOB, "getColumnType 4 is fail."); + + errCode = cursor->getColumnType(cursor, 5, &type); + NAPI_ASSERT(env, type == OH_ColumnType::TYPE_TEXT, "getColumnType 5 is fail."); + + predicates->destroy(predicates); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} + + +/** + * @tc.name: SUB_DDM_RDB_CURSOR_0200 + * @tc.desc: napi test RDB cursor for GetColumnIndex. + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_CURSOR_0200(napi_env env, napi_callback_info info) { + int errCode = 0; + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + + OH_Cursor *cursor = OH_Rdb_Query(cursorTestRdbStore_, predicates, NULL, 0); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query config is fail."); + + int columnIndex; + errCode = cursor->getColumnIndex(cursor, "data1", &columnIndex); + NAPI_ASSERT(env, columnIndex == 1, "getColumnIndex 1 is fail."); + + errCode = cursor->getColumnIndex(cursor, "data2", &columnIndex); + NAPI_ASSERT(env, columnIndex == 2, "getColumnIndex 2 is fail."); + + errCode = cursor->getColumnIndex(cursor, "data3", &columnIndex); + NAPI_ASSERT(env, columnIndex == 3, "getColumnIndex 3 is fail."); + + errCode = cursor->getColumnIndex(cursor, "data4", &columnIndex); + NAPI_ASSERT(env, columnIndex == 4, "getColumnIndex 4 is fail."); + + errCode = cursor->getColumnIndex(cursor, "data5", &columnIndex); + NAPI_ASSERT(env, columnIndex == 5, "getColumnIndex 5 is fail."); + + predicates->destroy(predicates); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} +/** + * @tc.name: SUB_DDM_RDB_CURSOR_0300 + * @tc.desc: napi test RDB cursor for GetColumnName. + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_CURSOR_0300(napi_env env, napi_callback_info info) { + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + + OH_Cursor *cursor = OH_Rdb_Query(cursorTestRdbStore_, predicates, NULL, 0); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query config is fail."); + + char name[10]; + int errCode = cursor->getColumnName(cursor, 1, name, 10); + NAPI_ASSERT(env, strncmp(name, "data1", 5) == 0, "getColumnName data1 is fail."); + + errCode = cursor->getColumnName(cursor, 2, name, 6); + NAPI_ASSERT(env, strncmp(name, "data2", 5) == 0, "getColumnName data2 is fail."); + + errCode = cursor->getColumnName(cursor, 3, name, 6); + NAPI_ASSERT(env, strncmp(name, "data3", 5) == 0, "getColumnName data3 is fail."); + + errCode = cursor->getColumnName(cursor, 4, name, 6); + NAPI_ASSERT(env, strncmp(name, "data4", 5) == 0, "getColumnName data4 is fail."); + + errCode = cursor->getColumnName(cursor, 5, name, 6); + NAPI_ASSERT(env, strncmp(name, "data5", 5) == 0, "getColumnName data5 is fail."); + + predicates->destroy(predicates); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} + + +/** + * @tc.name: SUB_DDM_RDB_CURSOR_0400 + * @tc.desc: napi test RDB cursor for Getxxx. + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_CURSOR_0400(napi_env env, napi_callback_info info) { + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + + const char *columnNames[] = {"data1", "data2", "data3", "data4"}; + int len1 = sizeof(columnNames) / sizeof(columnNames[0]); + OH_Cursor *cursor = OH_Rdb_Query(cursorTestRdbStore_, predicates, columnNames, len1); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query config is fail."); + + int errCode = 0; + int rowCount = 0; + cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 3, "getRowCount is fail."); + + cursor->goToNextRow(cursor); + + int columnCount = 0; + cursor->getColumnCount(cursor, &columnCount); + NAPI_ASSERT(env, columnCount == 4, "getColumnCount is fail."); + + size_t size = 0; + cursor->getSize(cursor, 0, &size); + char data1Value[size + 1]; + cursor->getText(cursor, 0, data1Value, size + 1); + NAPI_ASSERT(env, strncmp(data1Value, "zhangSan", size) == 0, "getText is fail."); + + int64_t data2Value; + cursor->getInt64(cursor, 1, &data2Value); + NAPI_ASSERT(env, data2Value == 12800, "getInt64 is fail."); + + double data3Value; + cursor->getReal(cursor, 2, &data3Value); + NAPI_ASSERT(env, data3Value == 100.1, "getReal is fail."); + + cursor->getSize(cursor, 3, &size); + unsigned char data4Value[size]; + cursor->getBlob(cursor, 3, data4Value, size); + NAPI_ASSERT(env, data4Value[0] == 1, "getBlob 0 is fail."); + NAPI_ASSERT(env, data4Value[1] == 2, "getBlob 1 is fail."); + + cursor->goToNextRow(cursor); + + cursor->getSize(cursor, 0, &size); + char data1Value_1[size + 1]; + cursor->getText(cursor, 0, data1Value_1, size + 1); + NAPI_ASSERT(env, strncmp(data1Value_1, "liSi", size) == 0, "getText is fail."); + + cursor->getInt64(cursor, 1, &data2Value); + NAPI_ASSERT(env, data2Value == 13800, "getInt64 is fail."); + + cursor->getReal(cursor, 2, &data3Value); + NAPI_ASSERT(env, data3Value == 200.1, "getReal is fail."); + + bool isNull = false; + cursor->isNull(cursor, 3, &isNull); + NAPI_ASSERT(env, isNull == true, "isNull is fail."); + + predicates->destroy(predicates); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} +/** + * @tc.name: SUB_DDM_RDB_CURSOR_0500 + * @tc.desc: napi test RDB cursor for GetColumnIndex. + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_CURSOR_0500(napi_env env, napi_callback_info info) { + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + + OH_Cursor *cursor = OH_Rdb_Query(cursorTestRdbStore_, predicates, NULL, 0); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query is fail."); + + int columnIndex; + int errCode = cursor->getColumnIndex(cursor, "data", &columnIndex); + NAPI_ASSERT(env, columnIndex == -1, "getColumnIndex is fail."); + + errCode = predicates->destroy(predicates); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} + +/** + * @tc.name: SUB_DDM_RDB_CURSOR_0600 + * @tc.desc: napi test RDB cursor for GetColumnIndex. + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_CURSOR_0600(napi_env env, napi_callback_info info) { + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + + OH_Cursor *cursor = OH_Rdb_Query(cursorTestRdbStore_, predicates, NULL, 0); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query is fail."); + + int columnIndex; + char *name = NULL; + int errCode = cursor->getColumnIndex(cursor, name, &columnIndex); + NAPI_ASSERT(env, errCode == 14800001, "getColumnIndex is fail."); + + errCode = predicates->destroy(predicates); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} + +/** + * @tc.name: SUB_DDM_RDB_CURSOR_0700 + * @tc.desc: napi test RDB cursor for GetColumnType. + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_CURSOR_0700(napi_env env, napi_callback_info info) { + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + + OH_Cursor *cursor = OH_Rdb_Query(cursorTestRdbStore_, predicates, NULL, 0); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query is fail."); + + cursor->goToNextRow(cursor); + + OH_ColumnType type; + int errCode = cursor->getColumnType(cursor, 6, &type); + NAPI_ASSERT(env, type == OH_ColumnType::TYPE_NULL, "getColumnType is fail."); + + predicates->destroy(predicates); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} + +/** + * @tc.name: SUB_DDM_RDB_CURSOR_0800 + * @tc.desc: napi test RDB cursor for GetColumnName. + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_CURSOR_0800(napi_env env, napi_callback_info info) { + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + + OH_Cursor *cursor = OH_Rdb_Query(cursorTestRdbStore_, predicates, NULL, 0); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query is fail."); + + char name[10] = ""; + int errCode = cursor->getColumnName(cursor, 6, name, 10); + NAPI_ASSERT(env, strncmp(name, "", 10) == 0, "getColumnName is fail."); + predicates->destroy(predicates); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} + +/** + * @tc.name: SUB_DDM_RDB_CURSOR_0900 + * @tc.desc: napi test RDB cursor for getSize. + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_CURSOR_0900(napi_env env, napi_callback_info info) { + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + + const char *columnNames[] = {"data1", "data2", "data3", "data4"}; + int len1 = sizeof(columnNames) / sizeof(columnNames[0]); + OH_Cursor *cursor = OH_Rdb_Query(cursorTestRdbStore_, predicates, columnNames, len1); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query is fail."); + + int errCode = 0; + int rowCount = 0; + cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 3, "getRowCount is fail."); + + cursor->goToNextRow(cursor); + + int columnCount = 0; + cursor->getColumnCount(cursor, &columnCount); + NAPI_ASSERT(env, columnCount == 4, "getColumnCount is fail."); + + size_t size = 0; + cursor->getSize(cursor, 6, &size); + NAPI_ASSERT(env, (int)size == 0, "getSize is fail."); + + predicates->destroy(predicates); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} + +/** + * @tc.name: SUB_DDM_RDB_CURSOR_1000 + * @tc.desc: napi test RDB cursor for getText. + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_CURSOR_1000(napi_env env, napi_callback_info info) { + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + + const char *columnNames[] = {"data1", "data2", "data3", "data4"}; + int len1 = sizeof(columnNames) / sizeof(columnNames[0]); + OH_Cursor *cursor = OH_Rdb_Query(cursorTestRdbStore_, predicates, columnNames, len1); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query config is fail."); + + int rowCount = 0; + cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 3, "getRowCount is fail."); + + cursor->goToNextRow(cursor); + + int columnCount = 0; + cursor->getColumnCount(cursor, &columnCount); + NAPI_ASSERT(env, columnCount == 4, "getColumnCount is fail."); + + size_t size = 0; + cursor->getSize(cursor, 0, &size); + char data1Value[size + 1]; + cursor->getText(cursor, 6, data1Value, size + 1); + NAPI_ASSERT(env, strncmp(data1Value, "", size) == 0, "getText is fail."); + + predicates->destroy(predicates); + int errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} + +/** + * @tc.name: SUB_DDM_RDB_CURSOR_1100 + * @tc.desc: napi test RDB cursor for getInt64. + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_CURSOR_1100(napi_env env, napi_callback_info info) { + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + + const char *columnNames[] = {"data1", "data2", "data3", "data4"}; + int len1 = sizeof(columnNames) / sizeof(columnNames[0]); + OH_Cursor *cursor = OH_Rdb_Query(cursorTestRdbStore_, predicates, columnNames, len1); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query config is fail."); + + int rowCount = 0; + cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 3, "getRowCount is fail."); + + cursor->goToNextRow(cursor); + + int columnCount = 0; + cursor->getColumnCount(cursor, &columnCount); + NAPI_ASSERT(env, columnCount == 4, "getColumnCount is fail."); + + int64_t data2Value = 0; + int errCode = cursor->getInt64(cursor, 6, &data2Value); + NAPI_ASSERT(env, data2Value == 0, "getInt64 is fail."); + + predicates->destroy(predicates); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} + +/** + * @tc.name: SUB_DDM_RDB_CURSOR_1200 + * @tc.desc: napi test RDB cursor for getReal. + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_CURSOR_1200(napi_env env, napi_callback_info info) { + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + + const char *columnNames[] = {"data1", "data2", "data3", "data4"}; + int len = sizeof(columnNames) / sizeof(columnNames[0]); + OH_Cursor *cursor = OH_Rdb_Query(cursorTestRdbStore_, predicates, columnNames, len); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query config is fail."); + + int rowCount = 0; + cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 3, "getRowCount is fail."); + + cursor->goToNextRow(cursor); + + int columnCount = 0; + cursor->getColumnCount(cursor, &columnCount); + NAPI_ASSERT(env, columnCount == 4, "getColumnCount is fail."); + + double data3Value = 0; + cursor->getReal(cursor, 6, &data3Value); + NAPI_ASSERT(env, data3Value == 0, "getReal is fail."); + + predicates->destroy(predicates); + int errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} + +/** + * @tc.name: SUB_DDM_RDB_CURSOR_1300 + * @tc.desc: getBlob + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_CURSOR_1300(napi_env env, napi_callback_info info) { + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + + const char *columnNames[] = {"data1", "data2", "data3", "data4"}; + int len1 = sizeof(columnNames) / sizeof(columnNames[0]); + OH_Cursor *cursor = OH_Rdb_Query(cursorTestRdbStore_, predicates, columnNames, len1); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query config is fail."); + + int rowCount = 0; + cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 3, "getRowCount is fail."); + + cursor->goToNextRow(cursor); + + int columnCount = 0; + cursor->getColumnCount(cursor, &columnCount); + NAPI_ASSERT(env, columnCount == 4, "getColumnCount is fail."); + + size_t size = 0; + cursor->getSize(cursor, 3, &size); + unsigned char data4Value[] = "string"; + int errCode = cursor->getBlob(cursor, 6, data4Value, size); + NAPI_ASSERT(env, strncmp((char*)data4Value, "string", size) == 0, "getBlob is fail."); + + predicates->destroy(predicates); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} + +/** + * @tc.name: SUB_DDM_RDB_CURSOR_1400 + * @tc.desc: isNull + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_CURSOR_1400(napi_env env, napi_callback_info info) { + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + + const char *columnNames[] = {"data1", "data2", "data3", "data4"}; + int len1 = sizeof(columnNames) / sizeof(columnNames[0]); + OH_Cursor *cursor = OH_Rdb_Query(cursorTestRdbStore_, predicates, columnNames, len1); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query is fail."); + + int rowCount = 0; + cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 3, "getRowCount is fail."); + + cursor->goToNextRow(cursor); + + int columnCount = 0; + cursor->getColumnCount(cursor, &columnCount); + NAPI_ASSERT(env, columnCount == 4, "getColumnCount is fail."); + + bool isNull = false; + int errCode = cursor->isNull(cursor, 6, &isNull); + NAPI_ASSERT(env, isNull == false, "isNull is fail."); + + predicates->destroy(predicates); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} + +/** + * @tc.name: SUB_DDM_RDB_CURSOR_1500 + * @tc.desc: getRowCount + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_CURSOR_1500(napi_env env, napi_callback_info info) { + + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + OH_VObject *valueObject = OH_Rdb_CreateValueObject(); + const char *data1Value = "zhangSan"; + valueObject->putText(valueObject, data1Value); + predicates->equalTo(predicates, "data1", valueObject); + + OH_Cursor *cursor = OH_Rdb_Query(cursorTestRdbStore_, predicates, NULL, 0); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query is fail."); + + int rowCount = 0; + cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 1, "getRowCount is fail."); + + predicates->destroy(predicates); + int errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} + +/** + * @tc.name: SUB_DDM_RDB_CURSOR_1600 + * @tc.desc: getRowCount + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_CURSOR_1600(napi_env env, napi_callback_info info) { + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + OH_VObject *valueObject = OH_Rdb_CreateValueObject(); + const char *data1Value = "name"; + valueObject->putText(valueObject, data1Value); + predicates->equalTo(predicates, "data1", valueObject); + + OH_Cursor *cursor = OH_Rdb_Query(cursorTestRdbStore_, predicates, NULL, 0); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query is fail."); + + int rowCount = -1; + cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 0, "getRowCount is fail."); + + predicates->destroy(predicates); + int errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} + +/** + * @tc.name: SUB_DDM_RDB_CURSOR_1700 + * @tc.desc: getRowCount + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_CURSOR_1700(napi_env env, napi_callback_info info) { + + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + OH_VObject *valueObject1 = OH_Rdb_CreateValueObject(); + const char *data1Value1 = "zhangSan"; + valueObject1->putText(valueObject1, data1Value1); + predicates->equalTo(predicates, "data1", valueObject1); + OH_VObject *valueObject2 = OH_Rdb_CreateValueObject(); + const char *data1Value2 = "name"; + valueObject2->putText(valueObject2, data1Value2); + predicates->equalTo(predicates, "data1", valueObject2); + + OH_Cursor *cursor = OH_Rdb_Query(cursorTestRdbStore_, predicates, NULL, 0); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query is fail."); + + int rowCount = -1; + cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 0, "getRowCount is fail."); + + predicates->destroy(predicates); + int errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} + +/** + * @tc.name: SUB_DDM_RDB_CURSOR_1800 + * @tc.desc: + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_CURSOR_1800(napi_env env, napi_callback_info info) { + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + OH_VObject *valueObject = OH_Rdb_CreateValueObject(); + const char *data1Value = "zhangSan1"; + valueObject->putText(valueObject, data1Value); + predicates->equalTo(predicates, "data1", valueObject); + + OH_Cursor *cursor = OH_Rdb_Query(cursorTestRdbStore_, predicates, NULL, 0); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query is fail."); + + int rowCount = -1; + cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 0, "getRowCount is fail."); + + int errCode = cursor->goToNextRow(cursor); + NAPI_ASSERT(env, errCode == 14800026, "goToNextRow is fail."); + + predicates->destroy(predicates); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} + +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) { + napi_property_descriptor desc[] = { + {"CursorSetUpTestCase", nullptr, CursorSetUpTestCase, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"CursorTearDownTestCase", nullptr, CursorTearDownTestCase, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_CURSOR_0100", nullptr, SUB_DDM_RDB_CURSOR_0100, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_CURSOR_0200", nullptr, SUB_DDM_RDB_CURSOR_0200, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_CURSOR_0300", nullptr, SUB_DDM_RDB_CURSOR_0300, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_CURSOR_0400", nullptr, SUB_DDM_RDB_CURSOR_0400, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_CURSOR_0500", nullptr, SUB_DDM_RDB_CURSOR_0500, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_CURSOR_0600", nullptr, SUB_DDM_RDB_CURSOR_0600, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_CURSOR_0700", nullptr, SUB_DDM_RDB_CURSOR_0700, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_CURSOR_0800", nullptr, SUB_DDM_RDB_CURSOR_0800, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_CURSOR_0900", nullptr, SUB_DDM_RDB_CURSOR_0900, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_CURSOR_1000", nullptr, SUB_DDM_RDB_CURSOR_1000, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_CURSOR_1100", nullptr, SUB_DDM_RDB_CURSOR_1100, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_CURSOR_1200", nullptr, SUB_DDM_RDB_CURSOR_1200, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_CURSOR_1300", nullptr, SUB_DDM_RDB_CURSOR_1300, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_CURSOR_1400", nullptr, SUB_DDM_RDB_CURSOR_1400, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_CURSOR_1500", nullptr, SUB_DDM_RDB_CURSOR_1500, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_CURSOR_1600", nullptr, SUB_DDM_RDB_CURSOR_1600, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_CURSOR_1700", nullptr, SUB_DDM_RDB_CURSOR_1700, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_CURSOR_1800", nullptr, SUB_DDM_RDB_CURSOR_1800, nullptr, nullptr, nullptr, napi_default, nullptr} + + }; + + + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END + + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "cursor", + .nm_priv = ((void *)0), + .reserved = {0}, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { + napi_module_register(&demoModule); +} diff --git a/distributeddatamgr/relationalStoretest/rdbnapitest/entry/src/main/cpp/napi/rdb_store_encrypt_test.cpp b/distributeddatamgr/relationalStoretest/rdbnapitest/entry/src/main/cpp/napi/rdb_store_encrypt_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..36c605988257646125390077ef703b6cbf49fea6 --- /dev/null +++ b/distributeddatamgr/relationalStoretest/rdbnapitest/entry/src/main/cpp/napi/rdb_store_encrypt_test.cpp @@ -0,0 +1,176 @@ +/* + * 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 +#include +#include +#include +#include +#include +#include + +#include "napi/native_api.h" +#include "common/common.h" +#include "relational_store.h" +#include "relational_store_error_code.h" +#include "oh_cursor.h" +#include "oh_predicates.h" +#include "oh_value_object.h" +#include "oh_values_bucket.h" + +char RDB_TEST_PATH[] = "/data/storage/el2/database/"; +char RDB_STORE_NAME[] = "rdb_store_encrypt_test.db"; +char RDB_STORE_NAME2[] = "Encrypt.db"; +char BUNDLE_NAME[] = "com.acts.rdb.napitest"; +char MODULE_NAME[] = "com.acts.rdb.napitest"; + + +OH_Rdb_Store *storeEncryptTestRdbStore_ = NULL; +OH_Rdb_Store *storeEncryptTestRdbStore2_ = NULL; +static OH_Rdb_Config config_; +static OH_Rdb_Config config1_; +static OH_Rdb_Config config2_; +static OH_Rdb_Config config3_; +static void InitRdbConfig() +{ + config_.dataBaseDir = RDB_TEST_PATH; + config_.storeName = RDB_STORE_NAME; + config_.bundleName = BUNDLE_NAME; + config_.moduleName = MODULE_NAME; + config_.securityLevel = OH_Rdb_SecurityLevel::S1; + config_.isEncrypt = false; + config_.selfSize = sizeof(OH_Rdb_Config); +} + +static void InitRdbConfig1() +{ + config1_.dataBaseDir = RDB_TEST_PATH; + config1_.storeName = RDB_STORE_NAME; + config1_.bundleName = BUNDLE_NAME; + config1_.moduleName = MODULE_NAME; + config1_.securityLevel = OH_Rdb_SecurityLevel::S2; + config1_.isEncrypt = false; + config1_.selfSize = sizeof(OH_Rdb_Config); +} + +static void InitRdbConfig2() +{ + config2_.dataBaseDir = RDB_TEST_PATH; + config2_.storeName = RDB_STORE_NAME2; + config2_.bundleName = BUNDLE_NAME; + config2_.moduleName = MODULE_NAME; + config2_.securityLevel = OH_Rdb_SecurityLevel::S1; + config2_.isEncrypt = true; + config2_.selfSize = sizeof(OH_Rdb_Config); +} + +static void InitRdbConfig3() +{ + config3_.dataBaseDir = RDB_TEST_PATH; + config3_.storeName = RDB_STORE_NAME2; + config3_.bundleName = BUNDLE_NAME; + config3_.moduleName = MODULE_NAME; + config3_.securityLevel = OH_Rdb_SecurityLevel::S1; + config3_.isEncrypt = false; + config3_.selfSize = sizeof(OH_Rdb_Config); +} + +static napi_value SUB_DDM_RDB_ENCRYPT_0100(napi_env env, napi_callback_info info) { + InitRdbConfig2(); + mkdir(config2_.dataBaseDir, 0770); + + InitRdbConfig3(); + mkdir(config3_.dataBaseDir, 0770); + + int errCode = 0; + storeEncryptTestRdbStore_ = OH_Rdb_GetOrOpen(&config2_, &errCode); + NAPI_ASSERT(env, errCode == 0, "OH_Rdb_GetOrOpen is fail."); + NAPI_ASSERT(env, storeEncryptTestRdbStore_ != NULL, "OH_Rdb_GetOrOpen config2 is fail."); + + storeEncryptTestRdbStore2_ = OH_Rdb_GetOrOpen(&config3_, &errCode); + NAPI_ASSERT(env, storeEncryptTestRdbStore2_ == NULL, "OH_Rdb_GetOrOpen config3 is success."); + + errCode = OH_Rdb_CloseStore(storeEncryptTestRdbStore_); + NAPI_ASSERT(env, errCode == 0, "OH_Rdb_CloseStore is fail."); + storeEncryptTestRdbStore_ = NULL; + storeEncryptTestRdbStore2_ = NULL; + + errCode = OH_Rdb_DeleteStore(&config2_); + NAPI_ASSERT(env, errCode == 0, "OH_Rdb_DeleteStore is fail."); + + errCode = OH_Rdb_DeleteStore(&config3_); + NAPI_ASSERT(env, errCode == 0, "OH_Rdb_DeleteStore is fail."); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} + + +static napi_value SUB_DDM_RDB_ENCRYPT_0200(napi_env env, napi_callback_info info) { + + InitRdbConfig(); + mkdir(config_.dataBaseDir, 0770); + + InitRdbConfig1(); + mkdir(config1_.dataBaseDir, 0770); + + int errCode = 0; + storeEncryptTestRdbStore_ = OH_Rdb_GetOrOpen(&config_, &errCode); + NAPI_ASSERT(env, errCode == 0, "OH_Rdb_GetOrOpen is fail."); + NAPI_ASSERT(env, storeEncryptTestRdbStore_ != NULL, "OH_Rdb_GetOrOpen config1 is fail."); + + storeEncryptTestRdbStore2_ = OH_Rdb_GetOrOpen(&config1_, &errCode); + NAPI_ASSERT(env, storeEncryptTestRdbStore2_ == NULL, "OH_Rdb_GetOrOpen config is success."); + + errCode = OH_Rdb_CloseStore(storeEncryptTestRdbStore_); + NAPI_ASSERT(env, errCode == 0, "OH_Rdb_CloseStore is fail."); + storeEncryptTestRdbStore_ = NULL; + storeEncryptTestRdbStore2_ = NULL; + errCode = OH_Rdb_DeleteStore(&config1_); + NAPI_ASSERT(env, errCode == 0, "OH_Rdb_DeleteStore is fail."); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} + + +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) { + napi_property_descriptor desc[] = { + {"SUB_DDM_RDB_ENCRYPT_0100", nullptr, SUB_DDM_RDB_ENCRYPT_0100, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_ENCRYPT_0200", nullptr, SUB_DDM_RDB_ENCRYPT_0200, nullptr, nullptr, nullptr, napi_default, nullptr}}; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "encrypt", + .nm_priv = ((void *)0), + .reserved = {0}, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { + napi_module_register(&demoModule); +} diff --git a/distributeddatamgr/relationalStoretest/rdbnapitest/entry/src/main/cpp/napi/rdb_store_level_test.cpp b/distributeddatamgr/relationalStoretest/rdbnapitest/entry/src/main/cpp/napi/rdb_store_level_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..df5c7dcd58b2ae171d64e9b2a0d08da5ec84e978 --- /dev/null +++ b/distributeddatamgr/relationalStoretest/rdbnapitest/entry/src/main/cpp/napi/rdb_store_level_test.cpp @@ -0,0 +1,313 @@ +/* + * 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 +#include +#include +#include +#include +#include +#include + +#include "napi/native_api.h" +#include "common/common.h" +#include "relational_store.h" +#include "relational_store_error_code.h" +#include "oh_cursor.h" +#include "oh_predicates.h" +#include "oh_value_object.h" +#include "oh_values_bucket.h" + + +char RDB_TEST_PATH[] = "/data/storage/el2/database/"; +char RDB_STORE_NAME[] = "rdb_store_test.db"; +char BUNDLE_NAME[] = "com.acts.rdb.napitest"; +char MODULE_NAME[] = "com.acts.rdb.napitest"; +OH_Rdb_Store *storeLevelTestRdbStore_ = NULL; +static OH_Rdb_Config config1_; +static OH_Rdb_Config config2_; +static OH_Rdb_Config config3_; +static OH_Rdb_Config config4_; +static void InitRdbConfig1() +{ + config1_.dataBaseDir = RDB_TEST_PATH; + config1_.storeName = RDB_STORE_NAME; + config1_.bundleName = BUNDLE_NAME; + config1_.moduleName = MODULE_NAME; + config1_.securityLevel = OH_Rdb_SecurityLevel::S1; + config1_.isEncrypt = false; + config1_.selfSize = sizeof(OH_Rdb_Config); +} + +static void InitRdbConfig2() +{ + config2_.dataBaseDir = RDB_TEST_PATH; + config2_.storeName = RDB_STORE_NAME; + config2_.bundleName = BUNDLE_NAME; + config2_.moduleName = MODULE_NAME; + config2_.securityLevel = OH_Rdb_SecurityLevel::S2; + config2_.isEncrypt = false; + config2_.selfSize = sizeof(OH_Rdb_Config); +} + +static void InitRdbConfig3() +{ + config3_.dataBaseDir = RDB_TEST_PATH; + config3_.storeName = RDB_STORE_NAME; + config3_.bundleName = BUNDLE_NAME; + config3_.moduleName = MODULE_NAME; + config3_.securityLevel = OH_Rdb_SecurityLevel::S3; + config3_.isEncrypt = false; + config3_.selfSize = sizeof(OH_Rdb_Config); +} + +static void InitRdbConfig4() +{ + config4_.dataBaseDir = RDB_TEST_PATH; + config4_.storeName = RDB_STORE_NAME; + config4_.bundleName = BUNDLE_NAME; + config4_.moduleName = MODULE_NAME; + config4_.securityLevel = OH_Rdb_SecurityLevel::S4; + config4_.isEncrypt = false; + config4_.selfSize = sizeof(OH_Rdb_Config); +} + + + +static napi_value SUB_DDM_RDB_LEVEL_0100(napi_env env, napi_callback_info info) { + InitRdbConfig1(); + mkdir(config1_.dataBaseDir, 0770); + int errCode = 0; + storeLevelTestRdbStore_ = OH_Rdb_GetOrOpen(&config1_, &errCode); + NAPI_ASSERT(env, errCode == 0, "getRdbStore is fail."); + + char createTableSql[] = "CREATE TABLE test (id INTEGER PRIMARY KEY AUTOINCREMENT, data1 TEXT, data2 INTEGER, " + "data3 FLOAT, data4 BLOB, data5 TEXT);"; + + errCode = OH_Rdb_Execute(storeLevelTestRdbStore_, createTableSql); + NAPI_ASSERT(env, errCode == 0, "createTable is fail."); + + OH_VBucket* valueBucket = OH_Rdb_CreateValuesBucket(); + valueBucket->putInt64(valueBucket, "id", 1); + valueBucket->putText(valueBucket, "data1", "zhangSan"); + valueBucket->putInt64(valueBucket, "data2", 12800); + valueBucket->putReal(valueBucket, "data3", 100.1); + uint8_t arr[] = {1, 2, 3, 4, 5}; + int len = sizeof(arr) / sizeof(arr[0]); + valueBucket->putBlob(valueBucket, "data4", arr, len); + valueBucket->putText(valueBucket, "data5", "ABCDEFG"); + + errCode = OH_Rdb_Insert(storeLevelTestRdbStore_, "test", valueBucket); + NAPI_ASSERT(env, errCode == 1, "OH_Rdb_Insert is fail."); + + char querySql[] = "SELECT * FROM test"; + OH_Cursor *cursor = OH_Rdb_ExecuteQuery(storeLevelTestRdbStore_, querySql); + + int rowCount = 0; + cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 1, "getRowCount is fail."); + + valueBucket->destroy(valueBucket); + cursor->destroy(cursor); + + char dropTableSql[] = "DROP TABLE IF EXISTS test"; + errCode = OH_Rdb_Execute(storeLevelTestRdbStore_, dropTableSql); + NAPI_ASSERT(env, errCode == 0, "OH_Rdb_Execute is fail."); + errCode = OH_Rdb_CloseStore(storeLevelTestRdbStore_); + NAPI_ASSERT(env, errCode == 0, "OH_Rdb_CloseStore is fail."); + errCode = OH_Rdb_DeleteStore(&config1_); + NAPI_ASSERT(env, errCode == 0, "OH_Rdb_DeleteStore is fail."); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} + +static napi_value SUB_DDM_RDB_LEVEL_0200(napi_env env, napi_callback_info info) { + InitRdbConfig2(); + mkdir(config2_.dataBaseDir, 0770); + int errCode = 0; + storeLevelTestRdbStore_ = OH_Rdb_GetOrOpen(&config2_, &errCode); + NAPI_ASSERT(env, errCode == 0, "getRdbStore is fail."); + + char createTableSql[] = "CREATE TABLE test (id INTEGER PRIMARY KEY AUTOINCREMENT, data1 TEXT, data2 INTEGER, " + "data3 FLOAT, data4 BLOB, data5 TEXT);"; + + errCode = OH_Rdb_Execute(storeLevelTestRdbStore_, createTableSql); + NAPI_ASSERT(env, errCode == 0, "createTable is fail."); + + OH_VBucket* valueBucket = OH_Rdb_CreateValuesBucket(); + valueBucket->putInt64(valueBucket, "id", 1); + valueBucket->putText(valueBucket, "data1", "zhangSan"); + valueBucket->putInt64(valueBucket, "data2", 12800); + valueBucket->putReal(valueBucket, "data3", 100.1); + uint8_t arr[] = {1, 2, 3, 4, 5}; + int len = sizeof(arr) / sizeof(arr[0]); + valueBucket->putBlob(valueBucket, "data4", arr, len); + valueBucket->putText(valueBucket, "data5", "ABCDEFG"); + + errCode = OH_Rdb_Insert(storeLevelTestRdbStore_, "test", valueBucket); + NAPI_ASSERT(env, errCode == 1, "OH_Rdb_Insert is fail."); + + char querySql[] = "SELECT * FROM test"; + OH_Cursor *cursor = OH_Rdb_ExecuteQuery(storeLevelTestRdbStore_, querySql); + + int rowCount = 0; + cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 1, "getRowCount is fail."); + + valueBucket->destroy(valueBucket); + cursor->destroy(cursor); + + char dropTableSql[] = "DROP TABLE IF EXISTS test"; + errCode = OH_Rdb_Execute(storeLevelTestRdbStore_, dropTableSql); + NAPI_ASSERT(env, errCode == 0, "OH_Rdb_Execute is fail."); + errCode = OH_Rdb_CloseStore(storeLevelTestRdbStore_); + NAPI_ASSERT(env, errCode == 0, "OH_Rdb_CloseStore is fail."); + errCode = OH_Rdb_DeleteStore(&config2_); + NAPI_ASSERT(env, errCode == 0, "OH_Rdb_DeleteStore is fail."); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} + +static napi_value SUB_DDM_RDB_LEVEL_0300(napi_env env, napi_callback_info info) { + InitRdbConfig3(); + mkdir(config3_.dataBaseDir, 0770); + int errCode = 0; + storeLevelTestRdbStore_ = OH_Rdb_GetOrOpen(&config3_, &errCode); + NAPI_ASSERT(env, errCode == 0, "getRdbStore is fail."); + + char createTableSql[] = "CREATE TABLE test (id INTEGER PRIMARY KEY AUTOINCREMENT, data1 TEXT, data2 INTEGER, " + "data3 FLOAT, data4 BLOB, data5 TEXT);"; + + errCode = OH_Rdb_Execute(storeLevelTestRdbStore_, createTableSql); + NAPI_ASSERT(env, errCode == 0, "createTable is fail."); + + OH_VBucket* valueBucket = OH_Rdb_CreateValuesBucket(); + valueBucket->putInt64(valueBucket, "id", 1); + valueBucket->putText(valueBucket, "data1", "zhangSan"); + valueBucket->putInt64(valueBucket, "data2", 12800); + valueBucket->putReal(valueBucket, "data3", 100.1); + uint8_t arr[] = {1, 2, 3, 4, 5}; + int len = sizeof(arr) / sizeof(arr[0]); + valueBucket->putBlob(valueBucket, "data4", arr, len); + valueBucket->putText(valueBucket, "data5", "ABCDEFG"); + + errCode = OH_Rdb_Insert(storeLevelTestRdbStore_, "test", valueBucket); + NAPI_ASSERT(env, errCode == 1, "OH_Rdb_Insert is fail."); + + char querySql[] = "SELECT * FROM test"; + OH_Cursor *cursor = OH_Rdb_ExecuteQuery(storeLevelTestRdbStore_, querySql); + + int rowCount = 0; + cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 1, "getRowCount is fail."); + + valueBucket->destroy(valueBucket); + cursor->destroy(cursor); + + char dropTableSql[] = "DROP TABLE IF EXISTS test"; + errCode = OH_Rdb_Execute(storeLevelTestRdbStore_, dropTableSql); + NAPI_ASSERT(env, errCode == 0, "OH_Rdb_Execute is fail."); + errCode = OH_Rdb_CloseStore(storeLevelTestRdbStore_); + NAPI_ASSERT(env, errCode == 0, "OH_Rdb_CloseStore is fail."); + errCode = OH_Rdb_DeleteStore(&config3_); + NAPI_ASSERT(env, errCode == 0, "OH_Rdb_DeleteStore is fail."); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} + +static napi_value SUB_DDM_RDB_LEVEL_0400(napi_env env, napi_callback_info info) { + InitRdbConfig4(); + mkdir(config4_.dataBaseDir, 0770); + int errCode = 0; + storeLevelTestRdbStore_ = OH_Rdb_GetOrOpen(&config4_, &errCode); + NAPI_ASSERT(env, errCode == 0, "getRdbStore is fail."); + + char createTableSql[] = "CREATE TABLE test (id INTEGER PRIMARY KEY AUTOINCREMENT, data1 TEXT, data2 INTEGER, " + "data3 FLOAT, data4 BLOB, data5 TEXT);"; + + errCode = OH_Rdb_Execute(storeLevelTestRdbStore_, createTableSql); + NAPI_ASSERT(env, errCode == 0, "createTable is fail."); + + OH_VBucket* valueBucket = OH_Rdb_CreateValuesBucket(); + valueBucket->putInt64(valueBucket, "id", 1); + valueBucket->putText(valueBucket, "data1", "zhangSan"); + valueBucket->putInt64(valueBucket, "data2", 12800); + valueBucket->putReal(valueBucket, "data3", 100.1); + uint8_t arr[] = {1, 2, 3, 4, 5}; + int len = sizeof(arr) / sizeof(arr[0]); + valueBucket->putBlob(valueBucket, "data4", arr, len); + valueBucket->putText(valueBucket, "data5", "ABCDEFG"); + + errCode = OH_Rdb_Insert(storeLevelTestRdbStore_, "test", valueBucket); + NAPI_ASSERT(env, errCode == 1, "OH_Rdb_Insert is fail."); + + char querySql[] = "SELECT * FROM test"; + OH_Cursor *cursor = OH_Rdb_ExecuteQuery(storeLevelTestRdbStore_, querySql); + + int rowCount = 0; + cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 1, "getRowCount is fail."); + + valueBucket->destroy(valueBucket); + cursor->destroy(cursor); + + char dropTableSql[] = "DROP TABLE IF EXISTS test"; + errCode = OH_Rdb_Execute(storeLevelTestRdbStore_, dropTableSql); + NAPI_ASSERT(env, errCode == 0, "OH_Rdb_Execute is fail."); + errCode = OH_Rdb_CloseStore(storeLevelTestRdbStore_); + NAPI_ASSERT(env, errCode == 0, "OH_Rdb_CloseStore is fail."); + errCode = OH_Rdb_DeleteStore(&config4_); + NAPI_ASSERT(env, errCode == 0, "OH_Rdb_DeleteStore is fail."); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} + + +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) { + napi_property_descriptor desc[] = { + {"SUB_DDM_RDB_LEVEL_0100", nullptr, SUB_DDM_RDB_LEVEL_0100, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_LEVEL_0200", nullptr, SUB_DDM_RDB_LEVEL_0200, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_LEVEL_0300", nullptr, SUB_DDM_RDB_LEVEL_0300, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_LEVEL_0400", nullptr, SUB_DDM_RDB_LEVEL_0400, nullptr, nullptr, nullptr, napi_default, nullptr}}; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "level", + .nm_priv = ((void *)0), + .reserved = {0}, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { + napi_module_register(&demoModule); +} diff --git a/distributeddatamgr/relationalStoretest/rdbnapitest/entry/src/main/cpp/napi/rdb_store_predicates_test.cpp b/distributeddatamgr/relationalStoretest/rdbnapitest/entry/src/main/cpp/napi/rdb_store_predicates_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..2726a833ab04451c4b24f850c2d631a6cc4300f1 --- /dev/null +++ b/distributeddatamgr/relationalStoretest/rdbnapitest/entry/src/main/cpp/napi/rdb_store_predicates_test.cpp @@ -0,0 +1,2145 @@ +/* + * 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 +#include +#include +#include +#include +#include +#include + +#include "napi/native_api.h" +#include "common/common.h" +#include "relational_store.h" +#include "relational_store_error_code.h" +#include "oh_cursor.h" +#include "oh_predicates.h" +#include "oh_value_object.h" +#include "oh_values_bucket.h" + +OH_Rdb_Store *predicatesTestRdbStore_ = NULL; + +char RDB_TEST_PATH[] = "/data/storage/el2/database/"; +char RDB_STORE_NAME[] = "rdb_store_predicates_test.db"; +char BUNDLE_NAME[] = "com.acts.rdb.napitest"; +char MODULE_NAME[] = "com.acts.rdb.napitest"; + +static OH_Rdb_Config config_; +static void InitRdbConfig() +{ + config_.dataBaseDir = RDB_TEST_PATH; + config_.storeName = RDB_STORE_NAME; + config_.bundleName = BUNDLE_NAME; + config_.moduleName = MODULE_NAME; + config_.securityLevel = OH_Rdb_SecurityLevel::S1; + config_.isEncrypt = false; + config_.selfSize = sizeof(OH_Rdb_Config); +} + + +static napi_value PredicatesSetUpTestCase(napi_env env, napi_callback_info info) { + InitRdbConfig(); + mkdir(config_.dataBaseDir, 0770); + + int errCode = 0; + char table[] = "test"; + predicatesTestRdbStore_ = OH_Rdb_GetOrOpen(&config_, &errCode); + NAPI_ASSERT(env, predicatesTestRdbStore_ != NULL, "OH_Rdb_GetOrOpen is fail."); + + char createTableSql[] = "CREATE TABLE test (id INTEGER PRIMARY KEY AUTOINCREMENT, data1 TEXT, data2 INTEGER, " + "data3 FLOAT, data4 BLOB, data5 TEXT);"; + errCode = OH_Rdb_Execute(predicatesTestRdbStore_, createTableSql); + + OH_VBucket *valueBucket = OH_Rdb_CreateValuesBucket(); + valueBucket->putInt64(valueBucket, "id", 1); + valueBucket->putText(valueBucket, "data1", "zhangSan"); + valueBucket->putInt64(valueBucket, "data2", 12800); + valueBucket->putReal(valueBucket, "data3", 100.1); + uint8_t arr[] = {1, 2, 3, 4, 5}; + int len = sizeof(arr) / sizeof(arr[0]); + valueBucket->putBlob(valueBucket, "data4", arr, len); + valueBucket->putText(valueBucket, "data5", "ABCDEFG"); + errCode = OH_Rdb_Insert(predicatesTestRdbStore_, table, valueBucket); + NAPI_ASSERT(env, errCode == 1, "OH_Rdb_Insert 1 is fail."); + + valueBucket->clear(valueBucket); + valueBucket->putInt64(valueBucket, "id", 2); + valueBucket->putText(valueBucket, "data1", "liSi"); + valueBucket->putInt64(valueBucket, "data2", 13800); + valueBucket->putReal(valueBucket, "data3", 200.1); + valueBucket->putText(valueBucket, "data5", "ABCDEFGH"); + errCode = OH_Rdb_Insert(predicatesTestRdbStore_, table, valueBucket); + NAPI_ASSERT(env, errCode == 2, "OH_Rdb_Insert 2 is fail."); + + valueBucket->clear(valueBucket); + valueBucket->putInt64(valueBucket, "id", 3); + valueBucket->putText(valueBucket, "data1", "wangWu"); + valueBucket->putInt64(valueBucket, "data2", 14800); + valueBucket->putReal(valueBucket, "data3", 300.1); + valueBucket->putText(valueBucket, "data5", "ABCDEFGHI"); + errCode = OH_Rdb_Insert(predicatesTestRdbStore_, table, valueBucket); + NAPI_ASSERT(env, errCode == 3, "OH_Rdb_Insert 3 is fail."); + + valueBucket->clear(valueBucket); + valueBucket->putInt64(valueBucket, "id", 4); + valueBucket->putText(valueBucket, "data1", "zhangliu"); + valueBucket->putInt64(valueBucket, "data2", 14800); + valueBucket->putReal(valueBucket, "data3", 300.1); + valueBucket->putText(valueBucket, "data5", "ABCDEFGHI"); + errCode = OH_Rdb_Insert(predicatesTestRdbStore_, table, valueBucket); + NAPI_ASSERT(env, errCode == 4, "OH_Rdb_Insert 4 is fail."); + + errCode = 0; + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; + +} + +static napi_value PredicatesTearDownTestCase(napi_env env, napi_callback_info info) { + int errCode = 0; + char dropTableSql[] = "DROP TABLE IF EXISTS test"; + errCode = OH_Rdb_Execute(predicatesTestRdbStore_, dropTableSql); + NAPI_ASSERT(env, errCode == 0, "OH_Rdb_Execute is fail."); + errCode = OH_Rdb_CloseStore(predicatesTestRdbStore_); + NAPI_ASSERT(env, errCode == 0, "OH_Rdb_CloseStore is fail."); + errCode = OH_Rdb_DeleteStore(&config_); + NAPI_ASSERT(env, errCode == 0, "OH_Rdb_DeleteStore is fail."); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; + +} + + +/** + * @tc.name: SUB_DDM_RDB_Predicates_0100 + * @tc.desc: napi test RDB Predicates for EqualTo、AndOR、beginWrap and endWrap + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_Predicates_0100(napi_env env, napi_callback_info info) { + int errCode = 0; + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + OH_VObject *valueObject = OH_Rdb_CreateValueObject(); + uint32_t count = 1; + const char *data1Value = "zhangSan"; + valueObject->putText(valueObject, data1Value); + predicates->beginWrap(predicates); + predicates->equalTo(predicates, "data1", valueObject); + predicates->orOperate(predicates); + double data3Value = 200.1; + valueObject->putDouble(valueObject, &data3Value, count); + predicates->equalTo(predicates, "data3", valueObject); + predicates->endWrap(predicates); + + OH_Cursor *cursor = OH_Rdb_Query(predicatesTestRdbStore_, predicates, NULL, 0); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query is fail."); + + int rowCount = 0; + errCode = cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 2, "getRowCount is fail."); + + predicates->destroy(predicates); + valueObject->destroy(valueObject); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} + +/** + * @tc.name: SUB_DDM_RDB_Predicates_0200 + * @tc.desc: napi test RDB Predicates for NotEqualTo + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_Predicates_0200(napi_env env, napi_callback_info info) { + int errCode = 0; + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + OH_VObject *valueObject = OH_Rdb_CreateValueObject(); + const char *data1Value = "zhangSan"; + valueObject->putText(valueObject, data1Value); + predicates->notEqualTo(predicates, "data1", valueObject); + NAPI_ASSERT(env, errCode == 0, "notEqualTo is fail."); + + OH_Cursor *cursor = OH_Rdb_Query(predicatesTestRdbStore_, predicates, NULL, 0); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query is fail."); + int rowCount = 0; + errCode = cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 3, "getRowCount is fail."); + + valueObject->destroy(valueObject); + predicates->destroy(predicates); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} + + +/** + * @tc.name: SUB_DDM_RDB_Predicates_0300 + * @tc.desc: napi test RDB Predicates for GreaterThan + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_Predicates_0300(napi_env env, napi_callback_info info) { + int errCode = 0; + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + OH_VObject *valueObject = OH_Rdb_CreateValueObject(); + const char *data5Value = "ABCDEFG"; + valueObject->putText(valueObject, data5Value); + predicates->greaterThan(predicates, "data5", valueObject); + + OH_Cursor *cursor = OH_Rdb_Query(predicatesTestRdbStore_, predicates, NULL, 0); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query is fail."); + int rowCount = 0; + errCode = cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 3, "getRowCount is fail."); + + valueObject->destroy(valueObject); + predicates->destroy(predicates); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} +/** + * @tc.name: SUB_DDM_RDB_Predicates_0400 + * @tc.desc: napi test RDB Predicates for GreaterThanOrEqualTo + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_Predicates_0400(napi_env env, napi_callback_info info) { + int errCode = 0; + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + OH_VObject *valueObject = OH_Rdb_CreateValueObject(); + const char *data5Value = "ABCDEFG"; + valueObject->putText(valueObject, data5Value); + predicates->greaterThanOrEqualTo(predicates, "data5", valueObject); + + OH_Cursor *cursor = OH_Rdb_Query(predicatesTestRdbStore_, predicates, NULL, 0); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query is fail."); + int rowCount = 0; + errCode = cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 4, "getRowCount is fail."); + + valueObject->destroy(valueObject); + predicates->destroy(predicates); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} + + + +/** + * @tc.name: SUB_DDM_RDB_Predicates_0500 + * @tc.desc: napi test RDB Predicates for LessThan + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_Predicates_0500(napi_env env, napi_callback_info info) { + int errCode = 0; + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + OH_VObject *valueObject = OH_Rdb_CreateValueObject(); + const char *data5Value = "ABCDEFG"; + valueObject->putText(valueObject, data5Value); + predicates->lessThan(predicates, "data5", valueObject); + + OH_Cursor *cursor = OH_Rdb_Query(predicatesTestRdbStore_, predicates, NULL, 0); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query is fail."); + int rowCount = 0; + errCode = cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 0, "getRowCount is fail."); + + valueObject->destroy(valueObject); + predicates->destroy(predicates); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} +/** + * @tc.name: SUB_DDM_RDB_Predicates_0600 + * @tc.desc: napi test RDB Predicates for LessThanOrEqualTo + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_Predicates_0600(napi_env env, napi_callback_info info) { + int errCode = 0; + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + OH_VObject *valueObject = OH_Rdb_CreateValueObject(); + const char *data5Value = "ABCDEFG"; + valueObject->putText(valueObject, data5Value); + predicates->lessThanOrEqualTo(predicates, "data5", valueObject); + + OH_Cursor *cursor = OH_Rdb_Query(predicatesTestRdbStore_, predicates, NULL, 0); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query is fail."); + int rowCount = 0; + errCode = cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 1, "getRowCount is fail."); + + valueObject->destroy(valueObject); + predicates->destroy(predicates); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} +/** + * @tc.name: SUB_DDM_RDB_Predicates_0700 + * @tc.desc: napi test RDB Predicates for IsNull + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_Predicates_0700(napi_env env, napi_callback_info info) { + int errCode = 0; + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + predicates->isNull(predicates, "data4"); + + OH_Cursor *cursor = OH_Rdb_Query(predicatesTestRdbStore_, predicates, NULL, 0); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query is fail."); + int rowCount = 0; + errCode = cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 3, "getRowCount is fail."); + + predicates->destroy(predicates); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} +/** + * @tc.name: SUB_DDM_RDB_Predicates_0800 + * @tc.desc: napi test RDB Predicates for isNotNull + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_Predicates_0800(napi_env env, napi_callback_info info) { + int errCode = 0; + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + predicates->isNotNull(predicates, "data4"); + + OH_Cursor *cursor = OH_Rdb_Query(predicatesTestRdbStore_, predicates, NULL, 0); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query is fail."); + int rowCount = 0; + errCode = cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 1, "getRowCount is fail."); + + predicates->destroy(predicates); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} + +/** + * @tc.name: SUB_DDM_RDB_Predicates_0900 + * @tc.desc: napi test RDB Predicates for Between + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_Predicates_0900(napi_env env, napi_callback_info info) { + int errCode = 0; + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + OH_VObject *valueObject = OH_Rdb_CreateValueObject(); + int64_t data2Value[] = {12000, 13000}; + uint32_t len = sizeof(data2Value) / sizeof(data2Value[0]); + valueObject->putInt64(valueObject, data2Value, len); + predicates->between(predicates, "data2", valueObject); + double data3Value[] = {0.1, 101.1}; + len = sizeof(data3Value) / sizeof(data3Value[0]); + valueObject->putDouble(valueObject, data3Value, len); + predicates->between(predicates, "data3", valueObject); + + OH_Cursor *cursor = OH_Rdb_Query(predicatesTestRdbStore_, predicates, NULL, 0); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query is fail."); + int rowCount = 0; + errCode = cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 1, "getRowCount is fail."); + + valueObject->destroy(valueObject); + predicates->destroy(predicates); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} + +/** + * @tc.name: SUB_DDM_RDB_Predicates_1000 + * @tc.desc: napi test RDB Predicates for NotBetween + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_Predicates_1000(napi_env env, napi_callback_info info) { + int errCode = 0; + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + OH_VObject *valueObject = OH_Rdb_CreateValueObject(); + int64_t data2Value[] = {12000, 13000}; + int len = sizeof(data2Value) / sizeof(data2Value[0]); + valueObject->putInt64(valueObject, data2Value, len); + predicates->notBetween(predicates, "data2", valueObject); + + OH_Cursor *cursor = OH_Rdb_Query(predicatesTestRdbStore_, predicates, NULL, 0); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query is fail."); + int rowCount = 0; + errCode = cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 3, "getRowCount is fail."); + + valueObject->destroy(valueObject); + predicates->destroy(predicates); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} + + +/** + * @tc.name: SUB_DDM_RDB_Predicates_1100 + * @tc.desc: napi test RDB Predicates for OrderBy、Limit、Offset. + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_Predicates_1100(napi_env env, napi_callback_info info) { + int errCode = 0; + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + predicates->orderBy(predicates, "data2", OH_OrderType::ASC); + predicates->limit(predicates, 1); + predicates->offset(predicates, 0); + predicates->distinct(predicates); + + OH_Cursor *cursor = OH_Rdb_Query(predicatesTestRdbStore_, predicates, NULL, 0); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query is fail."); + int rowCount = 0; + errCode = cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 1, "getRowCount is fail."); + + errCode = cursor->goToNextRow(cursor); + int columnIndex; + cursor->getColumnIndex(cursor, "data2", &columnIndex); + NAPI_ASSERT(env, columnIndex == 2, "getColumnIndex is fail."); + + int64_t longValue; + cursor->getInt64(cursor, columnIndex, &longValue); + NAPI_ASSERT(env, longValue == 12800, "getInt64 is fail."); + + + predicates->destroy(predicates); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} + +/** + * @tc.name: SUB_DDM_RDB_Predicates_1200 + * @tc.desc: napi test RDB Predicates for In. + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_Predicates_1200(napi_env env, napi_callback_info info) { + int errCode = 0; + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + OH_VObject *valueObject = OH_Rdb_CreateValueObject(); + const char *data1Value[] = {"zhangSan", "liSi"}; + int len = sizeof(data1Value) / sizeof(data1Value[0]); + valueObject->putTexts(valueObject, data1Value, len); + predicates->in(predicates, "data1", valueObject); + + OH_Cursor *cursor = OH_Rdb_Query(predicatesTestRdbStore_, predicates, NULL, 0); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query is fail."); + int rowCount = 0; + errCode = cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 2, "getRowCount is fail."); + + valueObject->destroy(valueObject); + predicates->destroy(predicates); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} + +/** + * @tc.name: SUB_DDM_RDB_Predicates_1300 + * @tc.desc: napi test RDB Predicates for NotIn + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_Predicates_1300(napi_env env, napi_callback_info info) { + int errCode = 0; + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + OH_VObject *valueObject = OH_Rdb_CreateValueObject(); + const char *data1Value[] = {"zhangSan", "liSi"}; + int len = sizeof(data1Value) / sizeof(data1Value[0]); + valueObject->putTexts(valueObject, data1Value, len); + predicates->notIn(predicates, "data1", valueObject); + + OH_Cursor *cursor = OH_Rdb_Query(predicatesTestRdbStore_, predicates, NULL, 0); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query is fail."); + int rowCount = 0; + errCode = cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 2, "getRowCount is fail."); + + valueObject->destroy(valueObject); + predicates->destroy(predicates); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} + +/** + * @tc.name: SUB_DDM_RDB_Predicates_1400 + * @tc.desc: napi test RDB Predicates for Like + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_Predicates_1400(napi_env env, napi_callback_info info) { + int errCode = 0; + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + OH_VObject *valueObject = OH_Rdb_CreateValueObject(); + const char *data5Value = "ABCD%"; + valueObject->putText(valueObject, data5Value); + predicates->like(predicates, "data5", valueObject); + const char *data2Value = "%800"; + valueObject->putText(valueObject, data2Value); + predicates->like(predicates, "data2", valueObject); + + OH_Cursor *cursor = OH_Rdb_Query(predicatesTestRdbStore_, predicates, NULL, 0); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query is fail."); + int rowCount = 0; + errCode = cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 4, "getRowCount is fail."); + + valueObject->destroy(valueObject); + predicates->destroy(predicates); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} + +/** + * @tc.name: SUB_DDM_RDB_Predicates_1500 + * @tc.desc: napi test RDB Predicates for GroupBy + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_Predicates_1500(napi_env env, napi_callback_info info) { + int errCode = 0; + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + const char *columnNames[] = {"data1", "data2"}; + int len = sizeof(columnNames) / sizeof(columnNames[0]); + predicates->groupBy(predicates, columnNames, len); + + OH_Cursor *cursor = OH_Rdb_Query(predicatesTestRdbStore_, predicates, NULL, 0); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query is fail."); + int rowCount = 0; + errCode = cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 4, "getRowCount is fail."); + + predicates->destroy(predicates); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} +/** + * @tc.name: SUB_DDM_RDB_Predicates_1600 + * @tc.desc: napi test RDB Predicates for And + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_Predicates_1600(napi_env env, napi_callback_info info) { + int errCode = 0; + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + OH_VObject *valueObject = OH_Rdb_CreateValueObject(); + const char *data1Value = "zhangSan"; + valueObject->putText(valueObject, data1Value); + predicates->equalTo(predicates, "data1", valueObject); + predicates->andOperate(predicates); + double data3Value = 100.1; + valueObject->putDouble(valueObject, &data3Value, 1); + predicates->equalTo(predicates, "data3", valueObject); + + OH_Cursor *cursor = OH_Rdb_Query(predicatesTestRdbStore_, predicates, NULL, 0); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query is fail."); + int rowCount = 0; + errCode = cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 1, "getRowCount is fail."); + + valueObject->destroy(valueObject); + predicates->destroy(predicates); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} +/** + * @tc.name: SUB_DDM_RDB_Predicates_1700 + * @tc.desc: napi test RDB Predicates for Clear + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_Predicates_1700(napi_env env, napi_callback_info info) { + int errCode = 0; + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + OH_VObject *valueObject = OH_Rdb_CreateValueObject(); + const char *data1Value = "zhangSan"; + valueObject->putText(valueObject, data1Value); + predicates->equalTo(predicates, "data1", valueObject); + + OH_Cursor *cursor = OH_Rdb_Query(predicatesTestRdbStore_, predicates, NULL, 0); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query is fail."); + int rowCount = 0; + errCode = cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 1, "getRowCount is fail."); + errCode = cursor->destroy(cursor); + + predicates->clear(predicates); + predicates->notEqualTo(predicates, "data1", valueObject); + cursor = OH_Rdb_Query(predicatesTestRdbStore_, predicates, NULL, 0); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query is fail."); + errCode = cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 3, "getRowCount is fail."); + + valueObject->destroy(valueObject); + predicates->destroy(predicates); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} + +/** + * @tc.name: SUB_DDM_RDB_Predicates_1800 + * @tc.desc: napi test RDB Predicates for table name is NULL. + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_Predicates_1800(napi_env env, napi_callback_info info) { + char *table = NULL; + OH_Predicates *predicates = OH_Rdb_CreatePredicates(table); + NAPI_ASSERT(env, predicates == NULL, "OH_Rdb_CreatePredicates is fail."); + + OH_Cursor *cursor = OH_Rdb_Query(predicatesTestRdbStore_, predicates, NULL, 0); + NAPI_ASSERT(env, cursor == NULL, "OH_Rdb_Query is fail."); + + int errCode = 0; + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} + +/** + * @tc.name: SUB_DDM_RDB_Predicates_1900 + * @tc.desc: napi test RDB Predicates for equalTo + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_Predicates_1900(napi_env env, napi_callback_info info) { + int errCode = 0; + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + OH_VObject *valueObject = OH_Rdb_CreateValueObject(); + const char *data1Value = "zhangSan"; + valueObject->putText(valueObject, data1Value); + predicates->equalTo(predicates, "data1", valueObject); + + OH_Cursor *cursor = OH_Rdb_Query(predicatesTestRdbStore_, predicates, NULL, 0); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query is fail."); + + int rowCount = 0; + errCode = cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 1, "getRowCount is fail."); + + predicates->destroy(predicates); + valueObject->destroy(valueObject); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} + +/** + * @tc.name: SUB_DDM_RDB_Predicates_2000 + * @tc.desc: napi test RDB Predicates for equalTo + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_Predicates_2000(napi_env env, napi_callback_info info) { + int errCode = 0; + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + OH_VObject *valueObject = OH_Rdb_CreateValueObject(); + uint32_t count = 1; + double data3Value = 300.1; + valueObject->putDouble(valueObject, &data3Value, count); + predicates->equalTo(predicates, "data3", valueObject); + + OH_Cursor *cursor = OH_Rdb_Query(predicatesTestRdbStore_, predicates, NULL, 0); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query is fail."); + + int rowCount = 0; + errCode = cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 2, "getRowCount is fail."); + + predicates->destroy(predicates); + valueObject->destroy(valueObject); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} + + + +/** + * @tc.name: SUB_DDM_RDB_Predicates_2100 + * @tc.desc: napi test RDB Predicates for equalTo + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_Predicates_2100(napi_env env, napi_callback_info info) { + int errCode = 0; + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + OH_VObject *valueObject = OH_Rdb_CreateValueObject(); + uint32_t count = 1; + double data3Value = 300.1; + valueObject->putDouble(valueObject, &data3Value, count); + predicates->equalTo(predicates, "data", valueObject); + + OH_Cursor *cursor = OH_Rdb_Query(predicatesTestRdbStore_, predicates, NULL, 0); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query is fail."); + + int rowCount = -1; + errCode = cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == -1, "getRowCount is fail."); + + predicates->destroy(predicates); + valueObject->destroy(valueObject); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} + +/** + * @tc.name: SUB_DDM_RDB_Predicates_2200 + * @tc.desc: napi test RDB Predicates for equalTo + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_Predicates_2200(napi_env env, napi_callback_info info) { + int errCode = 0; + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + OH_VObject *valueObject = OH_Rdb_CreateValueObject(); + uint32_t count = 1; + double data3Value = 1.1; + valueObject->putDouble(valueObject, &data3Value, count); + predicates->equalTo(predicates, "data3", valueObject); + + OH_Cursor *cursor = OH_Rdb_Query(predicatesTestRdbStore_, predicates, NULL, 0); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query is fail."); + + int rowCount = -1; + errCode = cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 0, "getRowCount is fail."); + + predicates->destroy(predicates); + valueObject->destroy(valueObject); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} + +/** + * @tc.name: SUB_DDM_RDB_Predicates_2300 + * @tc.desc: napi test RDB Predicates for notEqualTo + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_Predicates_2300(napi_env env, napi_callback_info info) { + int errCode = 0; + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + OH_VObject *valueObject = OH_Rdb_CreateValueObject(); + uint32_t count = 1; + double data3Value = 300.1; + valueObject->putDouble(valueObject, &data3Value, count); + predicates->notEqualTo(predicates, "data3", valueObject); + + OH_Cursor *cursor = OH_Rdb_Query(predicatesTestRdbStore_, predicates, NULL, 0); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query is fail."); + + int rowCount = -1; + errCode = cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 2, "getRowCount is fail."); + + predicates->destroy(predicates); + valueObject->destroy(valueObject); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} + +/** + * @tc.name: SUB_DDM_RDB_Predicates_2400 + * @tc.desc: napi test RDB Predicates for notEqualTo + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_Predicates_2400(napi_env env, napi_callback_info info) { + int errCode = 0; + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + OH_VObject *valueObject = OH_Rdb_CreateValueObject(); + const char *data1Value = "wangWu"; + valueObject->putText(valueObject, data1Value); + predicates->notEqualTo(predicates, "data1", valueObject); + predicates->andOperate(predicates); + OH_VObject *valueObject1 = OH_Rdb_CreateValueObject(); + const char *data1Value1 = "zhangliu"; + valueObject1->putText(valueObject1, data1Value1); + predicates->notEqualTo(predicates, "data1", valueObject1); + + OH_Cursor *cursor = OH_Rdb_Query(predicatesTestRdbStore_, predicates, NULL, 0); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query is fail."); + + int rowCount = -1; + errCode = cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 2, "getRowCount is fail."); + + predicates->destroy(predicates); + valueObject->destroy(valueObject); + valueObject1->destroy(valueObject1); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} + +/** + * @tc.name: SUB_DDM_RDB_Predicates_2500 + * @tc.desc: napi test RDB Predicates for notEqualTo + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_Predicates_2500(napi_env env, napi_callback_info info) { + int errCode = 0; + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + OH_VObject *valueObject = OH_Rdb_CreateValueObject(); + const char *data1Value = "name"; + valueObject->putText(valueObject, data1Value); + predicates->notEqualTo(predicates, "data1", valueObject); + + OH_Cursor *cursor = OH_Rdb_Query(predicatesTestRdbStore_, predicates, NULL, 0); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query is fail."); + + int rowCount = -1; + errCode = cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 4, "getRowCount is fail."); + + predicates->destroy(predicates); + valueObject->destroy(valueObject); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} + +/** + * @tc.name: SUB_DDM_RDB_Predicates_2600 + * @tc.desc: napi test RDB Predicates for notEqualTo + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_Predicates_2600(napi_env env, napi_callback_info info) { + int errCode = 0; + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + OH_VObject *valueObject = OH_Rdb_CreateValueObject(); + uint32_t count = 1; + double data3Value = 300.1; + valueObject->putDouble(valueObject, &data3Value, count); + predicates->notEqualTo(predicates, "data", valueObject); + + OH_Cursor *cursor = OH_Rdb_Query(predicatesTestRdbStore_, predicates, NULL, 0); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query is fail."); + + int rowCount = -1; + errCode = cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == -1, "getRowCount is fail."); + + predicates->destroy(predicates); + valueObject->destroy(valueObject); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} + +/** + * @tc.name: SUB_DDM_RDB_Predicates_2700 + * @tc.desc: napi test RDB Predicates for beginWrap and endWrap + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_Predicates_2700(napi_env env, napi_callback_info info) { + int errCode = 0; + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + OH_VObject *valueObject = OH_Rdb_CreateValueObject(); + const char *data1Value = "zhangSan"; + valueObject->putText(valueObject, data1Value); + predicates->beginWrap(predicates); + predicates->equalTo(predicates, "data1", valueObject); + predicates->endWrap(predicates); + + OH_Cursor *cursor = OH_Rdb_Query(predicatesTestRdbStore_, predicates, NULL, 0); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query is fail."); + int rowCount = 0; + errCode = cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 1, "getRowCount is fail."); + + predicates->destroy(predicates); + valueObject->destroy(valueObject); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} + +/** + * @tc.name: SUB_DDM_RDB_Predicates_2800 + * @tc.desc: napi test RDB Predicates for beginWrap and endWrap + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_Predicates_2800(napi_env env, napi_callback_info info) { + int errCode = 0; + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + OH_VObject *valueObject = OH_Rdb_CreateValueObject(); + const char *data1Value = "zhangSan"; + valueObject->putText(valueObject, data1Value); + predicates->equalTo(predicates, "data1", valueObject); + predicates->endWrap(predicates); + + OH_Cursor *cursor = OH_Rdb_Query(predicatesTestRdbStore_, predicates, NULL, 0); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query is fail."); + int rowCount = -1; + errCode = cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == -1, "getRowCount is fail."); + + predicates->destroy(predicates); + valueObject->destroy(valueObject); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} + +/** + * @tc.name: SUB_DDM_RDB_Predicates_2900 + * @tc.desc: napi test RDB Predicates for beginWrap and endWrap + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_Predicates_2900(napi_env env, napi_callback_info info) { + int errCode = 0; + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + OH_VObject *valueObject = OH_Rdb_CreateValueObject(); + const char *data1Value = "zhangSan"; + valueObject->putText(valueObject, data1Value); + predicates->beginWrap(predicates); + predicates->equalTo(predicates, "data1", valueObject); + + OH_Cursor *cursor = OH_Rdb_Query(predicatesTestRdbStore_, predicates, NULL, 0); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query is fail."); + int rowCount = -1; + errCode = cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == -1, "getRowCount is fail."); + + predicates->destroy(predicates); + valueObject->destroy(valueObject); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} + +/** + * @tc.name: SUB_DDM_RDB_Predicates_3000 + * @tc.desc: napi test RDB Predicates for EqualTo、AndOR、beginWrap and endWrap + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_Predicates_3000(napi_env env, napi_callback_info info) { + int errCode = 0; + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + OH_VObject *valueObject = OH_Rdb_CreateValueObject(); + uint32_t count = 1; + const char *data1Value = "zhangSan"; + valueObject->putText(valueObject, data1Value); + predicates->beginWrap(predicates); + predicates->equalTo(predicates, "data1", valueObject); + predicates->andOperate(predicates); + double data3Value = 200.1; + valueObject->putDouble(valueObject, &data3Value, count); + predicates->equalTo(predicates, "data3", valueObject); + predicates->endWrap(predicates); + + OH_Cursor *cursor = OH_Rdb_Query(predicatesTestRdbStore_, predicates, NULL, 0); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query is fail."); + int rowCount = -1; + errCode = cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 0, "getRowCount is fail."); + + predicates->destroy(predicates); + valueObject->destroy(valueObject); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} + +/** + * @tc.name: SUB_DDM_RDB_Predicates_3100 + * @tc.desc: napi test RDB Predicates for + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_Predicates_3100(napi_env env, napi_callback_info info) { + int errCode = 0; + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + OH_VObject *valueObject = OH_Rdb_CreateValueObject(); + const char *data1Value = "zhangSan"; + valueObject->putText(valueObject, data1Value); + predicates->equalTo(predicates, "data1", valueObject); + predicates->andOperate(predicates); + predicates->orOperate(predicates); + double data3Value = 200.1; + valueObject->putDouble(valueObject, &data3Value, 1); + predicates->equalTo(predicates, "data3", valueObject); + + OH_Cursor *cursor = OH_Rdb_Query(predicatesTestRdbStore_, predicates, NULL, 0); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query is fail."); + int rowCount = -1; + errCode = cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 2, "getRowCount is fail."); + + predicates->destroy(predicates); + valueObject->destroy(valueObject); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} +/** + * @tc.name: SUB_DDM_RDB_Predicates_3200 + * @tc.desc: napi test RDB Predicates for And + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_Predicates_3200(napi_env env, napi_callback_info info) { + int errCode = 0; + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + OH_VObject *valueObject = OH_Rdb_CreateValueObject(); + const char *data1Value = "zhangSan"; + valueObject->putText(valueObject, data1Value); + predicates->equalTo(predicates, "data1", valueObject); + predicates->orOperate(predicates); + predicates->orOperate(predicates); + double data3Value = 200.1; + valueObject->putDouble(valueObject, &data3Value, 1); + predicates->equalTo(predicates, "data3", valueObject); + + OH_Cursor *cursor = OH_Rdb_Query(predicatesTestRdbStore_, predicates, NULL, 0); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query is fail."); + int rowCount = -1; + errCode = cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 2, "getRowCount is fail."); + + predicates->destroy(predicates); + valueObject->destroy(valueObject); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} + +/** + * @tc.name: SUB_DDM_RDB_Predicates_3300 + * @tc.desc: napi test RDB Predicates for IsNull + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_Predicates_3300(napi_env env, napi_callback_info info) { + int errCode = 0; + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + predicates->isNull(predicates, "data"); + + OH_Cursor *cursor = OH_Rdb_Query(predicatesTestRdbStore_, predicates, NULL, 0); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query is fail."); + int rowCount = -1; + errCode = cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == -1, "getRowCount is fail."); + + predicates->destroy(predicates); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} +/** + * @tc.name: SUB_DDM_RDB_Predicates_3400 + * @tc.desc: napi test RDB Predicates for isNotNull + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_Predicates_3400(napi_env env, napi_callback_info info) { + int errCode = 0; + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + predicates->isNotNull(predicates, "data"); + + OH_Cursor *cursor = OH_Rdb_Query(predicatesTestRdbStore_, predicates, NULL, 0); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query is fail."); + int rowCount = -1; + errCode = cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == -1, "getRowCount is fail."); + + predicates->destroy(predicates); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} +/** + * @tc.name: SUB_DDM_RDB_Predicates_3500 + * @tc.desc: napi test RDB Predicates for Like + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_Predicates_3500(napi_env env, napi_callback_info info) { + int errCode = 0; + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + OH_VObject *valueObject = OH_Rdb_CreateValueObject(); + const char *data5Value = "%BCD%"; + valueObject->putText(valueObject, data5Value); + predicates->like(predicates, "data5", valueObject); + + OH_Cursor *cursor = OH_Rdb_Query(predicatesTestRdbStore_, predicates, NULL, 0); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query is fail."); + int rowCount = 0; + errCode = cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 4, "getRowCount is fail."); + + valueObject->destroy(valueObject); + predicates->destroy(predicates); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} +/** + * @tc.name: SUB_DDM_RDB_Predicates_3600 + * @tc.desc: napi test RDB Predicates for Like + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_Predicates_3600(napi_env env, napi_callback_info info) { + int errCode = 0; + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + OH_VObject *valueObject = OH_Rdb_CreateValueObject(); + const char *data5Value = "%BCDx%"; + valueObject->putText(valueObject, data5Value); + predicates->like(predicates, "data5", valueObject); + + OH_Cursor *cursor = OH_Rdb_Query(predicatesTestRdbStore_, predicates, NULL, 0); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query is fail."); + int rowCount = -1; + errCode = cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 0, "getRowCount is fail."); + + valueObject->destroy(valueObject); + predicates->destroy(predicates); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} +/** + * @tc.name: SUB_DDM_RDB_Predicates_3700 + * @tc.desc: napi test RDB Predicates for Like + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_Predicates_3700(napi_env env, napi_callback_info info) { + int errCode = 0; + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + OH_VObject *valueObject = OH_Rdb_CreateValueObject(); + const char *data5Value = "ABCD%"; + valueObject->putText(valueObject, data5Value); + predicates->like(predicates, "data", valueObject); + + OH_Cursor *cursor = OH_Rdb_Query(predicatesTestRdbStore_, predicates, NULL, 0); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query is fail."); + int rowCount = 0; + errCode = cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == -1, "getRowCount is fail."); + + valueObject->destroy(valueObject); + predicates->destroy(predicates); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} +/** + * @tc.name: SUB_DDM_RDB_Predicates_3800 + * @tc.desc: napi test RDB Predicates for Between + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_Predicates_3800(napi_env env, napi_callback_info info) { + int errCode = 0; + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + OH_VObject *valueObject = OH_Rdb_CreateValueObject(); + int64_t data2Value[] = {12000, 12000}; + uint32_t len = sizeof(data2Value) / sizeof(data2Value[0]); + valueObject->putInt64(valueObject, data2Value, len); + predicates->between(predicates, "data2", valueObject); + + OH_Cursor *cursor = OH_Rdb_Query(predicatesTestRdbStore_, predicates, NULL, 0); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query is fail."); + int rowCount = -1; + errCode = cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 0, "getRowCount is fail."); + + valueObject->destroy(valueObject); + predicates->destroy(predicates); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} +/** + * @tc.name: SUB_DDM_RDB_Predicates_3900 + * @tc.desc: napi test RDB Predicates for Between + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_Predicates_3900(napi_env env, napi_callback_info info) { + int errCode = 0; + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + OH_VObject *valueObject = OH_Rdb_CreateValueObject(); + int64_t data2Value[] = {13000, 12000}; + uint32_t len = sizeof(data2Value) / sizeof(data2Value[0]); + valueObject->putInt64(valueObject, data2Value, len); + predicates->between(predicates, "data2", valueObject); + + OH_Cursor *cursor = OH_Rdb_Query(predicatesTestRdbStore_, predicates, NULL, 0); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query is fail."); + int rowCount = -1; + errCode = cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 0, "getRowCount is fail."); + + valueObject->destroy(valueObject); + predicates->destroy(predicates); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} +/** + * @tc.name: SUB_DDM_RDB_Predicates_4000 + * @tc.desc: napi test RDB Predicates for Between + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_Predicates_4000(napi_env env, napi_callback_info info) { + int errCode = 0; + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + OH_VObject *valueObject = OH_Rdb_CreateValueObject(); + int64_t data2Value[] = {12000, 13000}; + uint32_t len = sizeof(data2Value) / sizeof(data2Value[0]); + valueObject->putInt64(valueObject, data2Value, len); + predicates->between(predicates, "data", valueObject); + + OH_Cursor *cursor = OH_Rdb_Query(predicatesTestRdbStore_, predicates, NULL, 0); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query is fail."); + int rowCount = -1; + errCode = cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == -1, "getRowCount is fail."); + + valueObject->destroy(valueObject); + predicates->destroy(predicates); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} + +/** + * @tc.name: SUB_DDM_RDB_Predicates_4100 + * @tc.desc: napi test RDB Predicates for NotBetween + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_Predicates_4100(napi_env env, napi_callback_info info) { + int errCode = 0; + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + OH_VObject *valueObject = OH_Rdb_CreateValueObject(); + int64_t data2Value[] = {12000, 13000}; + int len = sizeof(data2Value) / sizeof(data2Value[0]); + valueObject->putInt64(valueObject, data2Value, len); + predicates->notBetween(predicates, "data", valueObject); + + OH_Cursor *cursor = OH_Rdb_Query(predicatesTestRdbStore_, predicates, NULL, 0); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query is fail."); + int rowCount = -1; + errCode = cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == -1, "getRowCount is fail."); + + valueObject->destroy(valueObject); + predicates->destroy(predicates); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} + +/** + * @tc.name: SUB_DDM_RDB_Predicates_4200 + * @tc.desc: napi test RDB Predicates for GreaterThan + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_Predicates_4200(napi_env env, napi_callback_info info) { + int errCode = 0; + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + OH_VObject *valueObject = OH_Rdb_CreateValueObject(); + uint32_t count = 1; + double data3Value = 200.1; + valueObject->putDouble(valueObject, &data3Value, count); + predicates->greaterThan(predicates, "data3", valueObject); + + OH_Cursor *cursor = OH_Rdb_Query(predicatesTestRdbStore_, predicates, NULL, 0); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query is fail."); + int rowCount = 0; + errCode = cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 2, "getRowCount is fail."); + + valueObject->destroy(valueObject); + predicates->destroy(predicates); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} + +/** + * @tc.name: SUB_DDM_RDB_Predicates_4300 + * @tc.desc: napi test RDB Predicates for GreaterThan + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_Predicates_4300(napi_env env, napi_callback_info info) { + int errCode = 0; + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + OH_VObject *valueObject = OH_Rdb_CreateValueObject(); + uint32_t count = 1; + double data3Value = 400.1; + valueObject->putDouble(valueObject, &data3Value, count); + predicates->greaterThan(predicates, "data3", valueObject); + + OH_Cursor *cursor = OH_Rdb_Query(predicatesTestRdbStore_, predicates, NULL, 0); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query is fail."); + int rowCount = -1; + errCode = cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 0, "getRowCount is fail."); + + valueObject->destroy(valueObject); + predicates->destroy(predicates); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} + +/** + * @tc.name: SUB_DDM_RDB_Predicates_4400 + * @tc.desc: napi test RDB Predicates for GreaterThan + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_Predicates_4400(napi_env env, napi_callback_info info) { + int errCode = 0; + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + OH_VObject *valueObject = OH_Rdb_CreateValueObject(); + const char *data5Value = "ABCDEFG"; + valueObject->putText(valueObject, data5Value); + predicates->greaterThan(predicates, "data", valueObject); + + OH_Cursor *cursor = OH_Rdb_Query(predicatesTestRdbStore_, predicates, NULL, 0); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query is fail."); + int rowCount = -1; + errCode = cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == -1, "getRowCount is fail."); + + valueObject->destroy(valueObject); + predicates->destroy(predicates); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} + +/** + * @tc.name: SUB_DDM_RDB_Predicates_4500 + * @tc.desc: napi test RDB Predicates for LessThan + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_Predicates_4500(napi_env env, napi_callback_info info) { + int errCode = 0; + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + OH_VObject *valueObject = OH_Rdb_CreateValueObject(); + const char *data5Value = "ABCDEFG"; + valueObject->putText(valueObject, data5Value); + predicates->lessThan(predicates, "data", valueObject); + + OH_Cursor *cursor = OH_Rdb_Query(predicatesTestRdbStore_, predicates, NULL, 0); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query is fail."); + int rowCount = -1; + errCode = cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == -1, "getRowCount is fail."); + + valueObject->destroy(valueObject); + predicates->destroy(predicates); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} + +/** + * @tc.name: SUB_DDM_RDB_Predicates_4600 + * @tc.desc: napi test RDB Predicates for LessThan + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_Predicates_4600(napi_env env, napi_callback_info info) { + int errCode = 0; + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + OH_VObject *valueObject = OH_Rdb_CreateValueObject(); + uint32_t count = 1; + double data3Value = 300.1; + valueObject->putDouble(valueObject, &data3Value, count); + predicates->lessThan(predicates, "data3", valueObject); + + OH_Cursor *cursor = OH_Rdb_Query(predicatesTestRdbStore_, predicates, NULL, 0); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query is fail."); + int rowCount = -1; + errCode = cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 2, "getRowCount is fail."); + + valueObject->destroy(valueObject); + predicates->destroy(predicates); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} + +/** + * @tc.name: SUB_DDM_RDB_Predicates_4700 + * @tc.desc: napi test RDB Predicates for LessThan + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_Predicates_4700(napi_env env, napi_callback_info info) { + int errCode = 0; + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + OH_VObject *valueObject = OH_Rdb_CreateValueObject(); + uint32_t count = 1; + double data3Value = 10.1; + valueObject->putDouble(valueObject, &data3Value, count); + predicates->lessThan(predicates, "data3", valueObject); + + OH_Cursor *cursor = OH_Rdb_Query(predicatesTestRdbStore_, predicates, NULL, 0); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query is fail."); + int rowCount = -1; + errCode = cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 0, "getRowCount is fail."); + + valueObject->destroy(valueObject); + predicates->destroy(predicates); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} + +/** + * @tc.name: SUB_DDM_RDB_Predicates_4800 + * @tc.desc: napi test RDB Predicates for GreaterThanOrEqualTo + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_Predicates_4800(napi_env env, napi_callback_info info) { + int errCode = 0; + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + OH_VObject *valueObject = OH_Rdb_CreateValueObject(); + const char *data5Value = "ABCDEFG"; + valueObject->putText(valueObject, data5Value); + predicates->greaterThanOrEqualTo(predicates, "data", valueObject); + + OH_Cursor *cursor = OH_Rdb_Query(predicatesTestRdbStore_, predicates, NULL, 0); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query is fail."); + int rowCount = -1; + errCode = cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == -1, "getRowCount is fail."); + + valueObject->destroy(valueObject); + predicates->destroy(predicates); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; + } + +/** + * @tc.name: SUB_DDM_RDB_Predicates_4900 + * @tc.desc: napi test RDB Predicates for GreaterThanOrEqualTo + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_Predicates_4900(napi_env env, napi_callback_info info) { + int errCode = 0; + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + OH_VObject *valueObject = OH_Rdb_CreateValueObject(); + uint32_t count = 1; + double data3Value = 300.1; + valueObject->putDouble(valueObject, &data3Value, count); + predicates->greaterThanOrEqualTo(predicates, "data3", valueObject); + + OH_Cursor *cursor = OH_Rdb_Query(predicatesTestRdbStore_, predicates, NULL, 0); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query is fail."); + int rowCount = 0; + errCode = cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 2, "getRowCount is fail."); + + valueObject->destroy(valueObject); + predicates->destroy(predicates); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} +/** + * @tc.name: SUB_DDM_RDB_Predicates_5000 + * @tc.desc: napi test RDB Predicates for GreaterThanOrEqualTo + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_Predicates_5000(napi_env env, napi_callback_info info) { + int errCode = 0; + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + OH_VObject *valueObject = OH_Rdb_CreateValueObject(); + uint32_t count = 1; + double data3Value = 400.1; + valueObject->putDouble(valueObject, &data3Value, count); + predicates->greaterThanOrEqualTo(predicates, "data3", valueObject); + + OH_Cursor *cursor = OH_Rdb_Query(predicatesTestRdbStore_, predicates, NULL, 0); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query is fail."); + int rowCount = -1; + errCode = cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 0, "getRowCount is fail."); + + valueObject->destroy(valueObject); + predicates->destroy(predicates); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} + +/** + * @tc.name: SUB_DDM_RDB_Predicates_5100 + * @tc.desc: napi test RDB Predicates for LessThanOrEqualTo + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_Predicates_5100(napi_env env, napi_callback_info info) { + int errCode = 0; + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + OH_VObject *valueObject = OH_Rdb_CreateValueObject(); + const char *data5Value = "ABCDEFG"; + valueObject->putText(valueObject, data5Value); + predicates->lessThanOrEqualTo(predicates, "data", valueObject); + + OH_Cursor *cursor = OH_Rdb_Query(predicatesTestRdbStore_, predicates, NULL, 0); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query is fail."); + int rowCount = -1; + errCode = cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == -1, "getRowCount is fail."); + + valueObject->destroy(valueObject); + predicates->destroy(predicates); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} + +/** + * @tc.name: SUB_DDM_RDB_Predicates_5200 + * @tc.desc: napi test RDB Predicates for LessThanOrEqualTo + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_Predicates_5200(napi_env env, napi_callback_info info) { + int errCode = 0; + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + OH_VObject *valueObject = OH_Rdb_CreateValueObject(); + uint32_t count = 1; + double data3Value = 1.1; + valueObject->putDouble(valueObject, &data3Value, count); + predicates->lessThanOrEqualTo(predicates, "data3", valueObject); + + OH_Cursor *cursor = OH_Rdb_Query(predicatesTestRdbStore_, predicates, NULL, 0); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query is fail."); + int rowCount = -1; + errCode = cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 0, "getRowCount is fail."); + + valueObject->destroy(valueObject); + predicates->destroy(predicates); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} +/** + * @tc.name: SUB_DDM_RDB_Predicates_5300 + * @tc.desc: napi test RDB Predicates for + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_Predicates_5300(napi_env env, napi_callback_info info) { + int errCode = 0; + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + OH_VObject *valueObject = OH_Rdb_CreateValueObject(); + uint32_t count = 1; + double data3Value = 200.1; + valueObject->putDouble(valueObject, &data3Value, count); + predicates->lessThanOrEqualTo(predicates, "data3", valueObject); + + OH_Cursor *cursor = OH_Rdb_Query(predicatesTestRdbStore_, predicates, NULL, 0); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query is fail."); + int rowCount = 0; + errCode = cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 2, "getRowCount is fail."); + + valueObject->destroy(valueObject); + predicates->destroy(predicates); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} +/** + * @tc.name: SUB_DDM_RDB_Predicates_5400 + * @tc.desc: napi test RDB Predicates for GroupBy + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_Predicates_5400(napi_env env, napi_callback_info info) { + int errCode = 0; + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + const char *columnNames[] = {"data", "data2"}; + int len = sizeof(columnNames) / sizeof(columnNames[0]); + predicates->groupBy(predicates, columnNames, len); + + OH_Cursor *cursor = OH_Rdb_Query(predicatesTestRdbStore_, predicates, NULL, 0); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query is fail."); + int rowCount = -1; + errCode = cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == -1, "getRowCount is fail."); + + predicates->destroy(predicates); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} +/** + * @tc.name: SUB_DDM_RDB_Predicates_5500 + * @tc.desc: napi test RDB Predicates for GroupBy + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_Predicates_5500(napi_env env, napi_callback_info info) { + int errCode = 0; + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + const char *columnNames[] = {"data1", "data2"}; + predicates->groupBy(predicates, columnNames, 0); + + OH_Cursor *cursor = OH_Rdb_Query(predicatesTestRdbStore_, predicates, NULL, 0); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query is fail."); + int rowCount = -1; + errCode = cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 4, "getRowCount is fail."); + + predicates->destroy(predicates); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} +/** + * @tc.name: SUB_DDM_RDB_Predicates_5600 + * @tc.desc: napi test RDB Predicates for GroupBy + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_Predicates_5600(napi_env env, napi_callback_info info) { + int errCode = 0; + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + const char *columnNames[] = {"data1", "data2"}; + predicates->groupBy(predicates, columnNames, 2); + + OH_Cursor *cursor = OH_Rdb_Query(predicatesTestRdbStore_, predicates, NULL, 0); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query is fail."); + int rowCount = -1; + errCode = cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 4, "getRowCount is fail."); + + predicates->destroy(predicates); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} +/** + * @tc.name: SUB_DDM_RDB_Predicates_5700 + * @tc.desc: napi test RDB Predicates for GroupBy + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_Predicates_5700(napi_env env, napi_callback_info info) { + int errCode = 0; + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + const char *columnNames[] = {"data1", "data2"}; + predicates->groupBy(predicates, columnNames, 3); + + OH_Cursor *cursor = OH_Rdb_Query(predicatesTestRdbStore_, predicates, NULL, 0); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query is fail."); + int rowCount = -1; + errCode = cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == -1, "getRowCount is fail."); + + predicates->destroy(predicates); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} +/** + * @tc.name: SUB_DDM_RDB_Predicates_5800 + * @tc.desc: napi test RDB Predicates for GroupBy + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_Predicates_5800(napi_env env, napi_callback_info info) { + int errCode = 0; + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + const char *columnNames[] = {"data2", "data3"}; + predicates->groupBy(predicates, columnNames, 1); + + OH_Cursor *cursor = OH_Rdb_Query(predicatesTestRdbStore_, predicates, NULL, 0); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query is fail."); + int rowCount = -1; + errCode = cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 3, "getRowCount is fail."); + + predicates->destroy(predicates); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} +/** + * @tc.name: SUB_DDM_RDB_Predicates_5900 + * @tc.desc: napi test RDB Predicates for In. + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_Predicates_5900(napi_env env, napi_callback_info info) { + int errCode = 0; + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + OH_VObject *valueObject = OH_Rdb_CreateValueObject(); + const char *data1Value[] = {"zhangSan", "liSi"}; + int len = sizeof(data1Value) / sizeof(data1Value[0]); + valueObject->putTexts(valueObject, data1Value, len); + predicates->in(predicates, "data", valueObject); + + OH_Cursor *cursor = OH_Rdb_Query(predicatesTestRdbStore_, predicates, NULL, 0); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query is fail."); + int rowCount = -1; + errCode = cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == -1, "getRowCount is fail."); + + valueObject->destroy(valueObject); + predicates->destroy(predicates); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} +/** + * @tc.name: SUB_DDM_RDB_Predicates_6000 + * @tc.desc: napi test RDB Predicates for In. + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_Predicates_6000(napi_env env, napi_callback_info info) { + int errCode = 0; + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + OH_VObject *valueObject = OH_Rdb_CreateValueObject(); + int64_t data2Value[] = {12800, 13000}; + uint32_t len = sizeof(data2Value) / sizeof(data2Value[0]); + valueObject->putInt64(valueObject, data2Value, len); + predicates->in(predicates, "data2", valueObject); + + OH_Cursor *cursor = OH_Rdb_Query(predicatesTestRdbStore_, predicates, NULL, 0); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query is fail."); + int rowCount = -1; + errCode = cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 1, "getRowCount is fail."); + + valueObject->destroy(valueObject); + predicates->destroy(predicates); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} + +/** + * @tc.name: SUB_DDM_RDB_Predicates_6100 + * @tc.desc: napi test RDB Predicates for NotIn + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_Predicates_6100(napi_env env, napi_callback_info info) { + int errCode = 0; + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + OH_VObject *valueObject = OH_Rdb_CreateValueObject(); + const char *data1Value[] = {"zhangSan", "liSi"}; + int len = sizeof(data1Value) / sizeof(data1Value[0]); + valueObject->putTexts(valueObject, data1Value, len); + predicates->notIn(predicates, "data", valueObject); + + OH_Cursor *cursor = OH_Rdb_Query(predicatesTestRdbStore_, predicates, NULL, 0); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query is fail."); + int rowCount = -1; + errCode = cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == -1, "getRowCount is fail."); + + valueObject->destroy(valueObject); + predicates->destroy(predicates); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} + +/** + * @tc.name: SUB_DDM_RDB_Predicates_6200 + * @tc.desc: napi test RDB Predicates for NotIn + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_Predicates_6200(napi_env env, napi_callback_info info) { + int errCode = 0; + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + OH_VObject *valueObject = OH_Rdb_CreateValueObject(); + int64_t data2Value[] = {12800, 13800}; + uint32_t len = sizeof(data2Value) / sizeof(data2Value[0]); + valueObject->putInt64(valueObject, data2Value, len); + predicates->notIn(predicates, "data2", valueObject); + + OH_Cursor *cursor = OH_Rdb_Query(predicatesTestRdbStore_, predicates, NULL, 0); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query is fail."); + int rowCount = -1; + errCode = cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 2, "getRowCount is fail."); + + valueObject->destroy(valueObject); + predicates->destroy(predicates); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} +/** + * @tc.name: SUB_DDM_RDB_Predicates_6300 + * @tc.desc: napi test RDB Predicates for OrderBy + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_Predicates_6300(napi_env env, napi_callback_info info) { + int errCode = 0; + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + predicates->orderBy(predicates, "data2", OH_OrderType::DESC); + predicates->limit(predicates, 1); + predicates->offset(predicates, 0); + predicates->distinct(predicates); + + OH_Cursor *cursor = OH_Rdb_Query(predicatesTestRdbStore_, predicates, NULL, 0); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query is fail."); + int rowCount = 0; + errCode = cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 1, "getRowCount is fail."); + + errCode = cursor->goToNextRow(cursor); + int columnIndex; + cursor->getColumnIndex(cursor, "data2", &columnIndex); + NAPI_ASSERT(env, columnIndex == 2, "getColumnIndex is fail."); + + int64_t longValue; + cursor->getInt64(cursor, columnIndex, &longValue); + NAPI_ASSERT(env, longValue == 14800, "getInt64 is fail."); + + predicates->destroy(predicates); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} +/** + * @tc.name: SUB_DDM_RDB_Predicates_6400 + * @tc.desc: napi test RDB Predicates for OrderBy + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_Predicates_6400(napi_env env, napi_callback_info info) { + int errCode = 0; + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + predicates->orderBy(predicates, "data", OH_OrderType::ASC); + predicates->limit(predicates, 1); + predicates->offset(predicates, 0); + predicates->distinct(predicates); + + OH_Cursor *cursor = OH_Rdb_Query(predicatesTestRdbStore_, predicates, NULL, 0); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query is fail."); + int rowCount = -1; + errCode = cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == -1, "getRowCount is fail."); + + predicates->destroy(predicates); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} +/** + * @tc.name: SUB_DDM_RDB_Predicates_6500 + * @tc.desc: napi test RDB Predicates for Limit + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_Predicates_6500(napi_env env, napi_callback_info info) { + int errCode = 0; + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + predicates->orderBy(predicates, "data2", OH_OrderType::ASC); + predicates->limit(predicates, 0); + predicates->offset(predicates, 0); + predicates->distinct(predicates); + + OH_Cursor *cursor = OH_Rdb_Query(predicatesTestRdbStore_, predicates, NULL, 0); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query is fail."); + int rowCount = -1; + errCode = cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 4, "getRowCount is fail."); + + predicates->destroy(predicates); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} + +/** + * @tc.name: SUB_DDM_RDB_Predicates_6600 + * @tc.desc: napi test RDB Predicates for Offset + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_Predicates_6600(napi_env env, napi_callback_info info) { + int errCode = 0; + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + predicates->orderBy(predicates, "data2", OH_OrderType::ASC); + predicates->limit(predicates, 1); + predicates->offset(predicates, 5); + predicates->distinct(predicates); + + OH_Cursor *cursor = OH_Rdb_Query(predicatesTestRdbStore_, predicates, NULL, 0); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query is fail."); + int rowCount = -1; + errCode = cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 0, "getRowCount is fail."); + + predicates->destroy(predicates); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} + +/** + * @tc.name: SUB_DDM_RDB_Predicates_6700 + * @tc.desc: napi test RDB Predicates for Offset + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_Predicates_6700(napi_env env, napi_callback_info info) { + int errCode = 0; + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + predicates->orderBy(predicates, "data2", OH_OrderType::ASC); + predicates->limit(predicates, 1); + predicates->offset(predicates, -1); + predicates->distinct(predicates); + + OH_Cursor *cursor = OH_Rdb_Query(predicatesTestRdbStore_, predicates, NULL, 0); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query is fail."); + int rowCount = -1; + errCode = cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 1, "getRowCount is fail."); + + predicates->destroy(predicates); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} + +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) { + napi_property_descriptor desc[] = { + {"PredicatesSetUpTestCase", nullptr, PredicatesSetUpTestCase, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"PredicatesTearDownTestCase", nullptr, PredicatesTearDownTestCase, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_Predicates_0100", nullptr, SUB_DDM_RDB_Predicates_0100, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_Predicates_0200", nullptr, SUB_DDM_RDB_Predicates_0200, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_Predicates_0300", nullptr, SUB_DDM_RDB_Predicates_0300, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_Predicates_0400", nullptr, SUB_DDM_RDB_Predicates_0400, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_Predicates_0500", nullptr, SUB_DDM_RDB_Predicates_0500, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_Predicates_0600", nullptr, SUB_DDM_RDB_Predicates_0600, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_Predicates_0700", nullptr, SUB_DDM_RDB_Predicates_0700, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_Predicates_0800", nullptr, SUB_DDM_RDB_Predicates_0800, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_Predicates_0900", nullptr, SUB_DDM_RDB_Predicates_0900, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_Predicates_1000", nullptr, SUB_DDM_RDB_Predicates_1000, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_Predicates_1100", nullptr, SUB_DDM_RDB_Predicates_1100, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_Predicates_1200", nullptr, SUB_DDM_RDB_Predicates_1200, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_Predicates_1300", nullptr, SUB_DDM_RDB_Predicates_1300, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_Predicates_1400", nullptr, SUB_DDM_RDB_Predicates_1400, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_Predicates_1500", nullptr, SUB_DDM_RDB_Predicates_1500, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_Predicates_1600", nullptr, SUB_DDM_RDB_Predicates_1600, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_Predicates_1700", nullptr, SUB_DDM_RDB_Predicates_1700, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_Predicates_1800", nullptr, SUB_DDM_RDB_Predicates_1800, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_Predicates_1900", nullptr, SUB_DDM_RDB_Predicates_1900, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_Predicates_2000", nullptr, SUB_DDM_RDB_Predicates_2000, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_Predicates_2100", nullptr, SUB_DDM_RDB_Predicates_2100, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_Predicates_2200", nullptr, SUB_DDM_RDB_Predicates_2200, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_Predicates_2300", nullptr, SUB_DDM_RDB_Predicates_2300, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_Predicates_2400", nullptr, SUB_DDM_RDB_Predicates_2400, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_Predicates_2500", nullptr, SUB_DDM_RDB_Predicates_2500, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_Predicates_2600", nullptr, SUB_DDM_RDB_Predicates_2600, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_Predicates_2700", nullptr, SUB_DDM_RDB_Predicates_2700, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_Predicates_2800", nullptr, SUB_DDM_RDB_Predicates_2800, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_Predicates_2900", nullptr, SUB_DDM_RDB_Predicates_2900, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_Predicates_3000", nullptr, SUB_DDM_RDB_Predicates_3000, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_Predicates_3100", nullptr, SUB_DDM_RDB_Predicates_3100, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_Predicates_3200", nullptr, SUB_DDM_RDB_Predicates_3200, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_Predicates_3300", nullptr, SUB_DDM_RDB_Predicates_3300, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_Predicates_3400", nullptr, SUB_DDM_RDB_Predicates_3400, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_Predicates_3500", nullptr, SUB_DDM_RDB_Predicates_3500, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_Predicates_3600", nullptr, SUB_DDM_RDB_Predicates_3600, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_Predicates_3700", nullptr, SUB_DDM_RDB_Predicates_3700, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_Predicates_3800", nullptr, SUB_DDM_RDB_Predicates_3800, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_Predicates_3900", nullptr, SUB_DDM_RDB_Predicates_3900, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_Predicates_4000", nullptr, SUB_DDM_RDB_Predicates_4000, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_Predicates_4100", nullptr, SUB_DDM_RDB_Predicates_4100, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_Predicates_4200", nullptr, SUB_DDM_RDB_Predicates_4200, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_Predicates_4300", nullptr, SUB_DDM_RDB_Predicates_4300, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_Predicates_4400", nullptr, SUB_DDM_RDB_Predicates_4400, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_Predicates_4500", nullptr, SUB_DDM_RDB_Predicates_4500, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_Predicates_4600", nullptr, SUB_DDM_RDB_Predicates_4600, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_Predicates_4700", nullptr, SUB_DDM_RDB_Predicates_4700, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_Predicates_4800", nullptr, SUB_DDM_RDB_Predicates_4800, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_Predicates_4900", nullptr, SUB_DDM_RDB_Predicates_4900, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_Predicates_5000", nullptr, SUB_DDM_RDB_Predicates_5000, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_Predicates_5100", nullptr, SUB_DDM_RDB_Predicates_5100, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_Predicates_5200", nullptr, SUB_DDM_RDB_Predicates_5200, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_Predicates_5300", nullptr, SUB_DDM_RDB_Predicates_5300, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_Predicates_5400", nullptr, SUB_DDM_RDB_Predicates_5400, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_Predicates_5500", nullptr, SUB_DDM_RDB_Predicates_5500, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_Predicates_5600", nullptr, SUB_DDM_RDB_Predicates_5600, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_Predicates_5700", nullptr, SUB_DDM_RDB_Predicates_5700, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_Predicates_5800", nullptr, SUB_DDM_RDB_Predicates_5800, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_Predicates_5900", nullptr, SUB_DDM_RDB_Predicates_5900, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_Predicates_6000", nullptr, SUB_DDM_RDB_Predicates_6000, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_Predicates_6100", nullptr, SUB_DDM_RDB_Predicates_6100, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_Predicates_6200", nullptr, SUB_DDM_RDB_Predicates_6200, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_Predicates_6300", nullptr, SUB_DDM_RDB_Predicates_6300, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_Predicates_6400", nullptr, SUB_DDM_RDB_Predicates_6400, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_Predicates_6500", nullptr, SUB_DDM_RDB_Predicates_6500, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_Predicates_6600", nullptr, SUB_DDM_RDB_Predicates_6600, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_Predicates_6700", nullptr, SUB_DDM_RDB_Predicates_6700, nullptr, nullptr, nullptr, napi_default, nullptr} + + }; + + + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END + + + + + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "predicates", + .nm_priv = ((void *)0), + .reserved = {0}, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { + napi_module_register(&demoModule); +} diff --git a/distributeddatamgr/relationalStoretest/rdbnapitest/entry/src/main/cpp/napi/rdb_store_test.cpp b/distributeddatamgr/relationalStoretest/rdbnapitest/entry/src/main/cpp/napi/rdb_store_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..fc26f8973251aae8df80583dcebbb7ee56f22c4f --- /dev/null +++ b/distributeddatamgr/relationalStoretest/rdbnapitest/entry/src/main/cpp/napi/rdb_store_test.cpp @@ -0,0 +1,1657 @@ +/* + * 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 +#include +#include +#include +#include +#include +#include + +#include "napi/native_api.h" +#include "common/common.h" +#include "relational_store.h" +#include "relational_store_error_code.h" +#include "oh_cursor.h" +#include "oh_predicates.h" +#include "oh_value_object.h" +#include "oh_values_bucket.h" + +char RDB_TEST_PATH[] = "/data/storage/el2/database/"; +char RDB_STORE_NAME[] = "rdb_store_test.db"; +char BUNDLE_NAME[] = "com.acts.rdb.napitest"; +char MODULE_NAME[] = "com.acts.rdb.napitest"; + +OH_Rdb_Store *storeTestRdbStore_ = NULL; +static OH_Rdb_Config config_; +static void InitRdbConfig() +{ + config_.dataBaseDir = RDB_TEST_PATH; + config_.storeName = RDB_STORE_NAME; + config_.bundleName = BUNDLE_NAME; + config_.moduleName = MODULE_NAME; + config_.securityLevel = OH_Rdb_SecurityLevel::S1; + config_.isEncrypt = false; + config_.selfSize = sizeof(OH_Rdb_Config); +} +static napi_value RdbstoreSetUpTestCase(napi_env env, napi_callback_info info) { + + InitRdbConfig(); + mkdir(config_.dataBaseDir, 0770); + + int errCode = 0; + storeTestRdbStore_ = OH_Rdb_GetOrOpen(&config_, &errCode); + NAPI_ASSERT(env, errCode == 0, "OH_Rdb_GetOrOpen is fail."); + NAPI_ASSERT(env, storeTestRdbStore_ != NULL, "OH_Rdb_GetOrOpen config is fail."); + + char createTableSql[] = "CREATE TABLE test (id INTEGER PRIMARY KEY AUTOINCREMENT, data1 TEXT, data2 INTEGER, " + "data3 FLOAT, data4 BLOB, data5 TEXT);"; + errCode = OH_Rdb_Execute(storeTestRdbStore_, createTableSql); + NAPI_ASSERT(env, errCode == 0, "createTable is fail."); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} + +static napi_value RdbstoreTearDownTestCase(napi_env env, napi_callback_info info) { + int errCode = 0; + char dropTableSql[] = "DROP TABLE IF EXISTS test"; + errCode = OH_Rdb_Execute(storeTestRdbStore_, dropTableSql); + NAPI_ASSERT(env, errCode == 0, "OH_Rdb_Execute is fail."); + errCode = OH_Rdb_CloseStore(storeTestRdbStore_); + NAPI_ASSERT(env, errCode == 0, "OH_Rdb_CloseStore is fail."); + errCode = OH_Rdb_DeleteStore(&config_); + NAPI_ASSERT(env, errCode == 0, "OH_Rdb_DeleteStore is fail."); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} + + +/** + * @tc.name: SUB_DDM_RDB_0100 + * @tc.desc: napi test RDB store for Insert、Update、Query. + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_0100(napi_env env, napi_callback_info info) { + + int errCode = 0; + OH_VBucket* valueBucket = OH_Rdb_CreateValuesBucket(); + valueBucket->putInt64(valueBucket, "id", 1); + valueBucket->putText(valueBucket, "data1", "zhangSan"); + valueBucket->putInt64(valueBucket, "data2", 12800); + valueBucket->putReal(valueBucket, "data3", 100.1); + uint8_t arr[] = {1, 2, 3, 4, 5}; + int len = sizeof(arr) / sizeof(arr[0]); + valueBucket->putBlob(valueBucket, "data4", arr, len); + valueBucket->putText(valueBucket, "data5", "ABCDEFG"); + errCode = OH_Rdb_Insert(storeTestRdbStore_, "test", valueBucket); + NAPI_ASSERT(env, errCode == 1, "OH_Rdb_Insert is fail."); + + valueBucket->clear(valueBucket); + valueBucket->putText(valueBucket, "data1", "liSi"); + valueBucket->putInt64(valueBucket, "data2", 13800); + valueBucket->putReal(valueBucket, "data3", 200.1); + valueBucket->putNull(valueBucket, "data5"); + + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + OH_VObject *valueObject = OH_Rdb_CreateValueObject(); + const char *data1Value = "zhangSan"; + valueObject->putText(valueObject, data1Value); + predicates->equalTo(predicates, "data1", valueObject); + errCode = OH_Rdb_Update(storeTestRdbStore_, valueBucket, predicates); + NAPI_ASSERT(env, errCode == 1, "OH_Rdb_Update is fail."); + + predicates->clear(predicates); + OH_Cursor *cursor = OH_Rdb_Query(storeTestRdbStore_, predicates, NULL, 0); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query is fail."); + + int rowCount = 0; + cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 1, "getRowCount is fail."); + + errCode = cursor->goToNextRow(cursor); + NAPI_ASSERT(env, errCode == 0, "goToNextRow is fail."); + + size_t size = 0; + cursor->getSize(cursor, 1, &size); + char data1Value_1[size + 1]; + cursor->getText(cursor, 1, data1Value_1, size + 1); + NAPI_ASSERT(env, strncmp(data1Value_1, "liSi", size) == 0, "getText is fail."); + + int64_t data2Value; + cursor->getInt64(cursor, 2, &data2Value); + NAPI_ASSERT(env, data2Value == 13800, "getInt64 is fail."); + + + double data3Value; + cursor->getReal(cursor, 3, &data3Value); + NAPI_ASSERT(env, data3Value == 200.1, "getReal is fail."); + + cursor->getSize(cursor, 4, &size); + unsigned char data4Value[size]; + cursor->getBlob(cursor, 4, data4Value, size); + NAPI_ASSERT(env, data4Value[0] == 1, "getBlob is fail."); + NAPI_ASSERT(env, data4Value[1] == 2, "getBlob is fail."); + + bool isNull = false; + cursor->isNull(cursor, 5, &isNull); + NAPI_ASSERT(env, isNull == true, "isNull is fail."); + + + valueObject->destroy(valueObject); + valueBucket->destroy(valueBucket); + predicates->destroy(predicates); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; + +} + + +/** + * @tc.name: SUB_DDM_RDB_0200 + * @tc.desc: napi test RDB store for Insert with wrong table name or table is NULL. + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_0200(napi_env env, napi_callback_info info) { + int errCode = 0; + OH_VBucket* valueBucket = OH_Rdb_CreateValuesBucket(); + valueBucket->putInt64(valueBucket, "id", 1); + valueBucket->putText(valueBucket, "data1", "zhangSan"); + valueBucket->putInt64(valueBucket, "data2", 12800); + valueBucket->putReal(valueBucket, "data3", 100.1); + uint8_t arr[] = {1, 2, 3, 4, 5}; + int len = sizeof(arr) / sizeof(arr[0]); + valueBucket->putBlob(valueBucket, "data4", arr, len); + valueBucket->putText(valueBucket, "data5", "ABCDEFG"); + errCode = OH_Rdb_Insert(storeTestRdbStore_, "test", valueBucket); + NAPI_ASSERT(env, errCode == 1, "OH_Rdb_Insert is fail."); + + valueBucket->clear(valueBucket); + valueBucket->putInt64(valueBucket, "id", 2); + valueBucket->putText(valueBucket, "data1", "liSi"); + valueBucket->putInt64(valueBucket, "data2", 13800); + valueBucket->putReal(valueBucket, "data3", 200.1); + valueBucket->putText(valueBucket, "data5", "ABCDEFGH"); + errCode = OH_Rdb_Insert(storeTestRdbStore_, "wrong", valueBucket); + NAPI_ASSERT(env, errCode == -1, "OH_Rdb_Insert id=2 is fail."); + + valueBucket->clear(valueBucket); + valueBucket->putInt64(valueBucket, "id", 3); + valueBucket->putText(valueBucket, "data1", "wangWu"); + valueBucket->putInt64(valueBucket, "data2", 14800); + valueBucket->putReal(valueBucket, "data3", 300.1); + valueBucket->putText(valueBucket, "data5", "ABCDEFGHI"); + char *table = NULL; + errCode = OH_Rdb_Insert(storeTestRdbStore_, table, valueBucket); + NAPI_ASSERT(env, errCode == OH_Rdb_ErrCode::RDB_E_INVALID_ARGS, "OH_Rdb_Insert id=3 is fail."); + + char querySql[] = "SELECT * FROM test"; + OH_Cursor *cursor = OH_Rdb_ExecuteQuery(storeTestRdbStore_, querySql); + + int rowCount = 0; + cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 1, "getRowCount is fail."); + + valueBucket->destroy(valueBucket); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; + +} + +/** + * @tc.name: SUB_DDM_RDB_0300 + * @tc.desc: napi test RDB store for Update with wrong table or table is NULL. + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_0300(napi_env env, napi_callback_info info) { + int errCode = 0; + OH_VBucket* valueBucket = OH_Rdb_CreateValuesBucket(); + valueBucket->putInt64(valueBucket, "id", 1); + valueBucket->putText(valueBucket, "data1", "zhangSan"); + valueBucket->putInt64(valueBucket, "data2", 12800); + valueBucket->putReal(valueBucket, "data3", 100.1); + uint8_t arr[] = {1, 2, 3, 4, 5}; + int len = sizeof(arr) / sizeof(arr[0]); + valueBucket->putBlob(valueBucket, "data4", arr, len); + valueBucket->putText(valueBucket, "data5", "ABCDEFG"); + errCode = OH_Rdb_Insert(storeTestRdbStore_, "test", valueBucket); + NAPI_ASSERT(env, errCode == 1, "OH_Rdb_Insert is fail."); + + valueBucket->clear(valueBucket); + valueBucket->putText(valueBucket, "data1", "liSi"); + valueBucket->putInt64(valueBucket, "data2", 13800); + valueBucket->putReal(valueBucket, "data3", 200.1); + valueBucket->putNull(valueBucket, "data5"); + + OH_Predicates *predicates = OH_Rdb_CreatePredicates("wrong"); + OH_VObject *valueObject = OH_Rdb_CreateValueObject(); + const char *data1Value = "zhangSan"; + valueObject->putText(valueObject, data1Value); + predicates->equalTo(predicates, "data1", valueObject); + errCode = OH_Rdb_Update(storeTestRdbStore_, valueBucket, predicates); + NAPI_ASSERT(env, errCode == -1, "OH_Rdb_Update is fail."); + + char *table = NULL; + OH_Predicates *predicates1 = OH_Rdb_CreatePredicates(table); + NAPI_ASSERT(env, predicates1 == NULL, "OH_Rdb_CreatePredicates is fail."); + errCode = OH_Rdb_Update(storeTestRdbStore_, valueBucket, predicates1); + NAPI_ASSERT(env, errCode == OH_Rdb_ErrCode::RDB_E_INVALID_ARGS, "OH_Rdb_Update is fail."); + + OH_Predicates *predicates2 = OH_Rdb_CreatePredicates("test"); + OH_Cursor *cursor = OH_Rdb_Query(storeTestRdbStore_, predicates2, NULL, 0); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query is fail."); + + int rowCount = 0; + cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 1, "getRowCount is fail."); + + errCode = cursor->goToNextRow(cursor); + NAPI_ASSERT(env, errCode == 0, "goToNextRow is fail."); + + size_t size = 0; + cursor->getSize(cursor, 1, &size); + char data1Value_1[size + 1]; + cursor->getText(cursor, 1, data1Value_1, size + 1); + NAPI_ASSERT(env, strncmp(data1Value_1, "zhangSan", size) == 0, "getText is fail."); + + int64_t data2Value; + cursor->getInt64(cursor, 2, &data2Value); + NAPI_ASSERT(env, data2Value == 12800, "getInt64 is fail."); + + double data3Value; + cursor->getReal(cursor, 3, &data3Value); + NAPI_ASSERT(env, data3Value == 100.1, "getReal is fail."); + + cursor->getSize(cursor, 4, &size); + unsigned char data4Value[size]; + cursor->getBlob(cursor, 4, data4Value, size); + NAPI_ASSERT(env, data4Value[0] == 1, "getBlob is fail."); + NAPI_ASSERT(env, data4Value[1] == 2, "getBlob is fail."); + + cursor->getSize(cursor, 5, &size); + char data5Value[size + 1]; + cursor->getText(cursor, 5, data5Value, size + 1); + NAPI_ASSERT(env, strncmp(data5Value, "ABCDEFG", size) == 0, "getText is fail."); + + valueObject->destroy(valueObject); + predicates->destroy(predicates); + predicates2->destroy(predicates2); + valueBucket->destroy(valueBucket); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; + +} + +/** + * @tc.name: SUB_DDM_RDB_0400 + * @tc.desc: napi test RDB store for Update with valueBucket is NULL. + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_0400(napi_env env, napi_callback_info info) { + int errCode = 0; + OH_VBucket* valueBucket = OH_Rdb_CreateValuesBucket(); + valueBucket->putInt64(valueBucket, "id", 1); + valueBucket->putText(valueBucket, "data1", "zhangSan"); + valueBucket->putInt64(valueBucket, "data2", 12800); + valueBucket->putReal(valueBucket, "data3", 100.1); + uint8_t arr[] = {1, 2, 3, 4, 5}; + int len = sizeof(arr) / sizeof(arr[0]); + valueBucket->putBlob(valueBucket, "data4", arr, len); + valueBucket->putText(valueBucket, "data5", "ABCDEFG"); + errCode = OH_Rdb_Insert(storeTestRdbStore_, "test", valueBucket); + NAPI_ASSERT(env, errCode == 1, "OH_Rdb_Insert is fail."); + + valueBucket->clear(valueBucket); + + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + OH_VObject *valueObject = OH_Rdb_CreateValueObject(); + const char *data1Value = "zhangSan"; + valueObject->putText(valueObject, data1Value); + predicates->equalTo(predicates, "data1", valueObject); + errCode = OH_Rdb_Update(storeTestRdbStore_, valueBucket, predicates); + NAPI_ASSERT(env, errCode == -1, "OH_Rdb_Update is fail."); + + OH_Cursor *cursor = OH_Rdb_Query(storeTestRdbStore_, predicates, NULL, 0); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query is fail."); + + int rowCount = 0; + cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 1, "getRowCount is fail."); + + errCode = cursor->goToNextRow(cursor); + NAPI_ASSERT(env, errCode == 0, "goToNextRow is fail."); + + size_t size = 0; + cursor->getSize(cursor, 1, &size); + char data1Value_1[size + 1]; + cursor->getText(cursor, 1, data1Value_1, size + 1); + NAPI_ASSERT(env, strncmp(data1Value_1, "zhangSan", size) == 0, "getText is fail."); + + valueObject->destroy(valueObject); + predicates->destroy(predicates); + valueBucket->destroy(valueBucket); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} + +/** + * @tc.name: SUB_DDM_RDB_0500 + * @tc.desc: napi test RDB store for Update with wrong predicates. + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_0500(napi_env env, napi_callback_info info) { + int errCode = 0; + OH_VBucket* valueBucket = OH_Rdb_CreateValuesBucket(); + valueBucket->putInt64(valueBucket, "id", 1); + valueBucket->putText(valueBucket, "data1", "zhangSan"); + valueBucket->putInt64(valueBucket, "data2", 12800); + valueBucket->putReal(valueBucket, "data3", 100.1); + uint8_t arr[] = {1, 2, 3, 4, 5}; + int len = sizeof(arr) / sizeof(arr[0]); + valueBucket->putBlob(valueBucket, "data4", arr, len); + valueBucket->putText(valueBucket, "data5", "ABCDEFG"); + errCode = OH_Rdb_Insert(storeTestRdbStore_, "test", valueBucket); + NAPI_ASSERT(env, errCode == 1, "OH_Rdb_Insert is fail."); + + valueBucket->clear(valueBucket); + valueBucket->putText(valueBucket, "data1", "liSi"); + valueBucket->putInt64(valueBucket, "data2", 13800); + valueBucket->putReal(valueBucket, "data3", 200.1); + valueBucket->putNull(valueBucket, "data5"); + + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + OH_VObject *valueObject = OH_Rdb_CreateValueObject(); + const char *data1Value = "wangwu"; + valueObject->putText(valueObject, data1Value); + predicates->equalTo(predicates, "data1", valueObject); + errCode = OH_Rdb_Update(storeTestRdbStore_, valueBucket, predicates); + NAPI_ASSERT(env, errCode == 0, "OH_Rdb_Update is fail."); + + predicates->clear(predicates); + OH_Cursor *cursor = OH_Rdb_Query(storeTestRdbStore_, predicates, NULL, 0); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query is fail."); + + int rowCount = 0; + cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 1, "getRowCount is fail."); + + errCode = cursor->goToNextRow(cursor); + NAPI_ASSERT(env, errCode == 0, "goToNextRow is fail."); + + size_t size = 0; + cursor->getSize(cursor, 1, &size); + char data1Value_1[size + 1]; + cursor->getText(cursor, 1, data1Value_1, size + 1); + NAPI_ASSERT(env, strncmp(data1Value_1, "zhangSan", size) == 0, "getText is fail."); + + valueObject->destroy(valueObject); + predicates->destroy(predicates); + valueBucket->destroy(valueBucket); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} + +/** + * @tc.name: SUB_DDM_RDB_0600 + * @tc.desc: napi test RDB store for Query with wrong table or table is NULL. + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_0600(napi_env env, napi_callback_info info) { + int errCode = 0; + OH_VBucket* valueBucket = OH_Rdb_CreateValuesBucket(); + valueBucket->putInt64(valueBucket, "id", 1); + valueBucket->putText(valueBucket, "data1", "zhangSan"); + valueBucket->putInt64(valueBucket, "data2", 12800); + valueBucket->putReal(valueBucket, "data3", 100.1); + uint8_t arr[] = {1, 2, 3, 4, 5}; + int len = sizeof(arr) / sizeof(arr[0]); + valueBucket->putBlob(valueBucket, "data4", arr, len); + valueBucket->putText(valueBucket, "data5", "ABCDEFG"); + errCode = OH_Rdb_Insert(storeTestRdbStore_, "test", valueBucket); + NAPI_ASSERT(env, errCode == 1, "OH_Rdb_Insert is fail."); + + OH_Predicates *predicates = OH_Rdb_CreatePredicates("wrong"); + OH_VObject *valueObject = OH_Rdb_CreateValueObject(); + const char *data1Value = "zhangSan"; + valueObject->putText(valueObject, data1Value); + predicates->equalTo(predicates, "data1", valueObject); + + OH_Cursor *cursor = OH_Rdb_Query(storeTestRdbStore_, predicates, NULL, 0); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query is fail."); + + char *table = NULL; + OH_Predicates *predicates1 = OH_Rdb_CreatePredicates(table); + + OH_Cursor *cursor1 = OH_Rdb_Query(storeTestRdbStore_, predicates1, NULL, 0); + NAPI_ASSERT(env, cursor1 == NULL, "OH_Rdb_Query 2 is fail."); + + valueObject->destroy(valueObject); + predicates->destroy(predicates); + valueBucket->destroy(valueBucket); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} + +/** + * @tc.name: SUB_DDM_RDB_0700 + * @tc.desc: napi test RDB store for Query with wrong columnNames. + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_0700(napi_env env, napi_callback_info info) { + int errCode = 0; + OH_VBucket* valueBucket = OH_Rdb_CreateValuesBucket(); + valueBucket->putInt64(valueBucket, "id", 1); + valueBucket->putText(valueBucket, "data1", "zhangSan"); + valueBucket->putInt64(valueBucket, "data2", 12800); + valueBucket->putReal(valueBucket, "data3", 100.1); + uint8_t arr[] = {1, 2, 3, 4, 5}; + int len = sizeof(arr) / sizeof(arr[0]); + valueBucket->putBlob(valueBucket, "data4", arr, len); + valueBucket->putText(valueBucket, "data5", "ABCDEFG"); + errCode = OH_Rdb_Insert(storeTestRdbStore_, "test", valueBucket); + NAPI_ASSERT(env, errCode == 1, "OH_Rdb_Insert is fail."); + + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + OH_VObject *valueObject = OH_Rdb_CreateValueObject(); + const char *data1Value = "zhangSan"; + valueObject->putText(valueObject, data1Value); + predicates->equalTo(predicates, "data1", valueObject); + + const char *columnNames[] = {"data"}; + OH_Cursor *cursor = OH_Rdb_Query(storeTestRdbStore_, predicates, columnNames, 1); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query is fail."); + + int rowCount = -1; + cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == -1, "getRowCount is fail."); + + valueObject->destroy(valueObject); + predicates->destroy(predicates); + valueBucket->destroy(valueBucket); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} + +/** + * @tc.name: SUB_DDM_RDB_0800 + * @tc.desc: napi test RDB store for Query with wrong length. + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_0800(napi_env env, napi_callback_info info) { + int errCode = 0; + OH_VBucket* valueBucket = OH_Rdb_CreateValuesBucket(); + valueBucket->putInt64(valueBucket, "id", 1); + valueBucket->putText(valueBucket, "data1", "zhangSan"); + valueBucket->putInt64(valueBucket, "data2", 12800); + valueBucket->putReal(valueBucket, "data3", 100.1); + uint8_t arr[] = {1, 2, 3, 4, 5}; + int len = sizeof(arr) / sizeof(arr[0]); + valueBucket->putBlob(valueBucket, "data4", arr, len); + valueBucket->putText(valueBucket, "data5", "ABCDEFG"); + errCode = OH_Rdb_Insert(storeTestRdbStore_, "test", valueBucket); + NAPI_ASSERT(env, errCode == 1, "OH_Rdb_Insert is fail."); + + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + OH_VObject *valueObject = OH_Rdb_CreateValueObject(); + const char *data1Value = "zhangSan"; + valueObject->putText(valueObject, data1Value); + predicates->equalTo(predicates, "data1", valueObject); + + OH_Cursor *cursor = OH_Rdb_Query(storeTestRdbStore_, predicates, NULL, 1); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query is fail."); + + int rowCount = -1; + cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 1, "getRowCount is fail."); + + valueObject->destroy(valueObject); + predicates->destroy(predicates); + valueBucket->destroy(valueBucket); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} + +/** + * @tc.name: SUB_DDM_RDB_0900 + * @tc.desc: napi test RDB store for Delete、ExecuteQuery. + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_0900(napi_env env, napi_callback_info info) { + int errCode = 0; + OH_VBucket* valueBucket = OH_Rdb_CreateValuesBucket(); + valueBucket->putInt64(valueBucket, "id", 1); + valueBucket->putText(valueBucket, "data1", "zhangSan"); + valueBucket->putInt64(valueBucket, "data2", 12800); + valueBucket->putReal(valueBucket, "data3", 100.1); + uint8_t arr[] = {1, 2, 3, 4, 5}; + int len = sizeof(arr) / sizeof(arr[0]); + valueBucket->putBlob(valueBucket, "data4", arr, len); + valueBucket->putText(valueBucket, "data5", "ABCDEFG"); + errCode = OH_Rdb_Insert(storeTestRdbStore_, "test", valueBucket); + NAPI_ASSERT(env, errCode == 1, "OH_Rdb_Insert is fail."); + + valueBucket->clear(valueBucket); + valueBucket->putInt64(valueBucket, "id", 2); + valueBucket->putText(valueBucket, "data1", "liSi"); + valueBucket->putInt64(valueBucket, "data2", 13800); + valueBucket->putReal(valueBucket, "data3", 200.1); + valueBucket->putText(valueBucket, "data5", "ABCDEFGH"); + errCode = OH_Rdb_Insert(storeTestRdbStore_, "test", valueBucket); + NAPI_ASSERT(env, errCode == 2, "OH_Rdb_Insert 2 is fail."); + + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + OH_VObject *valueObject = OH_Rdb_CreateValueObject(); + const char *data1Value = "zhangSan"; + valueObject->putText(valueObject, data1Value); + predicates->equalTo(predicates, "data1", valueObject); + errCode = OH_Rdb_Delete(storeTestRdbStore_, predicates); + NAPI_ASSERT(env, errCode == 1, "OH_Rdb_Delete is fail."); + + char querySql[] = "SELECT * FROM test"; + OH_Cursor *cursor = OH_Rdb_ExecuteQuery(storeTestRdbStore_, querySql); + + int rowCount = 0; + cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 1, "getRowCount is fail."); + + errCode = cursor->goToNextRow(cursor); + NAPI_ASSERT(env, errCode == 0, "goToNextRow is fail."); + + size_t size = 0; + cursor->getSize(cursor, 1, &size); + char data1Value_1[size + 1]; + cursor->getText(cursor, 1, data1Value_1, size + 1); + NAPI_ASSERT(env, strncmp(data1Value_1, "liSi", 4) == 0, "getText is fail."); + + int64_t data2Value; + cursor->getInt64(cursor, 2, &data2Value); + NAPI_ASSERT(env, data2Value == 13800, "getInt64 is fail."); + + double data3Value; + cursor->getReal(cursor, 3, &data3Value); + NAPI_ASSERT(env, data3Value == 200.1, "getReal is fail."); + + bool isNull = false; + cursor->isNull(cursor, 4, &isNull); + NAPI_ASSERT(env, isNull == true, "isNull is fail."); + + cursor->getSize(cursor, 5, &size); + char data5Value[size + 1]; + cursor->getText(cursor, 5, data5Value, size + 1); + NAPI_ASSERT(env, strncmp(data5Value, "ABCDEFGH", 8) == 0, "getText is fail."); + + valueObject->destroy(valueObject); + valueBucket->destroy(valueBucket); + predicates->destroy(predicates); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} + +/** + * @tc.name: SUB_DDM_RDB_1000 + * @tc.desc: napi test RDB store for querysql is NULL. + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_1000(napi_env env, napi_callback_info info) { + int errCode = 0; + OH_VBucket* valueBucket = OH_Rdb_CreateValuesBucket(); + valueBucket->putInt64(valueBucket, "id", 1); + valueBucket->putText(valueBucket, "data1", "zhangSan"); + valueBucket->putInt64(valueBucket, "data2", 12800); + valueBucket->putReal(valueBucket, "data3", 100.1); + uint8_t arr[] = {1, 2, 3, 4, 5}; + int len = sizeof(arr) / sizeof(arr[0]); + valueBucket->putBlob(valueBucket, "data4", arr, len); + valueBucket->putText(valueBucket, "data5", "ABCDEFG"); + errCode = OH_Rdb_Insert(storeTestRdbStore_, "test", valueBucket); + NAPI_ASSERT(env, errCode == 1, "OH_Rdb_Insert is fail."); + + char *querySql = NULL; + OH_Cursor *cursor = OH_Rdb_ExecuteQuery(storeTestRdbStore_, querySql); + NAPI_ASSERT(env, cursor == NULL, "OH_Rdb_ExecuteQuery is fail."); + + errCode = valueBucket->destroy(valueBucket); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} + +/** + * @tc.name: SUB_DDM_RDB_1100 + * @tc.desc: napi test RDB store for Delete with wrong table or table is NULL. + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_1100(napi_env env, napi_callback_info info) { + int errCode = 0; + OH_VBucket* valueBucket = OH_Rdb_CreateValuesBucket(); + valueBucket->putInt64(valueBucket, "id", 1); + valueBucket->putText(valueBucket, "data1", "zhangSan"); + valueBucket->putInt64(valueBucket, "data2", 12800); + valueBucket->putReal(valueBucket, "data3", 100.1); + uint8_t arr[] = {1, 2, 3, 4, 5}; + int len = sizeof(arr) / sizeof(arr[0]); + valueBucket->putBlob(valueBucket, "data4", arr, len); + valueBucket->putText(valueBucket, "data5", "ABCDEFG"); + errCode = OH_Rdb_Insert(storeTestRdbStore_, "test", valueBucket); + NAPI_ASSERT(env, errCode == 1, "OH_Rdb_Insert is fail."); + + + valueBucket->clear(valueBucket); + valueBucket->putInt64(valueBucket, "id", 2); + valueBucket->putText(valueBucket, "data1", "liSi"); + valueBucket->putInt64(valueBucket, "data2", 13800); + valueBucket->putReal(valueBucket, "data3", 200.1); + valueBucket->putText(valueBucket, "data5", "ABCDEFGH"); + errCode = OH_Rdb_Insert(storeTestRdbStore_, "test", valueBucket); + NAPI_ASSERT(env, errCode == 2, "OH_Rdb_Insert is fail."); + + OH_Predicates *predicates = OH_Rdb_CreatePredicates("wrong"); + OH_VObject *valueObject = OH_Rdb_CreateValueObject(); + const char *data1Value = "zhangSan"; + valueObject->putText(valueObject, data1Value); + predicates->equalTo(predicates, "data1", valueObject); + errCode = OH_Rdb_Delete(storeTestRdbStore_, predicates); + NAPI_ASSERT(env, errCode == -1, "OH_Rdb_Delete is fail."); + + OH_Predicates *predicates1 = OH_Rdb_CreatePredicates("test"); + OH_Cursor *cursor = OH_Rdb_Query(storeTestRdbStore_, predicates1, NULL, 0); + + int rowCount = 0; + cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 2, "getRowCount is fail."); + + char *table = NULL; + OH_Predicates *predicates2 = OH_Rdb_CreatePredicates(table); + NAPI_ASSERT(env, predicates2 == NULL, "OH_Rdb_CreatePredicates is fail."); + + errCode = OH_Rdb_Delete(storeTestRdbStore_, predicates2); + NAPI_ASSERT(env, errCode == 14800001, "OH_Rdb_Delete is fail."); + + OH_Cursor *cursor1 = OH_Rdb_Query(storeTestRdbStore_, predicates1, NULL, 0); + int rowCount1 = 0; + cursor1->getRowCount(cursor1, &rowCount1); + NAPI_ASSERT(env, rowCount1 == 2, "getRowCount is fail."); + + valueObject->destroy(valueObject); + valueBucket->destroy(valueBucket); + predicates->destroy(predicates); + errCode = cursor->destroy(cursor); + cursor1->destroy(cursor1); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} + + +/** + * @tc.name: SUB_DDM_RDB_1200 + * @tc.desc: napi test RDB store for Delete with wrong predicates. + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_1200(napi_env env, napi_callback_info info) { + int errCode = 0; + OH_VBucket* valueBucket = OH_Rdb_CreateValuesBucket(); + valueBucket->putInt64(valueBucket, "id", 1); + valueBucket->putText(valueBucket, "data1", "zhangSan"); + valueBucket->putInt64(valueBucket, "data2", 12800); + valueBucket->putReal(valueBucket, "data3", 100.1); + uint8_t arr[] = {1, 2, 3, 4, 5}; + int len = sizeof(arr) / sizeof(arr[0]); + valueBucket->putBlob(valueBucket, "data4", arr, len); + valueBucket->putText(valueBucket, "data5", "ABCDEFG"); + errCode = OH_Rdb_Insert(storeTestRdbStore_, "test", valueBucket); + NAPI_ASSERT(env, errCode == 1, "OH_Rdb_Insert is fail."); + + valueBucket->clear(valueBucket); + valueBucket->putInt64(valueBucket, "id", 2); + valueBucket->putText(valueBucket, "data1", "liSi"); + valueBucket->putInt64(valueBucket, "data2", 13800); + valueBucket->putReal(valueBucket, "data3", 200.1); + valueBucket->putText(valueBucket, "data5", "ABCDEFGH"); + errCode = OH_Rdb_Insert(storeTestRdbStore_, "test", valueBucket); + NAPI_ASSERT(env, errCode == 2, "OH_Rdb_Insert is fail."); + + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + OH_VObject *valueObject = OH_Rdb_CreateValueObject(); + const char *data1Value = "wangwu"; + valueObject->putText(valueObject, data1Value); + predicates->equalTo(predicates, "data1", valueObject); + errCode = OH_Rdb_Delete(storeTestRdbStore_, predicates); + NAPI_ASSERT(env, errCode == 0, "OH_Rdb_Delete is fail."); + + predicates->clear(predicates); + OH_Cursor *cursor = OH_Rdb_Query(storeTestRdbStore_, predicates, NULL, 0); + int rowCount = 0; + cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 2, "getRowCount is fail."); + + valueObject->destroy(valueObject); + valueBucket->destroy(valueBucket); + predicates->destroy(predicates); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} + + + +/** + * @tc.name: SUB_DDM_RDB_1300 + * @tc.desc: napi test RDB store for Delete multiple. + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_1300(napi_env env, napi_callback_info info) { + int errCode = 0; + OH_VBucket* valueBucket = OH_Rdb_CreateValuesBucket(); + valueBucket->putInt64(valueBucket, "id", 1); + valueBucket->putText(valueBucket, "data1", "zhangSan"); + valueBucket->putInt64(valueBucket, "data2", 12800); + valueBucket->putReal(valueBucket, "data3", 100.1); + uint8_t arr[] = {1, 2, 3, 4, 5}; + int len = sizeof(arr) / sizeof(arr[0]); + valueBucket->putBlob(valueBucket, "data4", arr, len); + valueBucket->putText(valueBucket, "data5", "ABCDEFG"); + errCode = OH_Rdb_Insert(storeTestRdbStore_, "test", valueBucket); + NAPI_ASSERT(env, errCode == 1, "OH_Rdb_Insert is fail."); + + valueBucket->clear(valueBucket); + valueBucket->putInt64(valueBucket, "id", 2); + valueBucket->putText(valueBucket, "data1", "zhangSan"); + valueBucket->putInt64(valueBucket, "data2", 13800); + valueBucket->putReal(valueBucket, "data3", 200.1); + valueBucket->putText(valueBucket, "data5", "ABCDEFGH"); + errCode = OH_Rdb_Insert(storeTestRdbStore_, "test", valueBucket); + NAPI_ASSERT(env, errCode == 2, "OH_Rdb_Insert is fail."); + + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + OH_VObject *valueObject = OH_Rdb_CreateValueObject(); + const char *data1Value = "zhangSan"; + valueObject->putText(valueObject, data1Value); + predicates->equalTo(predicates, "data1", valueObject); + errCode = OH_Rdb_Delete(storeTestRdbStore_, predicates); + NAPI_ASSERT(env, errCode == 2, "OH_Rdb_Delete is fail."); + + predicates->clear(predicates); + OH_Cursor *cursor = OH_Rdb_Query(storeTestRdbStore_, predicates, NULL, 0); + int rowCount = 0; + cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 0, "getRowCount is fail."); + + valueObject->destroy(valueObject); + valueBucket->destroy(valueBucket); + predicates->destroy(predicates); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} + + +/** + * @tc.name: SUB_DDM_RDB_1400 + * @tc.desc: napi test RDB store for Transaction、Commit. + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_1400(napi_env env, napi_callback_info info) { + int errCode = 0; + OH_VBucket* valueBucket = OH_Rdb_CreateValuesBucket(); + valueBucket->putInt64(valueBucket, "id", 1); + valueBucket->putText(valueBucket, "data1", "zhangSan"); + valueBucket->putInt64(valueBucket, "data2", 12800); + valueBucket->putReal(valueBucket, "data3", 100.1); + uint8_t arr[] = {1, 2, 3, 4, 5}; + int len = sizeof(arr) / sizeof(arr[0]); + valueBucket->putBlob(valueBucket, "data4", arr, len); + valueBucket->putText(valueBucket, "data5", "ABCDEFG"); + errCode = OH_Rdb_Insert(storeTestRdbStore_, "test", valueBucket); + NAPI_ASSERT(env, errCode == 1, "OH_Rdb_Insert is fail."); + + valueBucket->clear(valueBucket); + valueBucket->putInt64(valueBucket, "id", 2); + valueBucket->putText(valueBucket, "data1", "liSi"); + valueBucket->putInt64(valueBucket, "data2", 13800); + valueBucket->putReal(valueBucket, "data3", 200.1); + valueBucket->putText(valueBucket, "data5", "ABCDEFGH"); + errCode = OH_Rdb_Insert(storeTestRdbStore_, "test", valueBucket); + NAPI_ASSERT(env, errCode == 2, "OH_Rdb_Insert is fail."); + + OH_Rdb_Commit(storeTestRdbStore_); + + char querySql[] = "SELECT * FROM test"; + OH_Cursor *cursor = OH_Rdb_ExecuteQuery(storeTestRdbStore_, querySql); + + int rowCount = 0; + cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 2, "getRowCount is fail."); + + valueBucket->destroy(valueBucket); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} + +/** + * @tc.name: SUB_DDM_RDB_1500 + * @tc.desc: napi test RDB store for Transaction、RollBack. + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_1500(napi_env env, napi_callback_info info) { + int errCode = 0; + OH_Rdb_BeginTransaction(storeTestRdbStore_); + + OH_VBucket* valueBucket = OH_Rdb_CreateValuesBucket(); + valueBucket->putInt64(valueBucket, "id", 1); + valueBucket->putText(valueBucket, "data1", "zhangSan"); + valueBucket->putInt64(valueBucket, "data2", 12800); + valueBucket->putReal(valueBucket, "data3", 100.1); + uint8_t arr[] = {1, 2, 3, 4, 5}; + int len = sizeof(arr) / sizeof(arr[0]); + valueBucket->putBlob(valueBucket, "data4", arr, len); + valueBucket->putText(valueBucket, "data5", "ABCDEFG"); + errCode = OH_Rdb_Insert(storeTestRdbStore_, "test", valueBucket); + NAPI_ASSERT(env, errCode == 1, "OH_Rdb_Insert is fail."); + + + valueBucket->clear(valueBucket); + valueBucket->putInt64(valueBucket, "id", 2); + valueBucket->putText(valueBucket, "data1", "liSi"); + valueBucket->putInt64(valueBucket, "data2", 13800); + valueBucket->putReal(valueBucket, "data3", 200.1); + valueBucket->putText(valueBucket, "data5", "ABCDEFGH"); + errCode = OH_Rdb_Insert(storeTestRdbStore_, "test", valueBucket); + NAPI_ASSERT(env, errCode == 2, "OH_Rdb_Insert is fail."); + + OH_Rdb_RollBack(storeTestRdbStore_); + + char querySql[] = "SELECT * FROM test"; + OH_Cursor *cursor = OH_Rdb_ExecuteQuery(storeTestRdbStore_, querySql); + + int rowCount = 0; + cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 0, "getRowCount is fail."); + + valueBucket->destroy(valueBucket); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} + + +/** + * @tc.name: SUB_DDM_RDB_1600 + * @tc.desc: napi test RDB store for Transaction、Commit. + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_1600(napi_env env, napi_callback_info info) { + int errCode = 0; + OH_Rdb_BeginTransaction(storeTestRdbStore_); + + OH_VBucket* valueBucket = OH_Rdb_CreateValuesBucket(); + valueBucket->putInt64(valueBucket, "id", 1); + valueBucket->putText(valueBucket, "data1", "zhangSan"); + valueBucket->putInt64(valueBucket, "data2", 12800); + valueBucket->putReal(valueBucket, "data3", 100.1); + uint8_t arr[] = {1, 2, 3, 4, 5}; + int len = sizeof(arr) / sizeof(arr[0]); + valueBucket->putBlob(valueBucket, "data4", arr, len); + valueBucket->putText(valueBucket, "data5", "ABCDEFG"); + errCode = OH_Rdb_Insert(storeTestRdbStore_, "test", valueBucket); + NAPI_ASSERT(env, errCode == 1, "OH_Rdb_Insert is fail."); + + OH_Rdb_BeginTransaction(storeTestRdbStore_); + + valueBucket->clear(valueBucket); + valueBucket->putInt64(valueBucket, "id", 2); + valueBucket->putText(valueBucket, "data1", "liSi"); + valueBucket->putInt64(valueBucket, "data2", 13800); + valueBucket->putReal(valueBucket, "data3", 200.1); + valueBucket->putText(valueBucket, "data5", "ABCDEFGH"); + errCode = OH_Rdb_Insert(storeTestRdbStore_, "test", valueBucket); + NAPI_ASSERT(env, errCode == 2, "OH_Rdb_Insert is fail."); + + OH_Rdb_Commit(storeTestRdbStore_); + OH_Rdb_Commit(storeTestRdbStore_); + + char querySql[] = "SELECT * FROM test"; + OH_Cursor *cursor = OH_Rdb_ExecuteQuery(storeTestRdbStore_, querySql); + + int rowCount = 0; + cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 2, "getRowCount is fail."); + + valueBucket->destroy(valueBucket); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} + + +/** + * @tc.name: SUB_DDM_RDB_1700 + * @tc.desc: napi test RDB store for Transaction、Commit. + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_1700(napi_env env, napi_callback_info info) { + int errCode = 0; + OH_Rdb_BeginTransaction(storeTestRdbStore_); + + OH_VBucket* valueBucket = OH_Rdb_CreateValuesBucket(); + valueBucket->putInt64(valueBucket, "id", 1); + valueBucket->putText(valueBucket, "data1", "zhangSan"); + valueBucket->putInt64(valueBucket, "data2", 12800); + valueBucket->putReal(valueBucket, "data3", 100.1); + uint8_t arr[] = {1, 2, 3, 4, 5}; + int len = sizeof(arr) / sizeof(arr[0]); + valueBucket->putBlob(valueBucket, "data4", arr, len); + valueBucket->putText(valueBucket, "data5", "ABCDEFG"); + errCode = OH_Rdb_Insert(storeTestRdbStore_, "test", valueBucket); + NAPI_ASSERT(env, errCode == 1, "OH_Rdb_Insert is fail."); + + OH_Rdb_BeginTransaction(storeTestRdbStore_); + + valueBucket->clear(valueBucket); + valueBucket->putInt64(valueBucket, "id", 2); + valueBucket->putText(valueBucket, "data1", "liSi"); + valueBucket->putInt64(valueBucket, "data2", 13800); + valueBucket->putReal(valueBucket, "data3", 200.1); + valueBucket->putText(valueBucket, "data5", "ABCDEFGH"); + errCode = OH_Rdb_Insert(storeTestRdbStore_, "test", valueBucket); + NAPI_ASSERT(env, errCode == 2, "OH_Rdb_Insert is fail."); + + OH_Rdb_RollBack(storeTestRdbStore_); + OH_Rdb_Commit(storeTestRdbStore_); + + char querySql[] = "SELECT * FROM test"; + OH_Cursor *cursor = OH_Rdb_ExecuteQuery(storeTestRdbStore_, querySql); + + int rowCount = 0; + cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 1, "getRowCount is fail."); + + valueBucket->destroy(valueBucket); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} + + +/** + * @tc.name: SUB_DDM_RDB_1800 + * @tc.desc: napi test RDB store for GetVersion、SetVersion. + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_1800(napi_env env, napi_callback_info info) { + int errCode = 0; + int version = 0; + int setVersion = 3; + errCode = OH_Rdb_GetVersion(storeTestRdbStore_, &version); + NAPI_ASSERT(env, errCode == 0, "OH_Rdb_GetVersion is fail."); + NAPI_ASSERT(env, version == 0, "OH_Rdb_GetVersion is fail."); + + errCode = OH_Rdb_SetVersion(storeTestRdbStore_, setVersion); + errCode = OH_Rdb_GetVersion(storeTestRdbStore_, &version); + NAPI_ASSERT(env, errCode == 0, "OH_Rdb_SetVersion is fail."); + NAPI_ASSERT(env, version == 3, "OH_Rdb_SetVersion is fail."); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} + + +/** + * @tc.name: SUB_DDM_RDB_1900 + * @tc.desc: napi test RDB store for Query with wrong columnNames. + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_1900(napi_env env, napi_callback_info info) { + int errCode = 0; + OH_VBucket* valueBucket = OH_Rdb_CreateValuesBucket(); + valueBucket->putInt64(valueBucket, "id", 1); + valueBucket->putText(valueBucket, "data1", "zhangSan"); + valueBucket->putInt64(valueBucket, "data2", 12800); + valueBucket->putReal(valueBucket, "data3", 100.1); + uint8_t arr[] = {1, 2, 3, 4, 5}; + int len = sizeof(arr) / sizeof(arr[0]); + valueBucket->putBlob(valueBucket, "data4", arr, len); + valueBucket->putText(valueBucket, "data5", "ABCDEFG"); + errCode = OH_Rdb_Insert(storeTestRdbStore_, "test", valueBucket); + NAPI_ASSERT(env, errCode == 1, "OH_Rdb_Insert is fail."); + + + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + OH_VObject *valueObject = OH_Rdb_CreateValueObject(); + const char *data1Value = "zhangSan"; + valueObject->putText(valueObject, data1Value); + predicates->equalTo(predicates, "data1", valueObject); + + const char *columnNames[] = {"data1"}; + OH_Cursor *cursor = OH_Rdb_Query(storeTestRdbStore_, predicates, columnNames, 1); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query is fail."); + + int rowCount = -1; + cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 1, "getRowCount is fail."); + + valueObject->destroy(valueObject); + predicates->destroy(predicates); + valueBucket->destroy(valueBucket); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} + + +/** + * @tc.name: SUB_DDM_RDB_2000 + * @tc.desc: napi test RDB store for Update with wrong columnNames. + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_2000(napi_env env, napi_callback_info info) { + int errCode = 0; + OH_VBucket* valueBucket = OH_Rdb_CreateValuesBucket(); + valueBucket->putInt64(valueBucket, "id", 1); + valueBucket->putText(valueBucket, "data1", "zhangSan"); + valueBucket->putInt64(valueBucket, "data2", 12800); + valueBucket->putReal(valueBucket, "data3", 100.1); + uint8_t arr[] = {1, 2, 3, 4, 5}; + int len = sizeof(arr) / sizeof(arr[0]); + valueBucket->putBlob(valueBucket, "data4", arr, len); + valueBucket->putText(valueBucket, "data5", "ABCDEFG"); + errCode = OH_Rdb_Insert(storeTestRdbStore_, "test", valueBucket); + NAPI_ASSERT(env, errCode == 1, "OH_Rdb_Insert is fail."); + + valueBucket->clear(valueBucket); + valueBucket->putText(valueBucket, "data1", "liSi"); + valueBucket->putInt64(valueBucket, "data2", 13800); + valueBucket->putReal(valueBucket, "data3", 200.1); + valueBucket->putNull(valueBucket, "data5"); + + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + OH_VObject *valueObject = OH_Rdb_CreateValueObject(); + const char *data1Value = "zhangSan"; + valueObject->putText(valueObject, data1Value); + predicates->equalTo(predicates, "data", valueObject); + errCode = OH_Rdb_Update(storeTestRdbStore_, valueBucket, predicates); + NAPI_ASSERT(env, errCode == -1, "OH_Rdb_Update is fail."); + + predicates->clear(predicates); + OH_Cursor *cursor = OH_Rdb_Query(storeTestRdbStore_, predicates, NULL, 0); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query is fail."); + + int rowCount = 0; + cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 1, "getRowCount is fail."); + + errCode = cursor->goToNextRow(cursor); + NAPI_ASSERT(env, errCode == 0, "goToNextRow is fail."); + + size_t size = 0; + cursor->getSize(cursor, 1, &size); + char data1Value_1[size + 1]; + cursor->getText(cursor, 1, data1Value_1, size + 1); + NAPI_ASSERT(env, strncmp(data1Value_1, "zhangSan", size) == 0, "getText is fail."); + + valueObject->destroy(valueObject); + predicates->destroy(predicates); + valueBucket->destroy(valueBucket); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} + + +/** + * @tc.name: SUB_DDM_RDB_2100 + * @tc.desc: napi test RDB store for Delete with wrong columnNames. + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_2100(napi_env env, napi_callback_info info) { + int errCode = 0; + OH_VBucket* valueBucket = OH_Rdb_CreateValuesBucket(); + valueBucket->putInt64(valueBucket, "id", 1); + valueBucket->putText(valueBucket, "data1", "zhangSan"); + valueBucket->putInt64(valueBucket, "data2", 12800); + valueBucket->putReal(valueBucket, "data3", 100.1); + uint8_t arr[] = {1, 2, 3, 4, 5}; + int len = sizeof(arr) / sizeof(arr[0]); + valueBucket->putBlob(valueBucket, "data4", arr, len); + valueBucket->putText(valueBucket, "data5", "ABCDEFG"); + errCode = OH_Rdb_Insert(storeTestRdbStore_, "test", valueBucket); + NAPI_ASSERT(env, errCode == 1, "OH_Rdb_Insert is fail."); + + valueBucket->clear(valueBucket); + valueBucket->putInt64(valueBucket, "id", 2); + valueBucket->putText(valueBucket, "data1", "liSi"); + valueBucket->putInt64(valueBucket, "data2", 13800); + valueBucket->putReal(valueBucket, "data3", 200.1); + valueBucket->putText(valueBucket, "data5", "ABCDEFGH"); + errCode = OH_Rdb_Insert(storeTestRdbStore_, "test", valueBucket); + NAPI_ASSERT(env, errCode == 2, "OH_Rdb_Insert is fail."); + + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + OH_VObject *valueObject = OH_Rdb_CreateValueObject(); + const char *data1Value = "zhangSan"; + valueObject->putText(valueObject, data1Value); + predicates->equalTo(predicates, "data", valueObject); + errCode = OH_Rdb_Delete(storeTestRdbStore_, predicates); + NAPI_ASSERT(env, errCode == -1, "OH_Rdb_Delete is fail."); + + predicates->clear(predicates); + OH_Cursor *cursor = OH_Rdb_Query(storeTestRdbStore_, predicates, NULL, 0); + int rowCount = 0; + cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 2, "getRowCount is fail."); + + valueObject->destroy(valueObject); + valueBucket->destroy(valueBucket); + predicates->destroy(predicates); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} + + +/** + * @tc.name: SUB_DDM_RDB_2200 + * @tc.desc: napi test RDB store for Query with wrong length. + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_2200(napi_env env, napi_callback_info info) { + int errCode = 0; + OH_VBucket* valueBucket = OH_Rdb_CreateValuesBucket(); + valueBucket->putInt64(valueBucket, "id", 1); + valueBucket->putText(valueBucket, "data1", "zhangSan"); + valueBucket->putInt64(valueBucket, "data2", 12800); + valueBucket->putReal(valueBucket, "data3", 100.1); + uint8_t arr[] = {1, 2, 3, 4, 5}; + int len = sizeof(arr) / sizeof(arr[0]); + valueBucket->putBlob(valueBucket, "data4", arr, len); + valueBucket->putText(valueBucket, "data5", "ABCDEFG"); + errCode = OH_Rdb_Insert(storeTestRdbStore_, "test", valueBucket); + NAPI_ASSERT(env, errCode == 1, "OH_Rdb_Insert is fail."); + + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + OH_VObject *valueObject = OH_Rdb_CreateValueObject(); + const char *data1Value = "zhangSan"; + valueObject->putText(valueObject, data1Value); + predicates->equalTo(predicates, "data1", valueObject); + + OH_Cursor *cursor = OH_Rdb_Query(storeTestRdbStore_, predicates, NULL, 2); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query is fail."); + + int rowCount = -1; + cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 1, "getRowCount is fail."); + + valueObject->destroy(valueObject); + predicates->destroy(predicates); + valueBucket->destroy(valueBucket); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} + + +/** + * @tc.name: SUB_DDM_RDB_2300 + * @tc.desc: napi test RDB store for Query with wrong length. + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_2300(napi_env env, napi_callback_info info) { + int errCode = 0; + OH_VBucket* valueBucket = OH_Rdb_CreateValuesBucket(); + valueBucket->putInt64(valueBucket, "id", 1); + valueBucket->putText(valueBucket, "data1", "zhangSan"); + valueBucket->putInt64(valueBucket, "data2", 12800); + valueBucket->putReal(valueBucket, "data3", 100.1); + uint8_t arr[] = {1, 2, 3, 4, 5}; + int len = sizeof(arr) / sizeof(arr[0]); + valueBucket->putBlob(valueBucket, "data4", arr, len); + valueBucket->putText(valueBucket, "data5", "ABCDEFG"); + errCode = OH_Rdb_Insert(storeTestRdbStore_, "test", valueBucket); + NAPI_ASSERT(env, errCode == 1, "OH_Rdb_Insert is fail."); + + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + OH_VObject *valueObject = OH_Rdb_CreateValueObject(); + const char *data1Value = "zhangSan"; + valueObject->putText(valueObject, data1Value); + predicates->equalTo(predicates, "data1", valueObject); + + OH_Cursor *cursor = OH_Rdb_Query(storeTestRdbStore_, predicates, NULL, 7); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query is fail."); + + int rowCount = -1; + cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 1, "getRowCount is fail."); + + valueObject->destroy(valueObject); + predicates->destroy(predicates); + valueBucket->destroy(valueBucket); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} + + +/** + * @tc.name: SUB_DDM_RDB_2400 + * @tc.desc: napi test RDB store for Query with wrong length. + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_2400(napi_env env, napi_callback_info info) { + int errCode = 0; + OH_VBucket* valueBucket = OH_Rdb_CreateValuesBucket(); + valueBucket->putInt64(valueBucket, "id", 1); + valueBucket->putText(valueBucket, "data1", "zhangSan"); + valueBucket->putInt64(valueBucket, "data2", 12800); + valueBucket->putReal(valueBucket, "data3", 100.1); + uint8_t arr[] = {1, 2, 3, 4, 5}; + int len = sizeof(arr) / sizeof(arr[0]); + valueBucket->putBlob(valueBucket, "data4", arr, len); + valueBucket->putText(valueBucket, "data5", "ABCDEFG"); + errCode = OH_Rdb_Insert(storeTestRdbStore_, "test", valueBucket); + NAPI_ASSERT(env, errCode == 1, "OH_Rdb_Insert is fail."); + + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + OH_VObject *valueObject = OH_Rdb_CreateValueObject(); + const char *data1Value = "zhangSan"; + valueObject->putText(valueObject, data1Value); + predicates->equalTo(predicates, "data1", valueObject); + + OH_Cursor *cursor = OH_Rdb_Query(storeTestRdbStore_, predicates, NULL, 1); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query is fail."); + + int rowCount = -1; + cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 1, "getRowCount is fail."); + + valueObject->destroy(valueObject); + predicates->destroy(predicates); + valueBucket->destroy(valueBucket); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} + + +/** + * @tc.name: SUB_DDM_RDB_2500 + * @tc.desc: napi test RDB store for Query with wrong length. + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_2500(napi_env env, napi_callback_info info) { + int errCode = 0; + OH_VBucket* valueBucket = OH_Rdb_CreateValuesBucket(); + valueBucket->putInt64(valueBucket, "id", 1); + valueBucket->putText(valueBucket, "data1", "zhangSan"); + valueBucket->putInt64(valueBucket, "data2", 12800); + valueBucket->putReal(valueBucket, "data3", 100.1); + uint8_t arr[] = {1, 2, 3, 4, 5}; + int len = sizeof(arr) / sizeof(arr[0]); + valueBucket->putBlob(valueBucket, "data4", arr, len); + valueBucket->putText(valueBucket, "data5", "ABCDEFG"); + errCode = OH_Rdb_Insert(storeTestRdbStore_, "test", valueBucket); + NAPI_ASSERT(env, errCode == 1, "OH_Rdb_Insert is fail."); + + + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + OH_VObject *valueObject = OH_Rdb_CreateValueObject(); + const char *data1Value = "zhangSan"; + valueObject->putText(valueObject, data1Value); + predicates->equalTo(predicates, "data1", valueObject); + + const char *columnNames[] = {"data1","data2","data3","data4"}; + OH_Cursor *cursor = OH_Rdb_Query(storeTestRdbStore_, predicates, columnNames, 0); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query is fail."); + + int rowCount = -1; + cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 1, "getRowCount is fail."); + + valueObject->destroy(valueObject); + predicates->destroy(predicates); + valueBucket->destroy(valueBucket); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} + + +/** + * @tc.name: SUB_DDM_RDB_2600 + * @tc.desc: napi test RDB store for Query with wrong length. + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_2600(napi_env env, napi_callback_info info) { + int errCode = 0; + OH_VBucket* valueBucket = OH_Rdb_CreateValuesBucket(); + valueBucket->putInt64(valueBucket, "id", 1); + valueBucket->putText(valueBucket, "data1", "zhangSan"); + valueBucket->putInt64(valueBucket, "data2", 12800); + valueBucket->putReal(valueBucket, "data3", 100.1); + uint8_t arr[] = {1, 2, 3, 4, 5}; + int len = sizeof(arr) / sizeof(arr[0]); + valueBucket->putBlob(valueBucket, "data4", arr, len); + valueBucket->putText(valueBucket, "data5", "ABCDEFG"); + errCode = OH_Rdb_Insert(storeTestRdbStore_, "test", valueBucket); + NAPI_ASSERT(env, errCode == 1, "OH_Rdb_Insert is fail."); + + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + OH_VObject *valueObject = OH_Rdb_CreateValueObject(); + const char *data1Value = "zhangSan"; + valueObject->putText(valueObject, data1Value); + predicates->equalTo(predicates, "data1", valueObject); + + const char *columnNames[] = {"data1","data2","data3","data4"}; + OH_Cursor *cursor = OH_Rdb_Query(storeTestRdbStore_, predicates, columnNames, 1); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query is fail."); + + int rowCount = -1; + cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 1, "getRowCount is fail."); + + valueObject->destroy(valueObject); + predicates->destroy(predicates); + valueBucket->destroy(valueBucket); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} + + +/** + * @tc.name: SUB_DDM_RDB_2700 + * @tc.desc: napi test RDB store for Query with wrong length. + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_2700(napi_env env, napi_callback_info info) { + int errCode = 0; + OH_VBucket* valueBucket = OH_Rdb_CreateValuesBucket(); + valueBucket->putInt64(valueBucket, "id", 1); + valueBucket->putText(valueBucket, "data1", "zhangSan"); + valueBucket->putInt64(valueBucket, "data2", 12800); + valueBucket->putReal(valueBucket, "data3", 100.1); + uint8_t arr[] = {1, 2, 3, 4, 5}; + int len = sizeof(arr) / sizeof(arr[0]); + valueBucket->putBlob(valueBucket, "data4", arr, len); + valueBucket->putText(valueBucket, "data5", "ABCDEFG"); + errCode = OH_Rdb_Insert(storeTestRdbStore_, "test", valueBucket); + NAPI_ASSERT(env, errCode == 1, "OH_Rdb_Insert is fail."); + + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + OH_VObject *valueObject = OH_Rdb_CreateValueObject(); + const char *data1Value = "zhangSan"; + valueObject->putText(valueObject, data1Value); + predicates->equalTo(predicates, "data1", valueObject); + + const char *columnNames[] = {"data1","data2","data3","data4"}; + OH_Cursor *cursor = OH_Rdb_Query(storeTestRdbStore_, predicates, columnNames, 2); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query is fail."); + int rowCount = -1; + cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 1, "getRowCount is fail."); + + valueObject->destroy(valueObject); + predicates->destroy(predicates); + valueBucket->destroy(valueBucket); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} + +/** + * @tc.name: SUB_DDM_RDB_2800 + * @tc.desc: napi test RDB store for Query with wrong length. + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_2800(napi_env env, napi_callback_info info) { + int errCode = 0; + OH_VBucket* valueBucket = OH_Rdb_CreateValuesBucket(); + valueBucket->putInt64(valueBucket, "id", 1); + valueBucket->putText(valueBucket, "data1", "zhangSan"); + valueBucket->putInt64(valueBucket, "data2", 12800); + valueBucket->putReal(valueBucket, "data3", 100.1); + uint8_t arr[] = {1, 2, 3, 4, 5}; + int len = sizeof(arr) / sizeof(arr[0]); + valueBucket->putBlob(valueBucket, "data4", arr, len); + valueBucket->putText(valueBucket, "data5", "ABCDEFG"); + errCode = OH_Rdb_Insert(storeTestRdbStore_, "test", valueBucket); + NAPI_ASSERT(env, errCode == 1, "OH_Rdb_Insert is fail."); + + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + OH_VObject *valueObject = OH_Rdb_CreateValueObject(); + const char *data1Value = "zhangSan"; + valueObject->putText(valueObject, data1Value); + predicates->equalTo(predicates, "data1", valueObject); + + const char *columnNames[] = {"data1","data2","data3","data4"}; + OH_Cursor *cursor = OH_Rdb_Query(storeTestRdbStore_, predicates, columnNames, 4); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query is fail."); + int rowCount = -1; + cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 1, "getRowCount is fail."); + + valueObject->destroy(valueObject); + predicates->destroy(predicates); + valueBucket->destroy(valueBucket); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} +/** + * @tc.name: SUB_DDM_RDB_2900 + * @tc.desc: napi test RDB store for Query with wrong length. + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_2900(napi_env env, napi_callback_info info) { + int errCode = 0; + OH_VBucket* valueBucket = OH_Rdb_CreateValuesBucket(); + valueBucket->putInt64(valueBucket, "id", 1); + valueBucket->putText(valueBucket, "data1", "zhangSan"); + valueBucket->putInt64(valueBucket, "data2", 12800); + valueBucket->putReal(valueBucket, "data3", 100.1); + uint8_t arr[] = {1, 2, 3, 4, 5}; + int len = sizeof(arr) / sizeof(arr[0]); + valueBucket->putBlob(valueBucket, "data4", arr, len); + valueBucket->putText(valueBucket, "data5", "ABCDEFG"); + errCode = OH_Rdb_Insert(storeTestRdbStore_, "test", valueBucket); + NAPI_ASSERT(env, errCode == 1, "OH_Rdb_Insert is fail."); + + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + OH_VObject *valueObject = OH_Rdb_CreateValueObject(); + const char *data1Value = "zhangSan"; + valueObject->putText(valueObject, data1Value); + predicates->equalTo(predicates, "data1", valueObject); + + const char *columnNames[] = {"data2","data3","data4"}; + OH_Cursor *cursor = OH_Rdb_Query(storeTestRdbStore_, predicates, columnNames, 3); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query is fail."); + int rowCount = -1; + cursor->getRowCount(cursor, &rowCount); + NAPI_ASSERT(env, rowCount == 1, "getRowCount is fail."); + + valueObject->destroy(valueObject); + predicates->destroy(predicates); + valueBucket->destroy(valueBucket); + errCode = cursor->destroy(cursor); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} +/** + * @tc.name: SUB_DDM_RDB_3000 + * @tc.desc: napi test RDB store for Query with wrong length. + * @tc.type: FUNC + */ +static napi_value SUB_DDM_RDB_3000(napi_env env, napi_callback_info info) { + int errCode = 0; + OH_VBucket* valueBucket = OH_Rdb_CreateValuesBucket(); + valueBucket->putInt64(valueBucket, "id", 1); + valueBucket->putText(valueBucket, "data1", "zhangSan"); + valueBucket->putInt64(valueBucket, "data2", 12800); + valueBucket->putReal(valueBucket, "data3", 100.1); + uint8_t arr[] = {1, 2, 3, 4, 5}; + int len = sizeof(arr) / sizeof(arr[0]); + valueBucket->putBlob(valueBucket, "data4", arr, len); + valueBucket->putText(valueBucket, "data5", "ABCDEFG"); + errCode = OH_Rdb_Insert(storeTestRdbStore_, "test", valueBucket); + NAPI_ASSERT(env, errCode == 1, "OH_Rdb_Insert is fail."); + + OH_Predicates *predicates = OH_Rdb_CreatePredicates("test"); + OH_VObject *valueObject = OH_Rdb_CreateValueObject(); + const char *data1Value = "zhangSan"; + valueObject->putText(valueObject, data1Value); + predicates->equalTo(predicates, "data1", valueObject); + + const char *columnNames[] = {"data1","data2","data3","data4","data5"}; + OH_Cursor *cursor = OH_Rdb_Query(storeTestRdbStore_, predicates, columnNames, 5); + NAPI_ASSERT(env, cursor != NULL, "OH_Rdb_Query is fail."); + + valueObject->destroy(valueObject); + predicates->destroy(predicates); + errCode = valueBucket->destroy(valueBucket); + + napi_value returnCode; + napi_create_double(env, errCode, &returnCode); + return returnCode; +} + +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) { + napi_property_descriptor desc[] = { + {"RdbstoreSetUpTestCase", nullptr, RdbstoreSetUpTestCase, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"RdbstoreTearDownTestCase", nullptr, RdbstoreTearDownTestCase, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_0100", nullptr, SUB_DDM_RDB_0100, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_0200", nullptr, SUB_DDM_RDB_0200, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_0300", nullptr, SUB_DDM_RDB_0300, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_0400", nullptr, SUB_DDM_RDB_0400, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_0500", nullptr, SUB_DDM_RDB_0500, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_0600", nullptr, SUB_DDM_RDB_0600, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_0700", nullptr, SUB_DDM_RDB_0700, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_0800", nullptr, SUB_DDM_RDB_0800, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_0900", nullptr, SUB_DDM_RDB_0900, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_1000", nullptr, SUB_DDM_RDB_1000, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_1100", nullptr, SUB_DDM_RDB_1100, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_1200", nullptr, SUB_DDM_RDB_1200, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_1300", nullptr, SUB_DDM_RDB_1300, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_1400", nullptr, SUB_DDM_RDB_1400, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_1500", nullptr, SUB_DDM_RDB_1500, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_1600", nullptr, SUB_DDM_RDB_1600, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_1700", nullptr, SUB_DDM_RDB_1700, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_1800", nullptr, SUB_DDM_RDB_1800, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_1900", nullptr, SUB_DDM_RDB_1900, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_2000", nullptr, SUB_DDM_RDB_2000, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_2100", nullptr, SUB_DDM_RDB_2100, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_2200", nullptr, SUB_DDM_RDB_2200, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_2300", nullptr, SUB_DDM_RDB_2300, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_2400", nullptr, SUB_DDM_RDB_2400, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_2500", nullptr, SUB_DDM_RDB_2500, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_2600", nullptr, SUB_DDM_RDB_2600, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_2700", nullptr, SUB_DDM_RDB_2700, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_2800", nullptr, SUB_DDM_RDB_2800, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_2900", nullptr, SUB_DDM_RDB_2900, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"SUB_DDM_RDB_3000", nullptr, SUB_DDM_RDB_3000, nullptr, nullptr, nullptr, napi_default, nullptr} + }; + + + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END + + + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "rdbstore", + .nm_priv = ((void *)0), + .reserved = {0}, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { + napi_module_register(&demoModule); +} diff --git a/distributeddatamgr/relationalStoretest/rdbnapitest/entry/src/main/ets/MainAbility/app.ets b/distributeddatamgr/relationalStoretest/rdbnapitest/entry/src/main/ets/MainAbility/app.ets new file mode 100644 index 0000000000000000000000000000000000000000..74210553eede1d130ca36a0831418f1a085a862c --- /dev/null +++ b/distributeddatamgr/relationalStoretest/rdbnapitest/entry/src/main/ets/MainAbility/app.ets @@ -0,0 +1,36 @@ +// @ts-nocheck +/** + * 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. + */ +import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' +import { Hypium } from 'hypium/index' +import testsuite from '../test/List.test' + +export default { + onCreate() { + console.info('Application onCreate') + var abilityDelegator: any + abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + var abilityDelegatorArguments: any + abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + + console.info('start run testcase!!!') + Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite) + }, + onDestroy() { + console.info('Application onDestroy') + }, + + +} \ No newline at end of file diff --git a/distributeddatamgr/relationalStoretest/rdbnapitest/entry/src/main/ets/MainAbility/pages/index.ets b/distributeddatamgr/relationalStoretest/rdbnapitest/entry/src/main/ets/MainAbility/pages/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..d4be87ada586325cf469f6b138070346e8631af8 --- /dev/null +++ b/distributeddatamgr/relationalStoretest/rdbnapitest/entry/src/main/ets/MainAbility/pages/index.ets @@ -0,0 +1,37 @@ +// @ts-nocheck +/** + * 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. + */ + +@Entry +@Component +struct MyComponent { + aboutToAppear() { + } + + build() { + Flex({ + direction: FlexDirection.Column, + alignItems: ItemAlign.Center, + justifyContent: FlexAlign.Center + }) { + Text('ACE ETS TEST') + .fontSize(50) + .fontWeight(FontWeight.Bold) + } + .width('100%') + .height('100%') + } +} + diff --git a/distributeddatamgr/relationalStoretest/rdbnapitest/entry/src/main/ets/TestAbility/app.ets b/distributeddatamgr/relationalStoretest/rdbnapitest/entry/src/main/ets/TestAbility/app.ets new file mode 100644 index 0000000000000000000000000000000000000000..70605c30795dfff113d2e91abf508c04c138a02c --- /dev/null +++ b/distributeddatamgr/relationalStoretest/rdbnapitest/entry/src/main/ets/TestAbility/app.ets @@ -0,0 +1,35 @@ +// @ts-nocheck +/** + * 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. + */ +import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' +import { Hypium } from 'hypium/index' +import testsuite from '../test/List.test' + +export default { + onCreate() { + console.info('Application onCreate') + var abilityDelegator: any + abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + var abilityDelegatorArguments: any + abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + console.info('start run testcase!!!') + Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite) + }, + onDestroy() { + console.info('Application onDestroy') + } + + +} \ No newline at end of file diff --git a/distributeddatamgr/relationalStoretest/rdbnapitest/entry/src/main/ets/TestAbility/pages/index.ets b/distributeddatamgr/relationalStoretest/rdbnapitest/entry/src/main/ets/TestAbility/pages/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..4724a25d8bf8b6bc2a8fdb4c90b2b7974f85dea9 --- /dev/null +++ b/distributeddatamgr/relationalStoretest/rdbnapitest/entry/src/main/ets/TestAbility/pages/index.ets @@ -0,0 +1,50 @@ +// @ts-nocheck +/** + * 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. + */ +import router from '@system.router'; + +@Entry +@Component +struct Index { + aboutToAppear() { + console.info('TestAbility index aboutToAppear') + } + + @State message: string = 'Hello World' + build() { + Row() { + Column() { + Text(this.message) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Button() { + Text('next page') + .fontSize(20) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .width('35%') + .height('5%') + .onClick(()=>{ + }) + } + .width('100%') + } + .height('100%') + } + } \ No newline at end of file diff --git a/distributeddatamgr/relationalStoretest/rdbnapitest/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts b/distributeddatamgr/relationalStoretest/rdbnapitest/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts new file mode 100644 index 0000000000000000000000000000000000000000..d3cf5bb0061751c587f732b18169c3bd4c52199b --- /dev/null +++ b/distributeddatamgr/relationalStoretest/rdbnapitest/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts @@ -0,0 +1,78 @@ +// @ts-nocheck +/** + * 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. + */ +import TestRunner from '@ohos.application.testRunner' +import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' + +var abilityDelegator = undefined +var abilityDelegatorArguments = undefined + +function translateParamsToString(parameters) { + const keySet = new Set([ + '-s class', '-s notClass', '-s suite', '-s itName', + '-s level', '-s testType', '-s size', '-s timeout', + '-s package' + ]) + let targetParams = ''; + for (const key in parameters) { + if (keySet.has(key)) { + targetParams += ' ' + key + ' ' + parameters[key] + } + } + return targetParams.trim() +} + +async function onAbilityCreateCallback() { + console.log('onAbilityCreateCallback'); +} + +async function addAbilityMonitorCallback(err: any) { + console.info('addAbilityMonitorCallback : ' + JSON.stringify(err)) +} + +export default class OpenHarmonyTestRunner implements TestRunner { + constructor() { + } + + onPrepare() { + console.info('OpenHarmonyTestRunner OnPrepare') + } + + onRun() { + console.log('OpenHarmonyTestRunner onRun run') + abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + + let lMonitor = { + abilityName: testAbilityName, + onAbilityCreate: onAbilityCreateCallback, + }; + var testAbilityName = abilityDelegatorArguments.parameters['-p'] + '.MainAbility' + abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback) + var cmd = 'aa start -d 0 -a ' + testAbilityName + ' -b ' + abilityDelegatorArguments.bundleName + cmd += ' '+translateParamsToString(abilityDelegatorArguments.parameters) + console.info('cmd : '+cmd) + abilityDelegator.executeShellCommand(cmd, + (err: any, d: any) => { + console.info('executeShellCommand : err : ' + JSON.stringify(err)); + console.info('executeShellCommand : data : ' + d.stdResult); + console.info('executeShellCommand : data : ' + d.exitCode); + }) + console.info('OpenHarmonyTestRunner onRun call abilityDelegator.getAppContext') + var context = abilityDelegator.getAppContext() + console.info('getAppContext : ' + JSON.stringify(context)) + console.info('OpenHarmonyTestRunner onRun end') + } +}; \ No newline at end of file diff --git a/distributeddatamgr/relationalStoretest/rdbnapitest/entry/src/main/ets/test/List.test.ets b/distributeddatamgr/relationalStoretest/rdbnapitest/entry/src/main/ets/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..d23b3a76955d1522c8883279cc7ee42a159ddb30 --- /dev/null +++ b/distributeddatamgr/relationalStoretest/rdbnapitest/entry/src/main/ets/test/List.test.ets @@ -0,0 +1,29 @@ +/* + * 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. + */ +import RdbNdkStoreBackupTest from './RdbNdkStoreBackupTest' +import RdbNdkStoreEncryptTest from './RdbNdkStoreEncryptTest' +import RdbNdkStoreLevelTest from './RdbNdkStoreLevelTest' +import RdbNdkStoreCursorTest from './RdbNdkStoreCursorTest' +import RdbNdkStorePredicatesTest from './RdbNdkStorePredicatesTest' +import RdbNdkStoreTest from './RdbNdkStoreTest' + +export default function testsuite() { + RdbNdkStoreEncryptTest() + RdbNdkStoreLevelTest() + RdbNdkStoreCursorTest() + RdbNdkStorePredicatesTest() + RdbNdkStoreTest() + RdbNdkStoreBackupTest() +} \ No newline at end of file diff --git a/distributeddatamgr/relationalStoretest/rdbnapitest/entry/src/main/ets/test/RdbNdkStoreBackupTest.ets b/distributeddatamgr/relationalStoretest/rdbnapitest/entry/src/main/ets/test/RdbNdkStoreBackupTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..d006cc7c8708db678a6e63d77d6afcff1cc3f935 --- /dev/null +++ b/distributeddatamgr/relationalStoretest/rdbnapitest/entry/src/main/ets/test/RdbNdkStoreBackupTest.ets @@ -0,0 +1,159 @@ +/* + * 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. + */ +import hilog from '@ohos.hilog'; +import testNapi from 'libbackup.so'; +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'hypium/index'; + +const TAG = "[RdbNdkStoreTest]"; + +export default function RdbNdkStoreBackupTest() { + describe('RdbNdkStoreBackupTest', function () { + beforeAll(function () { + }) + beforeEach(function () { + hilog.info(0x0000, TAG, 'testTag RdbstoreSetUpTestCase' , ' begin'); + let re = testNapi.RdbstoreSetUpTestCase(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + afterEach(function () { + hilog.info(0x0000, TAG, 'testTag RdbstoreTearDownTestCase' , ' begin'); + let re = testNapi.RdbstoreTearDownTestCase(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + afterAll(function () { + }) + + + /** + * @tc.name: SUB_DDM_RDB_BackupRestoreTest_0100 + * @tc.desc: Normal testCase of NDK store for Backup、Restore. + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_BackupRestoreTest_0100',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_BackupRestoreTest_0100' , ' begin'); + let re = testNapi.SUB_DDM_RDB_BackupRestoreTest_0100(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + + /** + * @tc.name: SUB_DDM_RDB_BackupRestoreTest_0300 + * @tc.desc: Exception testCase of NDK store for Backup、Restore. + * @tc.desc: backup file name already exists + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_BackupRestoreTest_0300',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_BackupRestoreTest_0300' , ' begin'); + let re = testNapi.SUB_DDM_RDB_BackupRestoreTest_0300(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + + /** + * @tc.name: SUB_DDM_RDB_BackupRestoreTest_0400 + * @tc.desc: Exception testCase of NDK store for Backup、Restore. + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_BackupRestoreTest_0400',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_BackupRestoreTest_0400' , ' begin'); + let re = testNapi.SUB_DDM_RDB_BackupRestoreTest_0400(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_BackupRestoreTest_0500 + * @tc.desc: Exception testCase of NDK store for Backup、Restore. + * @tc.desc: backup file name is empty + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_BackupRestoreTest_0500',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_BackupRestoreTest_0500' , ' begin'); + let re = testNapi.SUB_DDM_RDB_BackupRestoreTest_0500(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + + + /** + * @tc.name: SUB_DDM_RDB_BackupRestoreTest_0600 + * @tc.desc: Normal testCase of NDK store for Backup、Restore. + * @tc.desc: backup file name is a space + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_BackupRestoreTest_0600',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_BackupRestoreTest_0600' , ' begin'); + let re = testNapi.SUB_DDM_RDB_BackupRestoreTest_0600(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + + /** + * @tc.name: SUB_DDM_RDB_BackupRestoreTest_0700 + * @tc.desc: Normal testCase of NDK store for Backup、Restore. + * @tc.desc: Backup file name is a null + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_BackupRestoreTest_0700',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_BackupRestoreTest_0700' , ' begin'); + let re = testNapi.SUB_DDM_RDB_BackupRestoreTest_0700(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + + /** + * @tc.name: SUB_DDM_RDB_BackupRestoreTest_0800 + * @tc.desc: Normal testCase of NDK store for Backup、Restore. + * @tc.desc: Restore file name is a null + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_BackupRestoreTest_0800',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_BackupRestoreTest_0800' , ' begin'); + let re = testNapi.SUB_DDM_RDB_BackupRestoreTest_0800(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + + /** + * @tc.name: SUB_DDM_RDB_BackupRestoreTest_0900 + * @tc.desc: Exception testCase of NDK store for Backup、Restore. + * @tc.desc: Restore file name is empty + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_BackupRestoreTest_0900',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_BackupRestoreTest_0900' , ' begin'); + let re = testNapi.SUB_DDM_RDB_BackupRestoreTest_0900(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + + /** + * @tc.name: SUB_DDM_RDB_BackupRestoreTest_0110 + * @tc.desc: Exception testCase of NDK store for Backup、Restore. + * @tc.desc: Restore file name is invalid + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_BackupRestoreTest_0110',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_BackupRestoreTest_0110' , ' begin'); + let re = testNapi.SUB_DDM_RDB_BackupRestoreTest_0110(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + + + + }) +} \ No newline at end of file diff --git a/distributeddatamgr/relationalStoretest/rdbnapitest/entry/src/main/ets/test/RdbNdkStoreCursorTest.ets b/distributeddatamgr/relationalStoretest/rdbnapitest/entry/src/main/ets/test/RdbNdkStoreCursorTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..3ea01ef1879e854445b7f066f2b9961d5ae14269 --- /dev/null +++ b/distributeddatamgr/relationalStoretest/rdbnapitest/entry/src/main/ets/test/RdbNdkStoreCursorTest.ets @@ -0,0 +1,245 @@ +/* + * 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. + */ +import hilog from '@ohos.hilog'; +import testNapi from 'libcursor.so' +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'hypium/index'; + +const TAG = "[RdbNdkStoreTest]"; + +export default function RdbNdkStoreCursorTest() { + describe('RdbNdkStoreCursorTest', function () { + // Defines a test suite. Two parameters are supported: test suite name and test suite function. + beforeAll(function () { + + }) + beforeEach(function () { + hilog.info(0x0000, TAG, 'testTag CursorSetUpTestCase' , ' begin'); + let re = testNapi.CursorSetUpTestCase(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + afterEach(function () { + hilog.info(0x0000, TAG, 'testTag CursorTearDownTestCase' , ' begin'); + let re = testNapi.CursorTearDownTestCase(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + afterAll(function () { + + }) + /** + * @tc.name: SUB_DDM_RDB_CURSOR_0100 + * @tc.desc: Normal testCase of NDK cursor for GetColumnType. + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_CURSOR_0100',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_CURSOR_0100' , ' begin'); + let re = testNapi.SUB_DDM_RDB_CURSOR_0100(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + + /** + * @tc.name: SUB_DDM_RDB_CURSOR_0200 + * @tc.desc: Normal testCase of NDK cursor for GetColumnIndex. + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_CURSOR_0200',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_CURSOR_0200' , ' begin'); + let re = testNapi.SUB_DDM_RDB_CURSOR_0200(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_CURSOR_0300 + * @tc.desc: Normal testCase of NDK cursor for GetColumnName. + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_CURSOR_0300',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_CURSOR_0300' , ' begin'); + let re = testNapi.SUB_DDM_RDB_CURSOR_0300(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + + /** + * @tc.name: SUB_DDM_RDB_CURSOR_0400 + * @tc.desc: Normal testCase of NDK cursor for Getxxx. + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_CURSOR_0400',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_CURSOR_0400' , ' begin'); + let re = testNapi.SUB_DDM_RDB_CURSOR_0400(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_CURSOR_0500 + * @tc.desc: Normal testCase of NDK cursor for GetColumnIndex. + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_CURSOR_0500',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_CURSOR_0500' , ' begin'); + let re = testNapi.SUB_DDM_RDB_CURSOR_0500(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_CURSOR_0600 + * @tc.desc: Normal testCase of NDK cursor for GetColumnIndex. + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_CURSOR_0600',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_CURSOR_0600' , ' begin'); + let re = testNapi.SUB_DDM_RDB_CURSOR_0600(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_CURSOR_0700 + * @tc.desc: Normal testCase of NDK cursor for GetColumnType. + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_CURSOR_0700',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_CURSOR_0700' , ' begin'); + let re = testNapi.SUB_DDM_RDB_CURSOR_0700(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_CURSOR_0800 + * @tc.desc: Normal testCase of NDK cursor for GetColumnName. + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_CURSOR_0800',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_CURSOR_0800' , ' begin'); + let re = testNapi.SUB_DDM_RDB_CURSOR_0800(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_CURSOR_0900 + * @tc.desc: Normal testCase of NDK cursor for getSize. + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_CURSOR_0900',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_CURSOR_0900' , ' begin'); + let re = testNapi.SUB_DDM_RDB_CURSOR_0900(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_CURSOR_1000 + * @tc.desc: Normal testCase of NDK cursor for getText. + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_CURSOR_1000',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_CURSOR_1000' , ' begin'); + let re = testNapi.SUB_DDM_RDB_CURSOR_1000(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + + /** + * @tc.name: SUB_DDM_RDB_CURSOR_1100 + * @tc.desc: Normal testCase of NDK cursor for getInt64. + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_CURSOR_1100',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_CURSOR_1100' , ' begin'); + let re = testNapi.SUB_DDM_RDB_CURSOR_1100(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_CURSOR_1200 + * @tc.desc: Normal testCase of NDK cursor for getReal. + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_CURSOR_1200',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_CURSOR_1200' , ' begin'); + let re = testNapi.SUB_DDM_RDB_CURSOR_1200(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_CURSOR_1300 + * @tc.desc: getBlob + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_CURSOR_1300',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_CURSOR_1300' , ' begin'); + let re = testNapi.SUB_DDM_RDB_CURSOR_1300(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_CURSOR_1400 + * @tc.desc: isNull + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_CURSOR_1400',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_CURSOR_1400' , ' begin'); + let re = testNapi.SUB_DDM_RDB_CURSOR_1400(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_CURSOR_1500 + * @tc.desc: getRowCount + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_CURSOR_1500',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_CURSOR_1500' , ' begin'); + let re = testNapi.SUB_DDM_RDB_CURSOR_1500(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_CURSOR_1600 + * @tc.desc: getRowCount + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_CURSOR_1600',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_CURSOR_1600' , ' begin'); + let re = testNapi.SUB_DDM_RDB_CURSOR_1600(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_CURSOR_1700 + * @tc.desc: getRowCount + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_CURSOR_1700',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_CURSOR_1700' , ' begin'); + let re = testNapi.SUB_DDM_RDB_CURSOR_1700(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_CURSOR_1800 + * @tc.desc: + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_CURSOR_1800',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_CURSOR_1800' , ' begin'); + let re = testNapi.SUB_DDM_RDB_CURSOR_1800(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + + }) +} \ No newline at end of file diff --git a/distributeddatamgr/relationalStoretest/rdbnapitest/entry/src/main/ets/test/RdbNdkStoreEncryptTest.ets b/distributeddatamgr/relationalStoretest/rdbnapitest/entry/src/main/ets/test/RdbNdkStoreEncryptTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..37ce839c23273544fb2f77dfd2d2216c420f1baa --- /dev/null +++ b/distributeddatamgr/relationalStoretest/rdbnapitest/entry/src/main/ets/test/RdbNdkStoreEncryptTest.ets @@ -0,0 +1,54 @@ +/* + * 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. + */ +import hilog from '@ohos.hilog'; +import testNapi from 'libencrypt.so' +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'hypium/index'; + +const TAG = "[RdbNdkStoreTest]"; + +export default function RdbNdkStoreEncryptTest() { + describe('RdbNdkStoreEncryptTest', function () { + beforeAll(function () {}) + beforeEach(function () {}) + afterEach(function () {}) + afterAll(function () {}) + + /** + * @tc.name: SUB_DDM_RDB_ENCRYPT_0100 + * @tc.desc: Exception testCase of NDK ENCRYPT. + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_ENCRYPT_0100',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_ENCRYPT_0100' , ' begin'); + let re = testNapi.SUB_DDM_RDB_ENCRYPT_0100(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + + /** + * @tc.name: SUB_DDM_RDB_ENCRYPT_0200 + * @tc.desc: Exception testCase of NDK SecurityLevel. + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_ENCRYPT_0200',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_ENCRYPT_0200' , ' begin'); + let re = testNapi.SUB_DDM_RDB_ENCRYPT_0200(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + + + }) +} \ No newline at end of file diff --git a/distributeddatamgr/relationalStoretest/rdbnapitest/entry/src/main/ets/test/RdbNdkStoreLevelTest.ets b/distributeddatamgr/relationalStoretest/rdbnapitest/entry/src/main/ets/test/RdbNdkStoreLevelTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..f889828f954b6924492b8809199ba8b254a6ef3d --- /dev/null +++ b/distributeddatamgr/relationalStoretest/rdbnapitest/entry/src/main/ets/test/RdbNdkStoreLevelTest.ets @@ -0,0 +1,79 @@ +/* + * 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. + */ +import hilog from '@ohos.hilog'; +import testNapi from 'liblevel.so' +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'hypium/index'; + +const TAG = "[RdbNdkStoreTest]"; + +export default function RdbNdkStoreLevelTest() { + describe('RdbNdkStoreLevelTest', function () { + beforeAll(function () {}) + beforeEach(function () {}) + afterEach(function () {}) + afterAll(function () {}) + + /** + * @tc.name: SUB_DDM_RDB_LEVEL_0100 + * @tc.desc: Normal testCase of NDK SecurityLevel is S1 + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_LEVEL_0100',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_LEVEL_0100' , ' begin'); + let re = testNapi.SUB_DDM_RDB_LEVEL_0100(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + + /** + * @tc.name: SUB_DDM_RDB_LEVEL_0200 + * @tc.desc: Normal testCase of NDK SecurityLevel is S2 + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_LEVEL_0200',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_LEVEL_0200' , ' begin'); + let re = testNapi.SUB_DDM_RDB_LEVEL_0200(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + + /** + * @tc.name: SUB_DDM_RDB_LEVEL_0300 + * @tc.desc: Normal testCase of NDK SecurityLevel is S3 + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_LEVEL_0300',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_LEVEL_0300' , ' begin'); + let re = testNapi.SUB_DDM_RDB_LEVEL_0300(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + + /** + * @tc.name: SUB_DDM_RDB_LEVEL_0400 + * @tc.desc: Normal testCase of NDK SecurityLevel is S4 + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_LEVEL_0400',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_LEVEL_0400' , ' begin'); + let re = testNapi.SUB_DDM_RDB_LEVEL_0400(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + + + + }) +} \ No newline at end of file diff --git a/distributeddatamgr/relationalStoretest/rdbnapitest/entry/src/main/ets/test/RdbNdkStorePredicatesTest.ets b/distributeddatamgr/relationalStoretest/rdbnapitest/entry/src/main/ets/test/RdbNdkStorePredicatesTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..a9144422f706db88bc32422043accbbaf5105139 --- /dev/null +++ b/distributeddatamgr/relationalStoretest/rdbnapitest/entry/src/main/ets/test/RdbNdkStorePredicatesTest.ets @@ -0,0 +1,790 @@ +/* + * 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. + */ +import hilog from '@ohos.hilog'; +import testNapi from 'libpredicates.so' + +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'hypium/index'; + +const TAG = "[RdbNdkStoreTest]"; + +export default function RdbNdkStorePredicatesTest() { + describe('RdbNdkStorePredicatesTest', function () { + // Defines a test suite. Two parameters are supported: test suite name and test suite function. + beforeAll(function () { + }) + beforeEach(function () { + hilog.info(0x0000, TAG, 'testTag PredicatesSetUpTestCase' , ' begin'); + let re = testNapi.PredicatesSetUpTestCase(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + afterEach(function () { + hilog.info(0x0000, TAG, 'testTag PredicatesTearDownTestCase' , ' begin'); + let re = testNapi.PredicatesTearDownTestCase(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + afterAll(function () { + }) + + /** + * @tc.name: SUB_DDM_RDB_Predicates_0100 + * @tc.desc: Normal testCase of NDK Predicates for EqualTo、AndOR、beginWrap and endWrap + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_Predicates_0100',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_Predicates_0100' , ' begin'); + let re = testNapi.SUB_DDM_RDB_Predicates_0100(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + + /** + * @tc.name: SUB_DDM_RDB_Predicates_0200 + * @tc.desc: Normal testCase of NDK Predicates for NotEqualTo + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_Predicates_0200',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_Predicates_0200' , ' begin'); + let re = testNapi.SUB_DDM_RDB_Predicates_0200(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_Predicates_0300 + * @tc.desc: Normal testCase of NDK Predicates for GreaterThan + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_Predicates_0300',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_Predicates_0300' , ' begin'); + let re = testNapi.SUB_DDM_RDB_Predicates_0300(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_Predicates_0400 + * @tc.desc: Normal testCase of NDK Predicates for GreaterThanOrEqualTo + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_Predicates_0400',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_Predicates_0400' , ' begin'); + let re = testNapi.SUB_DDM_RDB_Predicates_0400(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + + /** + * @tc.name: SUB_DDM_RDB_Predicates_0500 + * @tc.desc: Normal testCase of NDK Predicates for LessThan + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_Predicates_0500',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_Predicates_0500' , ' begin'); + let re = testNapi.SUB_DDM_RDB_Predicates_0500(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_Predicates_0600 + * @tc.desc: Normal testCase of NDK Predicates for LessThanOrEqualTo + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_Predicates_0600',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_Predicates_0600' , ' begin'); + let re = testNapi.SUB_DDM_RDB_Predicates_0600(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_Predicates_0700 + * @tc.desc: Normal testCase of NDK Predicates for IsNull + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_Predicates_0700',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_Predicates_0700' , ' begin'); + let re = testNapi.SUB_DDM_RDB_Predicates_0700(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_Predicates_0800 + * @tc.desc: Normal testCase of NDK Predicates for isNotNull + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_Predicates_0800',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_Predicates_0800' , ' begin'); + let re = testNapi.SUB_DDM_RDB_Predicates_0800(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_Predicates_0900 + * @tc.desc: Normal testCase of NDK Predicates for Between + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_Predicates_0900',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_Predicates_0900' , ' begin'); + let re = testNapi.SUB_DDM_RDB_Predicates_0900(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_Predicates_1000 + * @tc.desc: Normal testCase of NDK Predicates for NotBetween + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_Predicates_1000',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_Predicates_1000' , ' begin'); + let re = testNapi.SUB_DDM_RDB_Predicates_1000(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + + + /** + * @tc.name: SUB_DDM_RDB_Predicates_1100 + * @tc.desc: Normal testCase of NDK Predicates for OrderBy、Limit、Offset. + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_Predicates_1100',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_Predicates_1100' , ' begin'); + let re = testNapi.SUB_DDM_RDB_Predicates_1100(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_Predicates_1200 + * @tc.desc: Normal testCase of NDK Predicates for In. + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_Predicates_1200',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_Predicates_1200' , ' begin'); + let re = testNapi.SUB_DDM_RDB_Predicates_1200(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_Predicates_1300 + * @tc.desc: Normal testCase of NDK Predicates for NotIn + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_Predicates_1300',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_Predicates_1300' , ' begin'); + let re = testNapi.SUB_DDM_RDB_Predicates_1300(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_Predicates_1400 + * @tc.desc: Normal testCase of NDK Predicates for Like + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_Predicates_1400',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_Predicates_1400' , ' begin'); + let re = testNapi.SUB_DDM_RDB_Predicates_1400(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_Predicates_1500 + * @tc.desc: Normal testCase of NDK Predicates for GroupBy + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_Predicates_1500',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_Predicates_1500' , ' begin'); + let re = testNapi.SUB_DDM_RDB_Predicates_1500(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_Predicates_1600 + * @tc.desc: Normal testCase of NDK Predicates for And + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_Predicates_1600',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_Predicates_1600' , ' begin'); + let re = testNapi.SUB_DDM_RDB_Predicates_1600(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_Predicates_1700 + * @tc.desc: Normal testCase of NDK Predicates for Clear + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_Predicates_1700',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_Predicates_1700' , ' begin'); + let re = testNapi.SUB_DDM_RDB_Predicates_1700(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_Predicates_1800 + * @tc.desc: Normal testCase of NDK Predicates for table name is NULL. + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_Predicates_1800',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_Predicates_1800' , ' begin'); + let re = testNapi.SUB_DDM_RDB_Predicates_1800(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_Predicates_1900 + * @tc.desc: Normal testCase of NDK Predicates for equalTo + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_Predicates_1900',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_Predicates_1900' , ' begin'); + let re = testNapi.SUB_DDM_RDB_Predicates_1900(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_Predicates_2000 + * @tc.desc: Normal testCase of NDK Predicates for equalTo + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_Predicates_2000',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_Predicates_2000' , ' begin'); + let re = testNapi.SUB_DDM_RDB_Predicates_2000(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + + + /** + * @tc.name: SUB_DDM_RDB_Predicates_2100 + * @tc.desc: Normal testCase of NDK Predicates for equalTo + * @tc.type: FUNC + */ + + it('SUB_DDM_RDB_Predicates_2100',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_Predicates_2100' , ' begin'); + let re = testNapi.SUB_DDM_RDB_Predicates_2100(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_Predicates_2200 + * @tc.desc: Normal testCase of NDK Predicates for equalTo + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_Predicates_2200',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_Predicates_2200' , ' begin'); + let re = testNapi.SUB_DDM_RDB_Predicates_2200(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_Predicates_2300 + * @tc.desc: Normal testCase of NDK Predicates for notEqualTo + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_Predicates_2300',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_Predicates_2300' , ' begin'); + let re = testNapi.SUB_DDM_RDB_Predicates_2300(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_Predicates_2400 + * @tc.desc: Normal testCase of NDK Predicates for notEqualTo + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_Predicates_2400',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_Predicates_2400' , ' begin'); + let re = testNapi.SUB_DDM_RDB_Predicates_2400(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_Predicates_2500 + * @tc.desc: Normal testCase of NDK Predicates for notEqualTo + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_Predicates_2500',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_Predicates_2500' , ' begin'); + let re = testNapi.SUB_DDM_RDB_Predicates_2500(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_Predicates_2600 + * @tc.desc: Normal testCase of NDK Predicates for notEqualTo + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_Predicates_2600',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_Predicates_2600' , ' begin'); + let re = testNapi.SUB_DDM_RDB_Predicates_2600(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_Predicates_2700 + * @tc.desc: Normal testCase of NDK Predicates for beginWrap and endWrap + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_Predicates_2700',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_Predicates_2700' , ' begin'); + let re = testNapi.SUB_DDM_RDB_Predicates_2700(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_Predicates_2800 + * @tc.desc: Normal testCase of NDK Predicates for beginWrap and endWrap + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_Predicates_2800',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_Predicates_2800' , ' begin'); + let re = testNapi.SUB_DDM_RDB_Predicates_2800(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_Predicates_2900 + * @tc.desc: Normal testCase of NDK Predicates for beginWrap and endWrap + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_Predicates_2900',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_Predicates_2900' , ' begin'); + let re = testNapi.SUB_DDM_RDB_Predicates_2900(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_Predicates_3000 + * @tc.desc: Normal testCase of NDK Predicates for EqualTo、AndOR、beginWrap and endWrap + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_Predicates_3000',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_Predicates_3000' , ' begin'); + let re = testNapi.SUB_DDM_RDB_Predicates_3000(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_Predicates_3100 + * @tc.desc: Normal testCase of NDK Predicates for + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_Predicates_3100',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_Predicates_3100' , ' begin'); + let re = testNapi.SUB_DDM_RDB_Predicates_3100(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_Predicates_3200 + * @tc.desc: Normal testCase of NDK Predicates for And + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_Predicates_3200',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_Predicates_3200' , ' begin'); + let re = testNapi.SUB_DDM_RDB_Predicates_3200(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_Predicates_3300 + * @tc.desc: Normal testCase of NDK Predicates for IsNull + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_Predicates_3300',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_Predicates_3300' , ' begin'); + let re = testNapi.SUB_DDM_RDB_Predicates_3300(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_Predicates_3400 + * @tc.desc: Normal testCase of NDK Predicates for isNotNull + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_Predicates_3400',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_Predicates_3400' , ' begin'); + let re = testNapi.SUB_DDM_RDB_Predicates_3400(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_Predicates_3500 + * @tc.desc: Normal testCase of NDK Predicates for Like + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_Predicates_3500',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_Predicates_3500' , ' begin'); + let re = testNapi.SUB_DDM_RDB_Predicates_3500(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_Predicates_3600 + * @tc.desc: Normal testCase of NDK Predicates for Like + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_Predicates_3600',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_Predicates_3600' , ' begin'); + let re = testNapi.SUB_DDM_RDB_Predicates_3600(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_Predicates_3700 + * @tc.desc: Normal testCase of NDK Predicates for Like + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_Predicates_3700',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_Predicates_3700' , ' begin'); + let re = testNapi.SUB_DDM_RDB_Predicates_3700(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_Predicates_3800 + * @tc.desc: Normal testCase of NDK Predicates for Between + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_Predicates_3800',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_Predicates_3800' , ' begin'); + let re = testNapi.SUB_DDM_RDB_Predicates_3800(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_Predicates_3900 + * @tc.desc: Normal testCase of NDK Predicates for Between + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_Predicates_3900',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_Predicates_3900' , ' begin'); + let re = testNapi.SUB_DDM_RDB_Predicates_3900(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_Predicates_4000 + * @tc.desc: Normal testCase of NDK Predicates for Between + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_Predicates_4000',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_Predicates_4000' , ' begin'); + let re = testNapi.SUB_DDM_RDB_Predicates_4000(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + + /** + * @tc.name: SUB_DDM_RDB_Predicates_4100 + * @tc.desc: Normal testCase of NDK Predicates for NotBetween + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_Predicates_4100',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_Predicates_4100' , ' begin'); + let re = testNapi.SUB_DDM_RDB_Predicates_4100(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_Predicates_4200 + * @tc.desc: Normal testCase of NDK Predicates for GreaterThan + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_Predicates_4200',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_Predicates_4200' , ' begin'); + let re = testNapi.SUB_DDM_RDB_Predicates_4200(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_Predicates_4300 + * @tc.desc: Normal testCase of NDK Predicates for GreaterThan + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_Predicates_4300',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_Predicates_4300' , ' begin'); + let re = testNapi.SUB_DDM_RDB_Predicates_4300(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_Predicates_4400 + * @tc.desc: Normal testCase of NDK Predicates for GreaterThan + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_Predicates_4400',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_Predicates_4400' , ' begin'); + let re = testNapi.SUB_DDM_RDB_Predicates_4400(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_Predicates_4500 + * @tc.desc: Normal testCase of NDK Predicates for LessThan + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_Predicates_4500',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_Predicates_4500' , ' begin'); + let re = testNapi.SUB_DDM_RDB_Predicates_4500(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_Predicates_4600 + * @tc.desc: Normal testCase of NDK Predicates for LessThan + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_Predicates_4600',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_Predicates_4600' , ' begin'); + let re = testNapi.SUB_DDM_RDB_Predicates_4600(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_Predicates_4700 + * @tc.desc: Normal testCase of NDK Predicates for LessThan + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_Predicates_4700',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_Predicates_4700' , ' begin'); + let re = testNapi.SUB_DDM_RDB_Predicates_4700(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_Predicates_4800 + * @tc.desc: Normal testCase of NDK Predicates for GreaterThanOrEqualTo + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_Predicates_4800',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_Predicates_4800' , ' begin'); + let re = testNapi.SUB_DDM_RDB_Predicates_4800(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_Predicates_4900 + * @tc.desc: Normal testCase of NDK Predicates for GreaterThanOrEqualTo + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_Predicates_4900',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_Predicates_4900' , ' begin'); + let re = testNapi.SUB_DDM_RDB_Predicates_4900(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_Predicates_5000 + * @tc.desc: Normal testCase of NDK Predicates for GreaterThanOrEqualTo + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_Predicates_5000',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_Predicates_5000' , ' begin'); + let re = testNapi.SUB_DDM_RDB_Predicates_5000(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_Predicates_5100 + * @tc.desc: Normal testCase of NDK Predicates for LessThanOrEqualTo + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_Predicates_5100',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_Predicates_5100' , ' begin'); + let re = testNapi.SUB_DDM_RDB_Predicates_5100(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_Predicates_5200 + * @tc.desc: Normal testCase of NDK Predicates for LessThanOrEqualTo + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_Predicates_5200',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_Predicates_5200' , ' begin'); + let re = testNapi.SUB_DDM_RDB_Predicates_5200(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_Predicates_5300 + * @tc.desc: Normal testCase of NDK Predicates for + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_Predicates_5300',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_Predicates_5300' , ' begin'); + let re = testNapi.SUB_DDM_RDB_Predicates_5300(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_Predicates_5400 + * @tc.desc: Normal testCase of NDK Predicates for GroupBy + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_Predicates_5400',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_Predicates_5400' , ' begin'); + let re = testNapi.SUB_DDM_RDB_Predicates_5400(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_Predicates_5500 + * @tc.desc: Normal testCase of NDK Predicates for GroupBy + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_Predicates_5500',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_Predicates_5500' , ' begin'); + let re = testNapi.SUB_DDM_RDB_Predicates_5500(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_Predicates_5600 + * @tc.desc: Normal testCase of NDK Predicates for GroupBy + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_Predicates_5600',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_Predicates_5600' , ' begin'); + let re = testNapi.SUB_DDM_RDB_Predicates_5600(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_Predicates_5700 + * @tc.desc: Normal testCase of NDK Predicates for GroupBy + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_Predicates_5700',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_Predicates_5700' , ' begin'); + let re = testNapi.SUB_DDM_RDB_Predicates_5700(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_Predicates_5800 + * @tc.desc: Normal testCase of NDK Predicates for GroupBy + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_Predicates_5800',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_Predicates_5800' , ' begin'); + let re = testNapi.SUB_DDM_RDB_Predicates_5800(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_Predicates_5900 + * @tc.desc: Normal testCase of NDK Predicates for In. + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_Predicates_5900',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_Predicates_5900' , ' begin'); + let re = testNapi.SUB_DDM_RDB_Predicates_5900(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_Predicates_6000 + * @tc.desc: Normal testCase of NDK Predicates for In. + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_Predicates_6000',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_Predicates_6000' , ' begin'); + let re = testNapi.SUB_DDM_RDB_Predicates_6000(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + + /** + * @tc.name: SUB_DDM_RDB_Predicates_6100 + * @tc.desc: Normal testCase of NDK Predicates for NotIn + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_Predicates_6100',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_Predicates_6100' , ' begin'); + let re = testNapi.SUB_DDM_RDB_Predicates_6100(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_Predicates_6200 + * @tc.desc: Normal testCase of NDK Predicates for NotIn + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_Predicates_6200',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_Predicates_6200' , ' begin'); + let re = testNapi.SUB_DDM_RDB_Predicates_6200(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_Predicates_6300 + * @tc.desc: Normal testCase of NDK Predicates for OrderBy + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_Predicates_6300',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_Predicates_6300' , ' begin'); + let re = testNapi.SUB_DDM_RDB_Predicates_6300(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_Predicates_6400 + * @tc.desc: Normal testCase of NDK Predicates for OrderBy + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_Predicates_6400',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_Predicates_6400' , ' begin'); + let re = testNapi.SUB_DDM_RDB_Predicates_6400(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_Predicates_6500 + * @tc.desc: Normal testCase of NDK Predicates for Limit + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_Predicates_6500',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_Predicates_6500' , ' begin'); + let re = testNapi.SUB_DDM_RDB_Predicates_6500(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_Predicates_6600 + * @tc.desc: Normal testCase of NDK Predicates for Offset + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_Predicates_6600',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_Predicates_6600' , ' begin'); + let re = testNapi.SUB_DDM_RDB_Predicates_6600(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_Predicates_6700 + * @tc.desc: Normal testCase of NDK Predicates for Offset + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_Predicates_6700',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_Predicates_6700' , ' begin'); + let re = testNapi.SUB_DDM_RDB_Predicates_6700(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + + }) +} \ No newline at end of file diff --git a/distributeddatamgr/relationalStoretest/rdbnapitest/entry/src/main/ets/test/RdbNdkStoreTest.ets b/distributeddatamgr/relationalStoretest/rdbnapitest/entry/src/main/ets/test/RdbNdkStoreTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..810bfe35e9d34ae873500747e97ecd7515b2b116 --- /dev/null +++ b/distributeddatamgr/relationalStoretest/rdbnapitest/entry/src/main/ets/test/RdbNdkStoreTest.ets @@ -0,0 +1,378 @@ +/* + * 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. + */ +import hilog from '@ohos.hilog'; +import testNapi from 'librdbstore.so' +import featureAbility from '@ohos.ability.featureAbility'; +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'hypium/index'; + +const TAG = "[RdbNdkStoreTest]"; + +export default function RdbNdkStoreTest() { + describe('RdbNdkStoreTest', function () { + beforeAll(function () { + }) + beforeEach(function () { + hilog.info(0x0000, TAG, 'testTag RdbstoreSetUpTestCase' , ' begin'); + let re = testNapi.RdbstoreSetUpTestCase(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + afterEach(function () { + hilog.info(0x0000, TAG, 'testTag RdbstoreTearDownTestCase' , ' begin'); + let re = testNapi.RdbstoreTearDownTestCase(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + afterAll(function () { + }) + + /** + * @tc.name: SUB_DDM_RDB_0100 + * @tc.desc: Normal testCase of NDK store for Insert、Update、Query. + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_0100',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_0100' , ' begin'); + + + let re = testNapi.SUB_DDM_RDB_0100(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + + /** + * @tc.name: SUB_DDM_RDB_0200 + * @tc.desc: Normal testCase of NDK store for Insert with wrong table name or table is NULL. + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_0200',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_0200' , ' begin'); + let re = testNapi.SUB_DDM_RDB_0200(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_0300 + * @tc.desc: Normal testCase of NDK store for Update with wrong table or table is NULL. + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_0300',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_0300' , ' begin'); + let re = testNapi.SUB_DDM_RDB_0300(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_0400 + * @tc.desc: Normal testCase of NDK store for Update with valueBucket is NULL. + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_0400',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_0400' , ' begin'); + let re = testNapi.SUB_DDM_RDB_0400(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_0500 + * @tc.desc: Normal testCase of NDK store for Update with wrong predicates. + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_0500',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_0500' , ' begin'); + let re = testNapi.SUB_DDM_RDB_0500(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_0600 + * @tc.desc: Normal testCase of NDK store for Query with wrong table or table is NULL. + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_0600',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_0600' , ' begin'); + let re = testNapi.SUB_DDM_RDB_0600(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_0700 + * @tc.desc: Normal testCase of NDK store for Query with wrong columnNames. + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_0700',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_0700' , ' begin'); + let re = testNapi.SUB_DDM_RDB_0700(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_0800 + * @tc.desc: Normal testCase of NDK store for Query with wrong length. + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_0800',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_0800' , ' begin'); + let re = testNapi.SUB_DDM_RDB_0800(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_0900 + * @tc.desc: Normal testCase of NDK store for Delete、ExecuteQuery. + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_0900',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_0900' , ' begin'); + let re = testNapi.SUB_DDM_RDB_0900(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_1000 + * @tc.desc: Normal testCase of NDK store for querysql is NULL. + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_1000',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_1000' , ' begin'); + let re = testNapi.SUB_DDM_RDB_1000(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_1100 + * @tc.desc: Normal testCase of NDK store for Delete with wrong table or table is NULL. + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_1100',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_1100' , ' begin'); + let re = testNapi.SUB_DDM_RDB_1100(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_1200 + * @tc.desc: Normal testCase of NDK store for Delete with wrong predicates. + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_1200',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_1200' , ' begin'); + let re = testNapi.SUB_DDM_RDB_1200(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_1300 + * @tc.desc: Normal testCase of NDK store for Delete multiple. + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_1300',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_1300' , ' begin'); + let re = testNapi.SUB_DDM_RDB_1300(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_1400 + * @tc.desc: Normal testCase of NDK store for Transaction、Commit. + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_1400',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_1400' , ' begin'); + let re = testNapi.SUB_DDM_RDB_1400(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_1500 + * @tc.desc: Normal testCase of NDK store for Transaction、RollBack. + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_1500',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_1500' , ' begin'); + let re = testNapi.SUB_DDM_RDB_1500(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_1600 + * @tc.desc: Normal testCase of NDK store for Transaction、Commit. + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_1600',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_1600' , ' begin'); + let re = testNapi.SUB_DDM_RDB_1600(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_1700 + * @tc.desc: Normal testCase of NDK store for Transaction、Commit. + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_1700',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_1700' , ' begin'); + let re = testNapi.SUB_DDM_RDB_1700(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_1800 + * @tc.desc: Normal testCase of NDK store for GetVersion、SetVersion. + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_1800',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_1800' , ' begin'); + let re = testNapi.SUB_DDM_RDB_1800(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_1900 + * @tc.desc: Normal testCase of NDK store for Query with wrong columnNames. + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_1900',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_1900' , ' begin'); + let re = testNapi.SUB_DDM_RDB_1900(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_2000 + * @tc.desc: Normal testCase of NDK store for Update with wrong columnNames. + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_2000',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_2000' , ' begin'); + let re = testNapi.SUB_DDM_RDB_2000(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_2100 + * @tc.desc: Normal testCase of NDK store for Delete with wrong columnNames. + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_2100',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_2100' , ' begin'); + let re = testNapi.SUB_DDM_RDB_2100(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_2200 + * @tc.desc: Normal testCase of NDK store for Query with wrong length. + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_2200',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_2200' , ' begin'); + let re = testNapi.SUB_DDM_RDB_2200(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_2300 + * @tc.desc: Normal testCase of NDK store for Query with wrong length. + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_2300',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_2300' , ' begin'); + let re = testNapi.SUB_DDM_RDB_2300(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_2400 + * @tc.desc: Normal testCase of NDK store for Query with wrong length. + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_2400',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_2400' , ' begin'); + let re = testNapi.SUB_DDM_RDB_2400(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_2500 + * @tc.desc: Normal testCase of NDK store for Query with wrong length. + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_2500',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_2500' , ' begin'); + let re = testNapi.SUB_DDM_RDB_2500(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_2600 + * @tc.desc: Normal testCase of NDK store for Query with wrong length. + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_2600',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_2600' , ' begin'); + let re = testNapi.SUB_DDM_RDB_2600(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_2700 + * @tc.desc: Normal testCase of NDK store for Query with wrong length. + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_2700',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_2700' , ' begin'); + let re = testNapi.SUB_DDM_RDB_2700(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_2800 + * @tc.desc: Normal testCase of NDK store for Query with wrong length. + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_2800',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_2800' , ' begin'); + let re = testNapi.SUB_DDM_RDB_2800(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_2900 + * @tc.desc: Normal testCase of NDK store for Query with wrong length. + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_2900',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_2900' , ' begin'); + let re = testNapi.SUB_DDM_RDB_2900(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + /** + * @tc.name: SUB_DDM_RDB_3000 + * @tc.desc: Normal testCase of NDK store for Query with wrong length. + * @tc.type: FUNC + */ + it('SUB_DDM_RDB_3000',0, async function () { + hilog.info(0x0000, TAG, 'testTag SUB_DDM_RDB_3000' , ' begin'); + let re = testNapi.SUB_DDM_RDB_3000(); + hilog.info(0x0000, TAG, 'testTag errorCode is : '+ re , 'aa'); + expect(re == 0).assertTrue(); + }) + + + + }) +} \ No newline at end of file diff --git a/distributeddatamgr/relationalStoretest/rdbnapitest/entry/src/main/resources/base/element/string.json b/distributeddatamgr/relationalStoretest/rdbnapitest/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..498677efbde065c36668727190d3613cbf278bfc --- /dev/null +++ b/distributeddatamgr/relationalStoretest/rdbnapitest/entry/src/main/resources/base/element/string.json @@ -0,0 +1,20 @@ +{ + "string": [ + { + "name": "entry_MainAbility", + "value": "entry_MainAbility" + }, + { + "name": "description_mainability", + "value": "ETS_Empty Ability" + }, + { + "name": "TestAbility_desc", + "value": "description" + }, + { + "name": "TestAbility_label", + "value": "label" + } + ] +} \ No newline at end of file diff --git a/distributeddatamgr/relationalStoretest/rdbnapitest/entry/src/main/resources/base/media/icon.png b/distributeddatamgr/relationalStoretest/rdbnapitest/entry/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/distributeddatamgr/relationalStoretest/rdbnapitest/entry/src/main/resources/base/media/icon.png differ diff --git a/distributeddatamgr/relationalStoretest/rdbnapitest/signature/openharmony_sx.p7b b/distributeddatamgr/relationalStoretest/rdbnapitest/signature/openharmony_sx.p7b new file mode 100644 index 0000000000000000000000000000000000000000..0eeb485c43e346654972da51858f0358e6e8f704 Binary files /dev/null and b/distributeddatamgr/relationalStoretest/rdbnapitest/signature/openharmony_sx.p7b differ