MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / TestSkipNBytes

Function TestSkipNBytes

tensorflow/core/lib/io/zlib_buffers_test.cc:256–293  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

254}
255
256void TestSkipNBytes(CompressionOptions input_options,
257 CompressionOptions output_options) {
258 Env* env = Env::Default();
259 string fname = testing::TmpDir() + "/zlib_buffers_test";
260 for (auto file_size : NumCopies()) {
261 string data = GenTestString(file_size);
262 for (auto input_buf_size : InputBufferSizes()) {
263 for (auto output_buf_size : OutputBufferSizes()) {
264 // Write the compressed file.
265 WriteCompressedFile(env, fname, input_buf_size, output_buf_size,
266 output_options, data);
267
268 // Boiler-plate to set up ZlibInputStream.
269 std::unique_ptr<RandomAccessFile> file_reader;
270 TF_ASSERT_OK(env->NewRandomAccessFile(fname, &file_reader));
271 std::unique_ptr<RandomAccessInputStream> input_stream(
272 new RandomAccessInputStream(file_reader.get()));
273 ZlibInputStream in(input_stream.get(), input_buf_size, output_buf_size,
274 input_options);
275
276 size_t data_half_size = data.size() / 2;
277 string second_half(data, data_half_size, data.size() - data_half_size);
278
279 // Skip past the first half of the file and expect Tell() returns
280 // correctly.
281 TF_ASSERT_OK(in.SkipNBytes(data_half_size));
282 EXPECT_EQ(in.Tell(), data_half_size);
283
284 // Expect that second half is read correctly and Tell() returns past
285 // end of file after reading complete file.
286 string bytes_read;
287 TF_ASSERT_OK(in.ReadNBytes(second_half.size(), &bytes_read));
288 EXPECT_EQ(bytes_read, second_half);
289 EXPECT_EQ(in.Tell(), data.size());
290 }
291 }
292 }
293}
294
295TEST(ZlibInputStream, TellDefaultOptions) {
296 TestTell(CompressionOptions::DEFAULT(), CompressionOptions::DEFAULT());

Callers 1

TESTFunction · 0.85

Calls 13

DefaultFunction · 0.85
TmpDirFunction · 0.85
NumCopiesFunction · 0.85
InputBufferSizesFunction · 0.85
OutputBufferSizesFunction · 0.85
WriteCompressedFileFunction · 0.85
GenTestStringFunction · 0.70
NewRandomAccessFileMethod · 0.45
getMethod · 0.45
sizeMethod · 0.45
SkipNBytesMethod · 0.45
TellMethod · 0.45

Tested by

no test coverage detected