File: tmappedfile.cpp

package info (click to toggle)
wsclean 3.6-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 16,296 kB
  • sloc: cpp: 129,246; python: 22,066; sh: 360; ansic: 230; makefile: 185
file content (37 lines) | stat: -rw-r--r-- 796 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include "../../system/mappedfile.h"

#include <boost/filesystem/operations.hpp>
#include <boost/test/unit_test.hpp>

#include <fstream>

namespace wsclean {

BOOST_AUTO_TEST_SUITE(mapped_file)

BOOST_AUTO_TEST_CASE(map) {
  constexpr size_t kSize = 16;
  constexpr const char* kFilename = "tmappedfile-test.tmp";

  std::ofstream file(kFilename);
  char data[kSize];
  std::fill_n(data, kSize, 1);
  file.write(data, kSize);
  file.close();

  MappedFile file_a;
  MappedFile file_b(kFilename, kSize);
  for (size_t i = 0; i != kSize; ++i) {
    file_b.Data()[i] = i + 7;
  }
  file_a = std::move(file_b);
  for (size_t i = 0; i != kSize; ++i) {
    BOOST_CHECK_EQUAL(file_a.Data()[i], i + 7);
  }

  boost::filesystem::remove(kFilename);
}

BOOST_AUTO_TEST_SUITE_END()

}  // namespace wsclean