Source: tests/io/ByteStreams.cpp
18 #include <myramath/io/detail/map.h> 21 #include <tests/myratest.h> 25 ADD_TEST(
"ByteStreams",
"[io]")
28 typedef std::map<int,double> Map;
33 myra::out() <<
"m1 = [ ";
34 for (
auto i = m1.begin(); i != m1.end(); ++i)
35 myra::out() <<
"(" << i->first <<
"," << i->second <<
") ";
36 myra::out() <<
"]" << std::endl;
39 std::vector<char> buffer(N,0);
44 myra::out() <<
"buffer = [ ";
45 for (
size_t n = 0; n < N; ++n)
46 myra::out() << (int) buffer[n] <<
" ";
47 myra::out() <<
"]" << std::endl;
50 auto m2 = in.read<Map>();
51 myra::out() <<
"m2 = [ ";
52 for (
auto i = m2.begin(); i != m2.end(); ++i)
53 myra::out() <<
"(" << i->first <<
"," << i->second <<
") ";
54 myra::out() <<
"]" << std::endl;
56 REQUIRE(m2.at(1) == 1.111);
57 REQUIRE(m2.at(2) == 2.222);
58 REQUIRE(m2.at(3) == 3.333);
59 REQUIRE(m2.size() == 3);
Counts up the size (in bytes) of an instance t of type T, that possesses a T::write(OutputStream) met...
size_t iosize(const T &t)
Returns the serialized size (in bytes) of a serializable type T.
Definition: iosize.h:45
Streams that serialize/deserialize to char* buffer.
An OutputStream that thinly wraps a char* buffer.
Definition: ByteStreams.h:20
Results: [PASS]
m1 = [ (1,1.111) (2,2.222) (3,3.333) ]
buffer = [ 3 0 0 0 0 0 0 0 1 0 0 0 45 -78 -99 -17 -89 -58 -15 63 2 0 0 0 45 -78 -99 -17 -89 -58 1 64 3 0 0 0 68 -117 108 -25 -5 -87 10 64 ]
m2 = [ (1,1.111) (2,2.222) (3,3.333) ]
Go back to Summary of /test programs.