1 #include "SockBuffer.hpp"
8 #include <fmt/format.h>
10 #include <glog/logging.h>
12 int main(int argc
, char* argv
[])
14 constexpr auto infile
= "body.txt";
16 int fd_in
= open(infile
, O_RDONLY
);
19 char outfile
[] = "/tmp/SockBuffer-test-XXXXXX";
21 int fd_out
= mkstemp(outfile
);
24 auto read_hook
= []() { std::cout
<< "read_hook\n"; };
26 boost::iostreams::stream
<SockBuffer
> iostream
{fd_in
,
29 std::chrono::seconds(10),
30 std::chrono::seconds(10),
31 std::chrono::seconds(1)};
34 while (std::getline(iostream
, line
)) {
35 iostream
<< line
<< '\n';
37 iostream
<< std::flush
;
39 auto const diff_cmd
{fmt::format("diff {} {}", infile
, outfile
)};
40 CHECK_EQ(system(diff_cmd
.c_str()), 0);
42 PCHECK(!unlink(outfile
)) << "unlink failed for " << outfile
;
44 std::cout
<< "sizeof(SockBuffer) == " << sizeof(SockBuffer
) << '\n';