/* * Copyright (c) Contributors to the Open 3D Engine Project. * For complete copyright and license terms please see the LICENSE at the root of this distribution. * * SPDX-License-Identifier: Apache-2.0 OR MIT * */ #include #include #include namespace UnitTest { template class FileReaderTestFixture : public LeakDetectionFixture { public: void SetUp() override { if constexpr (AZStd::is_same_v) { m_fileIo = AZStd::make_unique(); } } void TearDown() override { m_fileIo.reset(); } protected: AZStd::unique_ptr m_fileIo{}; }; using FileIOTypes = ::testing::Types; TYPED_TEST_SUITE(FileReaderTestFixture, FileIOTypes); TYPED_TEST(FileReaderTestFixture, ConstructorWithFilePath_OpensFileSuccessfully) { AZ::IO::FileReader fileReader(this->m_fileIo.get(), AZ::IO::SystemFile::GetNullFilename()); EXPECT_TRUE(fileReader.IsOpen()); } TYPED_TEST(FileReaderTestFixture, Open_OpensFileSucessfully) { AZ::IO::FileReader fileReader; fileReader.Open(this->m_fileIo.get(), AZ::IO::SystemFile::GetNullFilename()); EXPECT_TRUE(fileReader.IsOpen()); } TYPED_TEST(FileReaderTestFixture, Eof_OnNULDeviceFile_Succeeds) { AZ::IO::FileReader fileReader(this->m_fileIo.get(), AZ::IO::SystemFile::GetNullFilename()); EXPECT_TRUE(fileReader.Eof()); } TYPED_TEST(FileReaderTestFixture, GetFilePath_ReturnsNULDeviceFilename_Succeeds) { AZ::IO::FileReader fileReader(this->m_fileIo.get(), AZ::IO::SystemFile::GetNullFilename()); AZ::IO::FixedMaxPath filePath; EXPECT_TRUE(fileReader.GetFilePath(filePath)); AZ::IO::FixedMaxPath nulFilename{ AZ::IO::SystemFile::GetNullFilename() }; if (this->m_fileIo) { EXPECT_TRUE(this->m_fileIo->ResolvePath(nulFilename, nulFilename)); } EXPECT_EQ(nulFilename, filePath); } } // namespace UnitTest