| 184 | } |
| 185 | |
| 186 | void test_incomplete_checksum(const boost::shared_array<uint8_t> buf, uint32_t buf_len) { |
| 187 | // Make sure we still get that "not complete" error if |
| 188 | // it really isn't complete. |
| 189 | shared_ptr<TMemoryBuffer> membuf(new TMemoryBuffer()); |
| 190 | shared_ptr<TZlibTransport> zlib_trans(new TZlibTransport(membuf)); |
| 191 | zlib_trans->write(buf.get(), buf_len); |
| 192 | zlib_trans->finish(); |
| 193 | string tmp_buf; |
| 194 | membuf->appendBufferToString(tmp_buf); |
| 195 | tmp_buf.erase(tmp_buf.length() - 1); |
| 196 | membuf->resetBuffer(const_cast<uint8_t*>(reinterpret_cast<const uint8_t*>(tmp_buf.data())), |
| 197 | static_cast<uint32_t>(tmp_buf.length())); |
| 198 | |
| 199 | boost::shared_array<uint8_t> mirror(new uint8_t[buf_len]); |
| 200 | uint32_t got = zlib_trans->readAll(mirror.get(), buf_len); |
| 201 | BOOST_REQUIRE_EQUAL(got, buf_len); |
| 202 | BOOST_CHECK_EQUAL(memcmp(mirror.get(), buf.get(), buf_len), 0); |
| 203 | try { |
| 204 | zlib_trans->verifyChecksum(); |
| 205 | BOOST_ERROR("verifyChecksum() did not report an error"); |
| 206 | } catch (TTransportException& ex) { |
| 207 | BOOST_CHECK_EQUAL(ex.getType(), TTransportException::CORRUPTED_DATA); |
| 208 | } |
| 209 | } |
| 210 | |
| 211 | void test_read_write_mix(const boost::shared_array<uint8_t> buf, |
| 212 | uint32_t buf_len, |
nothing calls this directly
no test coverage detected