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 <gtest/gtest.h>
17
18 #include "libabckit/include/cpp/abckit_cpp.h"
19
20 namespace {
21 class ErrorHandler final : public abckit::IErrorHandler {
HandleError(abckit::Exception && e)22 void HandleError(abckit::Exception &&e) override
23 {
24 EXPECT_TRUE(false) << "Abckit exception raised: " << e.what();
25 }
26 };
27 } // namespace
28
29 namespace libabckit::test {
30
31 class AbckitRegressionTestCppAPI : public ::testing::Test {};
32
33 // Test: test-kind=regression, abc-kind=ArkTS1, category=positive, extension=cpp
TEST_F(AbckitRegressionTestCppAPI,LibAbcKitTestIssueIB1YEI)34 TEST_F(AbckitRegressionTestCppAPI, LibAbcKitTestIssueIB1YEI)
35 {
36 const std::string inputPath = ABCKIT_ABC_DIR "regression/issue_IB1YEI/issue_IB1YEI.abc";
37 abckit::File file(inputPath, std::make_unique<ErrorHandler>());
38 const std::string name = "new_module";
39
40 abckit::arkts::Module arktsModule = file.AddExternalModuleArktsV1(name.c_str());
41 abckit::core::Module coreModule = static_cast<abckit::core::Module>(arktsModule);
42 EXPECT_TRUE(coreModule);
43 }
44
45 } // namespace libabckit::test
46