Descent3/ddio/tests/ddio_tests.cpp
Azamat H. Hackimov 511743d4b3 Implementing new ddio_GetTmpFileName()
New function uses std::filesystem::path and generates result faster than ddio_GetTempFileName() (benchmarked on Linux).
2024-09-18 21:23:18 +03:00

31 lines
1.1 KiB
C++

/*
* Descent 3
* Copyright (C) 2024 Descent Developers
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <filesystem>
#include <gtest/gtest.h>
#include "ddio.h"
TEST(D3, DDIO_GetTmpFileName) {
std::filesystem::path temp_dir = std::filesystem::temp_directory_path();
std::filesystem::path result = ddio_GetTmpFileName(temp_dir, "prefix_");
EXPECT_FALSE(result.empty());
EXPECT_EQ(result.extension(), ".tmp");
EXPECT_TRUE(canonical(result.parent_path()) == canonical(temp_dir));
}