1 #include "iobuffer.hpp"
3 #include <glog/logging.h>
5 const auto N
= 100'000;
11 // fill v with values [0..N-1]
13 for (size_t i
= 0; i
< N
; ++i
)
14 *(v
.data() + i
) = i
& 0x7F;
16 // chop off the end of v, which now should be [0..N/2], but
17 // the other N/2 values should remain in memory
23 // verify the values are unchanged
24 CHECK_EQ(v
.size(), N
);
25 for (size_t i
= 0; i
< N
; ++i
) {
26 CHECK_EQ(*(v
.data() + i
), i
& 0x7F);
29 iobuffer
<char> q(std::move(v
));
31 CHECK_EQ(q
.size(), N
);
32 for (size_t i
= 0; i
< N
; ++i
) {
33 CHECK_EQ(*(q
.data() + i
), i
& 0x7F);
36 iobuffer
<char> qq(std::move(q
));
38 CHECK_EQ(qq
.size(), N
);
39 for (size_t i
= 0; i
< N
; ++i
) {
40 CHECK_EQ(*(qq
.data() + i
), i
& 0x7F);
43 iobuffer
<char> qqq(std::move(qq
));
45 CHECK_EQ(qqq
.size(), N
);
46 for (size_t i
= 0; i
< N
; ++i
) {
47 CHECK_EQ(*(qqq
.data() + i
), i
& 0x7F);