2021-10-04 08:33:23 +00:00
|
|
|
|
/*
|
|
|
|
|
|
* synergy -- mouse and keyboard sharing utility
|
|
|
|
|
|
* Copyright (C) 2014-2021 Symless Ltd.
|
|
|
|
|
|
*
|
|
|
|
|
|
* This package is free software; you can redistribute it and/or
|
|
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
|
|
* found in the file LICENSE that should have accompanied this file.
|
|
|
|
|
|
*
|
|
|
|
|
|
* This package 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 "base/Path.h"
|
2024-07-04 09:14:54 +00:00
|
|
|
|
#include <filesystem>
|
2021-10-04 08:33:23 +00:00
|
|
|
|
#include <fstream>
|
|
|
|
|
|
|
2024-07-16 08:30:35 +00:00
|
|
|
|
#include <gtest/gtest.h>
|
2021-10-04 08:33:23 +00:00
|
|
|
|
|
2024-07-04 09:14:54 +00:00
|
|
|
|
const std::string testDir = "tmp/test";
|
|
|
|
|
|
const std::wstring testDirW = L"tmp/test";
|
|
|
|
|
|
|
2024-07-02 19:07:06 +00:00
|
|
|
|
TEST(PathTests, open_file_using_path) {
|
2024-07-04 09:14:54 +00:00
|
|
|
|
std::filesystem::create_directories(testDir);
|
|
|
|
|
|
|
|
|
|
|
|
std::string utf8FileName = testDir + "/тіás.txt";
|
2021-10-04 08:33:23 +00:00
|
|
|
|
#if SYSAPI_WIN32
|
2024-07-02 19:07:06 +00:00
|
|
|
|
// Windows uses UTF-16 for file path and names
|
2024-07-04 09:14:54 +00:00
|
|
|
|
std::wstring fileName =
|
|
|
|
|
|
testDirW + L"/\x0442\x0456\x00E1\x0073\x002E\x0074\x0078\x0074";
|
2021-10-04 08:33:23 +00:00
|
|
|
|
#else
|
2024-07-02 19:07:06 +00:00
|
|
|
|
std::string fileName = utf8FileName;
|
2021-10-04 08:33:23 +00:00
|
|
|
|
#endif
|
|
|
|
|
|
|
2024-07-02 19:07:06 +00:00
|
|
|
|
std::fstream file(fileName, std::fstream::out);
|
|
|
|
|
|
file << "test";
|
|
|
|
|
|
file.close();
|
2021-10-04 08:33:23 +00:00
|
|
|
|
|
2024-07-02 19:07:06 +00:00
|
|
|
|
std::ifstream inFile(synergy::filesystem::path(utf8FileName));
|
|
|
|
|
|
EXPECT_TRUE(inFile.is_open());
|
2021-10-04 08:33:23 +00:00
|
|
|
|
}
|