1 /* 2 * Copyright (c) 2025 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 "util.h" 19 20 namespace OHOS { 21 namespace MMI { 22 namespace { 23 using namespace testing::ext; 24 using namespace OHOS; 25 } // namespace 26 27 class UtilCommonTest : public testing::Test { 28 public: SetUpTestCase(void)29 static void SetUpTestCase(void) {} TearDownTestCase(void)30 static void TearDownTestCase(void) {} 31 }; 32 33 /** 34 * @tc.name:IsInteger_001 35 * @tc.desc:Verify enum add 36 * @tc.type: FUNC 37 * @tc.require: 38 */ 39 HWTEST_F(UtilCommonTest, IsInteger_001, TestSize.Level1) 40 { 41 EXPECT_TRUE(IsInteger("0")); 42 EXPECT_TRUE(IsInteger("123456")); 43 EXPECT_TRUE(IsInteger("-0")); 44 EXPECT_TRUE(IsInteger("-1")); 45 EXPECT_TRUE(IsInteger("-918273645")); 46 EXPECT_TRUE(IsInteger(" -918273645 ")); 47 EXPECT_FALSE(IsInteger("a -918273645 ")); 48 EXPECT_FALSE(IsInteger(" -918273645 b")); 49 EXPECT_FALSE(IsInteger("-")); 50 EXPECT_FALSE(IsInteger("-918273645a")); 51 EXPECT_FALSE(IsInteger("b-918273645")); 52 EXPECT_FALSE(IsInteger("-91827a3645")); 53 EXPECT_FALSE(IsInteger(".1")); 54 EXPECT_FALSE(IsInteger("1.")); 55 EXPECT_FALSE(IsInteger("1.0")); 56 EXPECT_FALSE(IsInteger("-1.0")); 57 } 58 } // namespace MMI 59 } // namespace OHOS