| 1 |
#include "UnitTest++.h" |
| 2 |
|
| 3 |
#include "test_utils.hh" |
| 4 |
|
| 5 |
#include <sstream> |
| 6 |
|
| 7 |
#include "geners/ColumnBuffer.hh" |
| 8 |
#include "geners/binaryIO.hh" |
| 9 |
|
| 10 |
using namespace gs; |
| 11 |
using namespace std; |
| 12 |
|
| 13 |
namespace { |
| 14 |
TEST(ColumnBuffer) |
| 15 |
{ |
| 16 |
Private::ColumnBuffer b1; |
| 17 |
b1.podsize = sizeof(test_rng()); |
| 18 |
for (unsigned i=0; i<100; ++i) |
| 19 |
{ |
| 20 |
write_pod(b1.buf, test_rng()); |
| 21 |
++b1.lastrowp1; |
| 22 |
} |
| 23 |
|
| 24 |
std::ostringstream os; |
| 25 |
CHECK(b1.classId().write(os)); |
| 26 |
CHECK(b1.buf.classId().write(os)); |
| 27 |
CHECK(b1.write(os)); |
| 28 |
|
| 29 |
std::istringstream is(os.str()); |
| 30 |
Private::ColumnBuffer b2; |
| 31 |
ClassId bufid(is, 1); |
| 32 |
CHECK(bufid == b1.classId()); |
| 33 |
ClassId cid(is, 1); |
| 34 |
CHECK(cid == b1.buf.classId()); |
| 35 |
Private::ColumnBuffer::restore(bufid, cid, is, &b2); |
| 36 |
CHECK(b1 == b2); |
| 37 |
} |
| 38 |
} |