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 "napi_parse_utils.h" 17 #include "napi_parse_utils.cpp" 18 #include <sys/mman.h> 19 #include <unistd.h> 20 #include <regex> 21 22 #include "nweb.h" 23 #include "nweb_log.h" 24 #include "ohos_adapter_helper.h" 25 #include "securec.h" 26 27 #include <gmock/gmock.h> 28 #include <gtest/gtest.h> 29 30 #define MAX_FLOWBUF_DATA_SIZE 52428800 /* 50 MB */ 31 32 namespace OHOS { 33 namespace NWeb { 34 std::shared_ptr<NapiParseUtils> g_utils; 35 class NapiParseUtilsTest : public testing::Test { 36 public: 37 static void SetUpTestCase(void); 38 static void TearDownTestCase(void); 39 void SetUp(); 40 void TearDown(); 41 }; 42 SetUpTestCase(void)43 void NapiParseUtilsTest::SetUpTestCase(void) 44 {} 45 TearDownTestCase(void)46 void NapiParseUtilsTest::TearDownTestCase(void) 47 {} 48 SetUp(void)49 void NapiParseUtilsTest::SetUp(void) 50 { 51 g_utils = std::make_shared<NapiParseUtils>(); 52 } 53 TearDown(void)54 void NapiParseUtilsTest::TearDown(void) 55 { 56 g_utils = nullptr; 57 } 58 TEST_F(NapiParseUtilsTest,IsFormatStringOfLength)59 TEST_F(NapiParseUtilsTest, IsFormatStringOfLength) 60 { 61 std::string str = "str"; 62 bool result = false; 63 result = IsFormatStringOfLength(str); 64 } 65 TEST_F(NapiParseUtilsTest,IsNumberOfLength)66 TEST_F(NapiParseUtilsTest, IsNumberOfLength) 67 { 68 std::string str = "str"; 69 bool result = false; 70 result = IsNumberOfLength(str); 71 } 72 TEST_F(NapiParseUtilsTest,ParseJsLengthStringToInt)73 TEST_F(NapiParseUtilsTest, ParseJsLengthStringToInt) 74 { 75 std::string input = "input"; 76 int32_t value = 32; 77 PixelUnit type = PixelUnit::PX; 78 g_utils->ParseJsLengthStringToInt(input, type, value); 79 } 80 } // namespace NWeb 81 } // namespace OHOS