1 /* 2 * Copyright (c) 2021 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 #ifdef USE_RD_KERNEL 16 #ifndef DISTRIBUTEDDB_STORAGE_SINGLE_VER_NATURAL_STORE_TESTCASE_H 17 #define DISTRIBUTEDDB_STORAGE_SINGLE_VER_NATURAL_STORE_TESTCASE_H 18 19 #include <gtest/gtest.h> 20 #include "db_errno.h" 21 #include "distributeddb_data_generate_unit_test.h" 22 #include "distributeddb_tools_unit_test.h" 23 #include "multi_ver_natural_store.h" 24 #include "sqlite_local_kvdb.h" 25 #include "rd_single_ver_natural_store.h" 26 #include "rd_single_ver_natural_store_connection.h" 27 #include "sqlite_utils.h" 28 29 struct SyncData { 30 std::vector<uint8_t> hashKey; 31 std::vector<uint8_t> key; 32 std::vector<uint8_t> value; 33 uint64_t timestamp; 34 uint64_t flag; 35 std::string deviceInfo; 36 }; 37 38 class DistributedDBStorageRdSingleVerNaturalStoreTestCase final { 39 public: DistributedDBStorageRdSingleVerNaturalStoreTestCase()40 DistributedDBStorageRdSingleVerNaturalStoreTestCase() {}; ~DistributedDBStorageRdSingleVerNaturalStoreTestCase()41 ~DistributedDBStorageRdSingleVerNaturalStoreTestCase() {}; 42 43 static void SyncDatabaseOperate001(DistributedDB::RdSingleVerNaturalStore *&store, 44 DistributedDB::RdSingleVerNaturalStoreConnection *&connection); 45 46 static void SyncDatabaseOperate003(DistributedDB::RdSingleVerNaturalStore *&store, 47 DistributedDB::RdSingleVerNaturalStoreConnection *&connection); 48 49 static void SyncDatabaseOperate005(DistributedDB::RdSingleVerNaturalStore *&store, 50 DistributedDB::RdSingleVerNaturalStoreConnection *&connection); 51 52 static void SyncDatabaseOperate006(DistributedDB::RdSingleVerNaturalStore *&store, 53 DistributedDB::RdSingleVerNaturalStoreConnection *&connection); 54 55 private: 56 static bool IsSqlinteExistKey(const std::vector<SyncData> &vecSyncData, const std::vector<uint8_t> &key); 57 58 static void TestMetaDataPutAndGet(DistributedDB::RdSingleVerNaturalStore *&store, 59 DistributedDB::RdSingleVerNaturalStoreConnection *&connection); 60 61 static void TestMetaDataDeleteByPrefixKey(DistributedDB::RdSingleVerNaturalStore *&store, 62 DistributedDB::RdSingleVerNaturalStoreConnection *&connection); 63 64 static void DataBaseCommonPutOperate(DistributedDB::RdSingleVerNaturalStore *&store, 65 DistributedDB::RdSingleVerNaturalStoreConnection *&connection, DistributedDB::IOption option); 66 67 static void DataBaseCommonDeleteOperate(DistributedDB::RdSingleVerNaturalStore *&store, 68 DistributedDB::RdSingleVerNaturalStoreConnection *&connection, DistributedDB::IOption option); 69 70 static void DataBaseCommonGetOperate(DistributedDB::RdSingleVerNaturalStore *&store, 71 DistributedDB::RdSingleVerNaturalStoreConnection *&connection, DistributedDB::IOption option); 72 }; 73 #endif 74 #endif // USE_RD_KERNEL