LCOV - code coverage report
Current view: top level - src/test - fs_tests.cpp (source / functions) Hit Total Coverage
Test: total_coverage.info Lines: 36 36 100.0 %
Date: 2020-09-26 01:30:44 Functions: 9 9 100.0 %

          Line data    Source code
       1             : // Copyright (c) 2011-2019 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/util/setup_common.h>
       7             : #include <util/system.h>
       8             : 
       9             : #include <boost/test/unit_test.hpp>
      10             : 
      11          89 : BOOST_FIXTURE_TEST_SUITE(fs_tests, BasicTestingSetup)
      12             : 
      13          95 : BOOST_AUTO_TEST_CASE(fsbridge_fstream)
      14             : {
      15           1 :     fs::path tmpfolder = GetDataDir();
      16             :     // tmpfile1 should be the same as tmpfile2
      17           1 :     fs::path tmpfile1 = tmpfolder / "fs_tests_₿_🏃";
      18           1 :     fs::path tmpfile2 = tmpfolder / "fs_tests_₿_🏃";
      19             :     {
      20           1 :         fsbridge::ofstream file(tmpfile1);
      21           1 :         file << "bitcoin";
      22           1 :     }
      23             :     {
      24           1 :         fsbridge::ifstream file(tmpfile2);
      25           1 :         std::string input_buffer;
      26           1 :         file >> input_buffer;
      27           1 :         BOOST_CHECK_EQUAL(input_buffer, "bitcoin");
      28           1 :     }
      29             :     {
      30           1 :         fsbridge::ifstream file(tmpfile1, std::ios_base::in | std::ios_base::ate);
      31           1 :         std::string input_buffer;
      32           1 :         file >> input_buffer;
      33           1 :         BOOST_CHECK_EQUAL(input_buffer, "");
      34           1 :     }
      35             :     {
      36           1 :         fsbridge::ofstream file(tmpfile2, std::ios_base::out | std::ios_base::app);
      37           1 :         file << "tests";
      38           1 :     }
      39             :     {
      40           1 :         fsbridge::ifstream file(tmpfile1);
      41           1 :         std::string input_buffer;
      42           1 :         file >> input_buffer;
      43           1 :         BOOST_CHECK_EQUAL(input_buffer, "bitcointests");
      44           1 :     }
      45             :     {
      46           1 :         fsbridge::ofstream file(tmpfile2, std::ios_base::out | std::ios_base::trunc);
      47           1 :         file << "bitcoin";
      48           1 :     }
      49             :     {
      50           1 :         fsbridge::ifstream file(tmpfile1);
      51           1 :         std::string input_buffer;
      52           1 :         file >> input_buffer;
      53           1 :         BOOST_CHECK_EQUAL(input_buffer, "bitcoin");
      54           1 :     }
      55           1 : }
      56             : 
      57          89 : BOOST_AUTO_TEST_SUITE_END()

Generated by: LCOV version 1.15