MRPT  1.9.9
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 CMemoryStream
This CStream derived class allow using a memory buffer as a CStream.
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...
uint64_t getPosition() const override
Method for getting the current cursor position, where 0 is the first byte and TotalBytesCount-1 the l...
EXPECT_EQ(out.image_pair_was_used.size(), NUM_IMGS)
size_t Read(void *Buffer, size_t Count) override
Introduces a pure virtual method responsible for reading from the stream.
TEST(CMemoryStream, readwrite)
size_t Write(const void *Buffer, size_t Count) override
Introduces a pure virtual method responsible for writing to the stream.



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: c7a3bec24 Sun Mar 29 18:33:13 2020 +0200 at dom mar 29 18:50:38 CEST 2020