forked from bitcoin/bitcoin
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge bitcoin#13878: utils: Add fstream wrapper to allow to pass unic…
…ode filename on Windows 43c7fbb Make MSVC compiler read the source code using utf-8 (Chun Kuan Lee) f86a571 tests: Add test case for std::ios_base::ate (Chun Kuan Lee) a554cc9 Move boost/std fstream to fsbridge (Chun Kuan Lee) 86eb3b3 utils: Add fsbridge fstream function wrapper (Chun Kuan Lee) Pull request description: If compiled with mingw, use glibc++ extension `stdio_filebuf` to open the file by `FILE*` instead of filename. In other condition, we can use boost::fstream. Tree-SHA512: b5dbd83e347fb9b2a0c8b1c2c7bd71a272e839ec0617883b2a0ec12506ae9e825373cf6e95b9bcc91d7edc85bf51580a7716b56a9ecaad776bc3ae61638cb3da
- Loading branch information
Showing
9 changed files
with
228 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
// Copyright (c) 2011-2018 The Bitcoin Core developers | ||
// Distributed under the MIT software license, see the accompanying | ||
// file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||
// | ||
#include <fs.h> | ||
#include <test/test_bitcoin.h> | ||
|
||
#include <boost/test/unit_test.hpp> | ||
|
||
BOOST_FIXTURE_TEST_SUITE(fs_tests, BasicTestingSetup) | ||
|
||
BOOST_AUTO_TEST_CASE(fsbridge_fstream) | ||
{ | ||
fs::path tmpfolder = SetDataDir("fsbridge_fstream"); | ||
// tmpfile1 should be the same as tmpfile2 | ||
fs::path tmpfile1 = tmpfolder / "fs_tests_₿_🏃"; | ||
fs::path tmpfile2 = tmpfolder / L"fs_tests_₿_🏃"; | ||
{ | ||
fsbridge::ofstream file(tmpfile1); | ||
file << "bitcoin"; | ||
} | ||
{ | ||
fsbridge::ifstream file(tmpfile2); | ||
std::string input_buffer; | ||
file >> input_buffer; | ||
BOOST_CHECK_EQUAL(input_buffer, "bitcoin"); | ||
} | ||
{ | ||
fsbridge::ifstream file(tmpfile1, std::ios_base::in | std::ios_base::ate); | ||
std::string input_buffer; | ||
file >> input_buffer; | ||
BOOST_CHECK_EQUAL(input_buffer, ""); | ||
} | ||
{ | ||
fsbridge::ofstream file(tmpfile2, std::ios_base::out | std::ios_base::app); | ||
file << "tests"; | ||
} | ||
{ | ||
fsbridge::ifstream file(tmpfile1); | ||
std::string input_buffer; | ||
file >> input_buffer; | ||
BOOST_CHECK_EQUAL(input_buffer, "bitcointests"); | ||
} | ||
{ | ||
fsbridge::ofstream file(tmpfile2, std::ios_base::out | std::ios_base::trunc); | ||
file << "bitcoin"; | ||
} | ||
{ | ||
fsbridge::ifstream file(tmpfile1); | ||
std::string input_buffer; | ||
file >> input_buffer; | ||
BOOST_CHECK_EQUAL(input_buffer, "bitcoin"); | ||
} | ||
} | ||
|
||
BOOST_AUTO_TEST_SUITE_END() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters