1 /* 2 * Copyright (c) 2022 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 "libpandabase/mem/space.h" 19 20 namespace panda::test { 21 22 HWTEST(MemSpaceTest, ToSpaceType, testing::ext::TestSize.Level0) 23 { 24 const size_t index = 1U; 25 ASSERT_EQ(index, static_cast<size_t>(ToSpaceType(index))); 26 } 27 28 HWTEST(MemSpaceTest, IsHeapSpace, testing::ext::TestSize.Level0) 29 { 30 ASSERT_TRUE(IsHeapSpace(SpaceType::SPACE_TYPE_OBJECT)); 31 } 32 33 HWTEST(MemSpaceTest, SpaceTypeToString, testing::ext::TestSize.Level0) 34 { 35 EXPECT_STREQ("ark-Undefined Space", SpaceTypeToString(SpaceType::SPACE_TYPE_UNDEFINED)); 36 EXPECT_STREQ("ark-Object Space", SpaceTypeToString(SpaceType::SPACE_TYPE_OBJECT)); 37 EXPECT_STREQ("ark-Humongous Object Space", SpaceTypeToString(SpaceType::SPACE_TYPE_HUMONGOUS_OBJECT)); 38 EXPECT_STREQ("ark-Non Movable Space", SpaceTypeToString(SpaceType::SPACE_TYPE_NON_MOVABLE_OBJECT)); 39 EXPECT_STREQ("ark-Internal Space", SpaceTypeToString(SpaceType::SPACE_TYPE_INTERNAL)); 40 EXPECT_STREQ("ark-Code Space", SpaceTypeToString(SpaceType::SPACE_TYPE_CODE)); 41 EXPECT_STREQ("ark-Compiler Space", SpaceTypeToString(SpaceType::SPACE_TYPE_COMPILER)); 42 EXPECT_STREQ("ark-Unknown Space", SpaceTypeToString(SpaceType::SPACE_TYPE_LAST)); 43 } 44 45 } // namespace panda::test 46