1 /*
2 * Copyright (c) 2024 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 #include "rdb_sql_utils.h"
17
18 #include <gtest/gtest.h>
19
20 #include <climits>
21 #include <string>
22
23 #include "grd_type_export.h"
24 #include "rd_utils.h"
25
26 using namespace testing::ext;
27 using namespace OHOS::NativeRdb;
28
29 class RdbSqlUtilsTest : public testing::Test {
30 public:
31 static void SetUpTestCase(void);
32 static void TearDownTestCase(void);
SetUp(void)33 void SetUp(void){};
TearDown(void)34 void TearDown(void){};
35 };
36
SetUpTestCase(void)37 void RdbSqlUtilsTest::SetUpTestCase(void)
38 {
39 }
40
TearDownTestCase(void)41 void RdbSqlUtilsTest::TearDownTestCase(void)
42 {
43 }
44
45 /**
46 * @tc.name: RdbStore_SqliteUtils_001
47 * @tc.desc: Normal testCase of sqlite_utils for IsSpecial, if sqlType is special
48 * @tc.type: FUNC
49 */
50 HWTEST_F(RdbSqlUtilsTest, RdbSqlUtils_Test_001, TestSize.Level1)
51 {
52 auto [dataBasePath, errCode] = RdbSqlUtils::GetDefaultDatabasePath("/data/test", "RdbTest.db");
53 EXPECT_EQ(dataBasePath, "/data/test/rdb/RdbTest.db");
54 EXPECT_EQ(errCode, E_OK);
55
56 auto [dataBasePath1, errCode1] = RdbSqlUtils::GetDefaultDatabasePath("/data/test", "RdbTest.db", "myself");
57 EXPECT_EQ(dataBasePath1, "/data/test/rdb/myself/RdbTest.db");
58 EXPECT_EQ(errCode1, E_OK);
59 }
60