1/* 2 * Copyright (c) Huawei Device Co., Ltd. 2023 - 2024. All rights reserved. 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#ifndef PANDA_ES2PANDA_UNIT_GTEST_H 17#define PANDA_ES2PANDA_UNIT_GTEST_H 18 19#include <gtest/gtest.h> 20#include <memory> 21#include <libpandabase/mem/arena_allocator.h> 22#include <libpandabase/mem/pool_manager.h> 23 24namespace ark::es2panda::testing { 25 26class Es2pandaUnitGtest : public ::testing::Test { 27public: 28 Es2pandaUnitGtest() : allocator_(std::make_unique<ArenaAllocator>(SpaceType::SPACE_TYPE_COMPILER)) {} 29 30 static void SetUpTestCase() 31 { 32 constexpr auto COMPILER_SIZE = operator""_MB(256ULL); 33 mem::MemConfig::Initialize(0, 0, COMPILER_SIZE, 0, 0, 0); 34 PoolManager::Initialize(); 35 } 36 37 ArenaAllocator *Allocator() 38 { 39 return allocator_.get(); 40 } 41 42private: 43 std::unique_ptr<ArenaAllocator> allocator_; 44}; 45 46} // namespace ark::es2panda::testing 47#endif // PANDA_ES2PANDA_UNIT_GTEST_H 48