PIVX Core  5.6.99
P2P Digital Currency
fs_tests.cpp
Go to the documentation of this file.
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 
11 
12 BOOST_AUTO_TEST_CASE(fsbridge_fstream)
13 {
14  fs::path tmpfolder = SetDataDir("fsbridge_fstream");
15  // tmpfile1 should be the same as tmpfile2
16  fs::path tmpfile1 = tmpfolder / "fs_tests_₿_🏃";
17  fs::path tmpfile2 = tmpfolder / L"fs_tests_₿_🏃";
18  {
19  fsbridge::ofstream file(tmpfile1);
20  file << "bitcoin";
21  }
22  {
23  fsbridge::ifstream file(tmpfile2);
24  std::string input_buffer;
25  file >> input_buffer;
26  BOOST_CHECK_EQUAL(input_buffer, "bitcoin");
27  }
28  {
29  fsbridge::ifstream file(tmpfile1, std::ios_base::in | std::ios_base::ate);
30  std::string input_buffer;
31  file >> input_buffer;
32  BOOST_CHECK_EQUAL(input_buffer, "");
33  }
34  {
35  fsbridge::ofstream file(tmpfile2, std::ios_base::out | std::ios_base::app);
36  file << "tests";
37  }
38  {
39  fsbridge::ifstream file(tmpfile1);
40  std::string input_buffer;
41  file >> input_buffer;
42  BOOST_CHECK_EQUAL(input_buffer, "bitcointests");
43  }
44  {
45  fsbridge::ofstream file(tmpfile2, std::ios_base::out | std::ios_base::trunc);
46  file << "bitcoin";
47  }
48  {
49  fsbridge::ifstream file(tmpfile1);
50  std::string input_buffer;
51  file >> input_buffer;
52  BOOST_CHECK_EQUAL(input_buffer, "bitcoin");
53  }
54 }
55 
BOOST_AUTO_TEST_SUITE_END()
BOOST_AUTO_TEST_CASE(fsbridge_fstream)
Definition: fs_tests.cpp:12
#define L(x0, x1, x2, x3, x4, x5, x6, x7)
Definition: jh.c:501
fs::ofstream ofstream
Definition: fs.h:93
fs::ifstream ifstream
Definition: fs.h:92
#define BOOST_FIXTURE_TEST_SUITE(a, b)
Definition: object.cpp:14
#define BOOST_CHECK_EQUAL(v1, v2)
Definition: object.cpp:18
Basic testing setup.
Definition: test_pivx.h:51