call out non-ASCII
[ghsmtp.git] / iobuffer-test.cpp
blob375ef8940ccc530ab472780dd93d26b2595a33d5
1 #include "iobuffer.hpp"
3 #include <glog/logging.h>
5 const auto N = 100'000;
7 int main()
9 iobuffer<char> v;
11 // fill v with values [0..N-1]
12 v.resize(N);
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
18 v.resize(N / 2);
20 // grow back to N
21 v.resize(N);
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);