MCPcopy Create free account
hub / github.com/apache/thrift / test_incomplete_checksum

Function test_incomplete_checksum

lib/cpp/test/ZlibTest.cpp:186–209  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

184}
185
186void 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
211void test_read_write_mix(const boost::shared_array<uint8_t> buf,
212 uint32_t buf_len,

Callers

nothing calls this directly

Calls 10

appendBufferToStringMethod · 0.80
resetBufferMethod · 0.80
dataMethod · 0.80
verifyChecksumMethod · 0.80
writeMethod · 0.65
lengthMethod · 0.65
getMethod · 0.45
finishMethod · 0.45
readAllMethod · 0.45
getTypeMethod · 0.45

Tested by

no test coverage detected