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 "ecmascript/platform/file.h" 17#include "ecmascript/tests/test_helper.h" 18 19using namespace panda::ecmascript; 20using namespace panda::ecmascript::base; 21 22namespace panda::test { 23class FilePathHelperTest : public BaseTestWithScope<false> { 24}; 25 26HWTEST_F_L0(FilePathHelperTest, RealPath) 27{ 28 std::string filePath = "__FilePathHelperTest.test"; 29 EXPECT_TRUE(std::fopen(filePath.c_str(), "r") == nullptr); 30 31 std::string realPath; 32 bool result = RealPath(filePath, realPath, false); 33 EXPECT_EQ(result, true); 34 35 std::fstream stream {}; 36 stream.open(realPath, std::ios::out); 37 EXPECT_EQ(stream.good(), true); 38 EXPECT_TRUE(std::fopen(realPath.c_str(), "r") != nullptr); 39 40 stream.close(); 41 stream.clear(); 42 std::remove(filePath.c_str()); 43 std::remove(realPath.c_str()); 44} 45} // namespace panda::test 46