Line data Source code
1 : // Copyright (c) 2011-2018 The Bitcoin Core developers 2 : // Distributed under the MIT software license, see the accompanying 3 : // file COPYING or http://www.opensource.org/licenses/mit-license.php. 4 : // 5 : #include "fs.h" 6 : #include "test/test_pivx.h" 7 : 8 : #include <boost/test/unit_test.hpp> 9 : 10 : BOOST_FIXTURE_TEST_SUITE(fs_tests, BasicTestingSetup) 11 : 12 2 : BOOST_AUTO_TEST_CASE(fsbridge_fstream) 13 : { 14 1 : fs::path tmpfolder = SetDataDir("fsbridge_fstream"); 15 : // tmpfile1 should be the same as tmpfile2 16 2 : fs::path tmpfile1 = tmpfolder / "fs_tests_₿_🏃"; 17 2 : fs::path tmpfile2 = tmpfolder / L"fs_tests_₿_🏃"; 18 1 : { 19 2 : fsbridge::ofstream file(tmpfile1); 20 1 : file << "bitcoin"; 21 : } 22 1 : { 23 1 : fsbridge::ifstream file(tmpfile2); 24 2 : std::string input_buffer; 25 1 : file >> input_buffer; 26 1 : BOOST_CHECK_EQUAL(input_buffer, "bitcoin"); 27 : } 28 1 : { 29 1 : fsbridge::ifstream file(tmpfile1, std::ios_base::in | std::ios_base::ate); 30 2 : std::string input_buffer; 31 1 : file >> input_buffer; 32 1 : BOOST_CHECK_EQUAL(input_buffer, ""); 33 : } 34 1 : { 35 2 : fsbridge::ofstream file(tmpfile2, std::ios_base::out | std::ios_base::app); 36 1 : file << "tests"; 37 : } 38 1 : { 39 1 : fsbridge::ifstream file(tmpfile1); 40 2 : std::string input_buffer; 41 1 : file >> input_buffer; 42 1 : BOOST_CHECK_EQUAL(input_buffer, "bitcointests"); 43 : } 44 1 : { 45 2 : fsbridge::ofstream file(tmpfile2, std::ios_base::out | std::ios_base::trunc); 46 1 : file << "bitcoin"; 47 : } 48 1 : { 49 1 : fsbridge::ifstream file(tmpfile1); 50 2 : std::string input_buffer; 51 1 : file >> input_buffer; 52 1 : BOOST_CHECK_EQUAL(input_buffer, "bitcoin"); 53 : } 54 1 : } 55 : 56 : BOOST_AUTO_TEST_SUITE_END()