MRPT  2.0.4
CMemoryStream_unittest.cpp
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | https://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2020, Individual contributors, see AUTHORS file |
6  | See: https://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See: https://www.mrpt.org/License |
8  +------------------------------------------------------------------------+ */
9 
10 #include <gtest/gtest.h>
11 #include <mrpt/io/CMemoryStream.h>
12 
13 TEST(CMemoryStream, readwrite)
14 {
16 
17  buf.Write("1234567890", 10);
18  EXPECT_EQ(buf.getPosition(), 10U);
19 
20  buf.Write("123456789", 9);
21  EXPECT_EQ(buf.getPosition(), 19U);
22 
23  buf.Seek(0);
24  EXPECT_EQ(buf.getPosition(), 0U);
25 
26  char r[100];
27  auto nRead = buf.Read(r, 1);
28 
29  EXPECT_EQ(nRead, 1U);
30  EXPECT_EQ(r[0], '1');
31 
32  nRead = buf.Read(&r[1], 100);
33 
34  EXPECT_EQ(nRead, 18U);
35  EXPECT_EQ(r[18], '9');
36 }
mrpt::io::CMemoryStream::Seek
uint64_t Seek(int64_t Offset, CStream::TSeekOrigin Origin=sFromBeginning) override
Introduces a pure virtual method for moving to a specified position in the streamed resource.
Definition: CMemoryStream.cpp:126
CMemoryStream.h
mrpt::utils::CMemoryStream
mrpt::io::CMemoryStream CMemoryStream
Definition: utils/CMemoryStream.h:5
EXPECT_EQ
EXPECT_EQ(out.image_pair_was_used.size(), NUM_IMGS)
mrpt::io::CMemoryStream::getPosition
uint64_t getPosition() const override
Method for getting the current cursor position, where 0 is the first byte and TotalBytesCount-1 the l...
Definition: CMemoryStream.cpp:147
mrpt::io::CMemoryStream
This CStream derived class allow using a memory buffer as a CStream.
Definition: io/CMemoryStream.h:26
mrpt::io::CMemoryStream::Write
size_t Write(const void *Buffer, size_t Count) override
Introduces a pure virtual method responsible for writing to the stream.
Definition: CMemoryStream.cpp:103
TEST
TEST(CMemoryStream, readwrite)
Definition: CMemoryStream_unittest.cpp:13
mrpt::io::CMemoryStream::Read
size_t Read(void *Buffer, size_t Count) override
Introduces a pure virtual method responsible for reading from the stream.
Definition: CMemoryStream.cpp:86



Page generated by Doxygen 1.8.17 for MRPT 2.0.4 at Sun Jul 19 17:54:30 UTC 2020