1 /*
2  * Copyright (C) 2023 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 
16 #ifndef SECURITY_GUARD_RESULT_SET_MOCK_H
17 #define SECURITY_GUARD_RESULT_SET_MOCK_H
18 
19 #include <cstdint>
20 #include <string>
21 
22 #include "gtest/gtest.h"
23 #include "gmock/gmock.h"
24 
25 namespace OHOS::NativeRdb {
26 class ResultSetInterface {
27 public:
28     virtual ~ResultSetInterface() = default;
29     virtual int GetBlob(int columnIndex, std::vector<uint8_t> &blob) = 0;
30     virtual int GetString(int columnIndex, std::string &value) = 0;
31     virtual int GetInt(int columnIndex, int &value) = 0;
32     virtual int GetLong(int columnIndex, int64_t &value) = 0;
33     virtual int GetDouble(int columnIndex, double &value) = 0;
34     virtual int GetSize(int columnIndex, size_t &size) = 0;
35     virtual int IsColumnNull(int columnIndex, bool &isNull) = 0;
36     virtual int GoToRow(int position) = 0;
37     virtual int GetAllColumnNames(std::vector<std::string> &columnNames) = 0;
38     virtual int GetRowCount(int &count) = 0;
39     virtual bool OnGo(int oldRowIndex, int newRowIndex) = 0;
40     virtual int Close() = 0;
41     virtual bool HasBlock() const = 0;
42     virtual int GetColumnCount(int &count) = 0;
43     virtual int GoToNextRow() = 0;
44 };
45 
46 class ResultSet : public ResultSetInterface {
47 public:
48     ResultSet() = default;
49     ~ResultSet() override = default;
50     MOCK_METHOD2(GetBlob, int(int columnIndex, std::vector<uint8_t> &blob));
51     MOCK_METHOD2(GetString, int(int columnIndex, std::string &value));
52     MOCK_METHOD2(GetInt, int(int columnIndex, int &value));
53     MOCK_METHOD2(GetLong, int(int columnIndex, int64_t &value));
54     MOCK_METHOD2(GetDouble, int(int columnIndex, double &value));
55     MOCK_METHOD2(GetSize, int(int columnIndex, size_t &size));
56     MOCK_METHOD2(IsColumnNull, int(int columnIndex, bool &isNull));
57     MOCK_METHOD1(GoToRow, int(int position));
58     MOCK_METHOD1(GetAllColumnNames, int(std::vector<std::string> &columnNames));
59     MOCK_METHOD1(GetRowCount, int(int &count));
60     MOCK_METHOD2(OnGo, bool(int oldRowIndex, int newRowIndex));
61     MOCK_METHOD0(Close, int());
62     MOCK_CONST_METHOD0(HasBlock, bool());
63     MOCK_METHOD1(GetColumnCount, int(int &count));
64     MOCK_METHOD0(GoToNextRow, int());
65 };
66 } // namespace OHOS::NativeRdb
67 #endif // SECURITY_GUARD_RESULT_SET_MOCK_H