83629a0ddb486aaecb5068f5162488d210612155
[platform/core/appfw/librua.git] / tests / mock / sqlite3_mock.cc
1 /*
2  * Copyright (c) 2020 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 #include "mock_hook.h"
18 #include "test_fixture.h"
19 #include "sqlite3_mock.h"
20
21 typedef int(*cb)(void*, int);
22 typedef int(*execcb)(void*, int, char**, char**);
23 typedef void(*bindcb)(void*);
24
25 extern "C" int sqlite3_open_v2(const char* arg0,
26     sqlite3** arg1, int arg2, const char* arg3) {
27   return MOCK_HOOK_P4(SqlMock, sqlite3_open_v2, arg0, arg1, arg2, arg3);
28 }
29
30 extern "C" int sqlite3_close_v2(sqlite3* arg0) {
31   return MOCK_HOOK_P1(SqlMock, sqlite3_close_v2, arg0);
32 }
33
34 extern "C" void sqlite3_free_table(char** arg0) {
35   return MOCK_HOOK_P1(SqlMock, sqlite3_free_table, arg0);
36 }
37
38 extern "C" int sqlite3_busy_handler(sqlite3* arg0, cb arg1, void* arg2) {
39   return MOCK_HOOK_P3(SqlMock, sqlite3_busy_handler, arg0, arg1, arg2);
40 }
41
42 extern "C" int sqlite3_get_table(sqlite3* arg0, const char* arg1,
43     char*** arg2, int* arg3, int* arg4, char** arg5) {
44   return MOCK_HOOK_P6(SqlMock, sqlite3_get_table, arg0, arg1, arg2, arg3,
45       arg4, arg5);
46 }
47
48 extern "C" int sqlite3_exec(sqlite3* arg0, const char* arg1,
49     execcb arg2, void* arg3, char** arg4) {
50   return MOCK_HOOK_P5(SqlMock, sqlite3_exec, arg0, arg1, arg2, arg3, arg4);
51 }
52
53 extern "C" int sqlite3_prepare_v2(sqlite3* arg0, const char* arg1,
54     int arg2, sqlite3_stmt** arg3, const char** arg4) {
55   return MOCK_HOOK_P5(SqlMock, sqlite3_prepare_v2, arg0, arg1, arg2, arg3, arg4);
56 }
57
58 extern "C" int sqlite3_bind_text(sqlite3_stmt* arg0, int arg1, const char* arg2,
59     int arg3, bindcb arg4) {
60   return MOCK_HOOK_P5(SqlMock, sqlite3_bind_text, arg0, arg1, arg2, arg3, arg4);
61 }
62
63 extern "C" int sqlite3_bind_int(sqlite3_stmt* arg0, int arg1, int arg2) {
64   return MOCK_HOOK_P3(SqlMock, sqlite3_bind_int, arg0, arg1, arg2);
65 }
66
67 extern "C" int sqlite3_step(sqlite3_stmt* arg0) {
68   return MOCK_HOOK_P1(SqlMock, sqlite3_step, arg0);
69 }
70
71 extern "C" int sqlite3_finalize(sqlite3_stmt* arg0) {
72   return MOCK_HOOK_P1(SqlMock, sqlite3_finalize, arg0);
73 }