From 0ad1996eb4a00f569a334ec0837165ac9f418662 Mon Sep 17 00:00:00 2001 From: ryne3366 Date: Fri, 9 May 2025 18:37:37 +0800 Subject: [PATCH] add unittest for sqlite Signed-off-by: ryne3366 --- bundle.json | 4 ++- unittest/BUILD.gn | 57 ++++++++++++++++++++++++++++++++++++++++ unittest/sqlite_test.cpp | 57 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 117 insertions(+), 1 deletion(-) create mode 100644 unittest/BUILD.gn create mode 100644 unittest/sqlite_test.cpp diff --git a/bundle.json b/bundle.json index b733d95..c6cf104 100644 --- a/bundle.json +++ b/bundle.json @@ -48,7 +48,9 @@ "name": "//third_party/sqlite:sqliteicu" } ], - "test": [] + "test": [ + "//third_party/sqlite/unittest:unittest" + ] } } } diff --git a/unittest/BUILD.gn b/unittest/BUILD.gn new file mode 100644 index 0000000..d32df9e --- /dev/null +++ b/unittest/BUILD.gn @@ -0,0 +1,57 @@ +# Copyright (c) 2025 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/test.gni") +import("//build/ohos.gni") + +module_output_path = "third_party_sqlite/third_party_sqlite" + +############################################################################### +config("module_private_config") { + visibility = [ ":*" ] + + defines = [ + ] + cflags_c = [ + "-fvisibility=hidden", + "-Wno-implicit-fallthrough", + ] + if (target_os != "ios") { + ldflags = [ "-Wl,--exclude-libs,ALL" ] + } +} + +ohos_unittest("libsqlittest") { + module_out_path = module_output_path + + sources = [ + "./sqlite_test.cpp", + ] + + configs = [ ":module_private_config" ] + + external_deps = [ + "c_utils:utils", + "googletest:gtest_main", + ] + + deps = [ + "//third_party/sqlite:sqlite", + ] +} + +############################################################################### +group("unittest") { + testonly = true + + deps = [ ":libsqlittest" ] +} \ No newline at end of file diff --git a/unittest/sqlite_test.cpp b/unittest/sqlite_test.cpp new file mode 100644 index 0000000..9db0369 --- /dev/null +++ b/unittest/sqlite_test.cpp @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2025 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 "sqlite3sym.h" + +using namespace testing::ext; + +class LibSQLiteTest : public testing::Test { +public: + static void SetUpTestCase(void); + static void TearDownTestCase(void); + void SetUp(); + void TearDown(); +}; + +void LibSQLiteTest::SetUpTestCase(void) +{ + mkdir("./sqlitetest", 0770); +} + +void LibSQLiteTest::TearDownTestCase(void) +{ +} + +void LibSQLiteTest::SetUp(void) +{ +} + +void LibSQLiteTest::TearDown(void) +{ +} + +/** + * @tc.name: Lib_SQLite_Test_001 + * @tc.desc: demo for LibSQLiteTest. + * @tc.type: FUNC + */ +HWTEST_F(LibSQLiteTest, Lib_SQLite_Test_001, TestSize.Level0) +{ +} -- Gitee