C++ Utilities  4.6.1
Common C++ classes and routines used by my applications such as argument parser, IO and conversion utilities
iotests.cpp
Go to the documentation of this file.
1 #include "./testutils.h"
2 
3 #include "../io/binaryreader.h"
4 #include "../io/binarywriter.h"
5 #include "../io/bitreader.h"
6 #include "../io/path.h"
7 #include "../io/inifile.h"
8 #include "../io/copy.h"
9 #include "../io/catchiofailure.h"
10 
11 #include <cppunit/extensions/HelperMacros.h>
12 #include <cppunit/TestFixture.h>
13 
14 #include <fstream>
15 #include <sstream>
16 #include <algorithm>
17 
18 using namespace std;
19 using namespace IoUtilities;
20 
21 using namespace CPPUNIT_NS;
22 
26 class IoTests : public TestFixture
27 {
28  CPPUNIT_TEST_SUITE(IoTests);
29  CPPUNIT_TEST(testFailure);
30  CPPUNIT_TEST(testBinaryReader);
31  CPPUNIT_TEST(testBinaryWriter);
32  CPPUNIT_TEST(testBitReader);
33  CPPUNIT_TEST(testPathUtilities);
34  CPPUNIT_TEST(testIniFile);
35  CPPUNIT_TEST(testCopy);
36  CPPUNIT_TEST_SUITE_END();
37 
38 public:
39  void setUp();
40  void tearDown();
41 
42  void testFailure();
43  void testBinaryReader();
44  void testBinaryWriter();
45  void testBitReader();
46  void testPathUtilities();
47  void testIniFile();
48  void testCopy();
49 };
50 
52 
54 {}
55 
57 {}
58 
65 {
66  //fstream stream;
67  //stream.exceptions(ios_base::failbit | ios_base::badbit);
68  //CPPUNIT_ASSERT_THROW(stream.open("path/to/file/which/does/not/exist", ios_base::in), ios_base::failure);
69  // check other exceptions used by my applications, too
70  vector<int> testVec;
71  map<string, string> testMap;
72  CPPUNIT_ASSERT_THROW(testVec.at(1), out_of_range);
73  CPPUNIT_ASSERT_THROW(testMap.at("test"), out_of_range);
74 
75  // check workaround
76  try {
77  fstream stream;
78  stream.exceptions(ios_base::failbit | ios_base::badbit);
79  stream.open("path/to/file/which/does/not/exist", ios_base::in);
80  } catch(...) {
82  }
83 }
84 
89 {
90  // read test file
91  fstream testFile;
92  testFile.exceptions(ios_base::failbit | ios_base::badbit);
93  testFile.open(TestUtilities::testFilePath("some_data"), ios_base::in | ios_base::binary);
94  BinaryReader reader(&testFile);
95  CPPUNIT_ASSERT(reader.readUInt16LE() == 0x0102u);
96  CPPUNIT_ASSERT(reader.readUInt16BE() == 0x0102u);
97  CPPUNIT_ASSERT(reader.readUInt24LE() == 0x010203u);
98  CPPUNIT_ASSERT(reader.readUInt24BE() == 0x010203u);
99  CPPUNIT_ASSERT(reader.readUInt32LE() == 0x01020304u);
100  CPPUNIT_ASSERT(reader.readUInt32BE() == 0x01020304u);
101  CPPUNIT_ASSERT(reader.readUInt40LE() == 0x0102030405u);
102  CPPUNIT_ASSERT(reader.readUInt40BE() == 0x0102030405u);
103  CPPUNIT_ASSERT(reader.readUInt56LE() == 0x01020304050607u);
104  CPPUNIT_ASSERT(reader.readUInt56BE() == 0x01020304050607u);
105  CPPUNIT_ASSERT(reader.readUInt64LE() == 0x0102030405060708u);
106  CPPUNIT_ASSERT(reader.readUInt64BE() == 0x0102030405060708u);
107  testFile.seekg(0);
108  CPPUNIT_ASSERT(reader.readInt16LE() == 0x0102);
109  CPPUNIT_ASSERT(reader.readInt16BE() == 0x0102);
110  CPPUNIT_ASSERT(reader.readInt24LE() == 0x010203);
111  CPPUNIT_ASSERT(reader.readInt24BE() == 0x010203);
112  CPPUNIT_ASSERT(reader.readInt32LE() == 0x01020304);
113  CPPUNIT_ASSERT(reader.readInt32BE() == 0x01020304);
114  CPPUNIT_ASSERT(reader.readInt40LE() == 0x0102030405);
115  CPPUNIT_ASSERT(reader.readInt40BE() == 0x0102030405);
116  CPPUNIT_ASSERT(reader.readInt56LE() == 0x01020304050607);
117  CPPUNIT_ASSERT(reader.readInt56BE() == 0x01020304050607);
118  CPPUNIT_ASSERT(reader.readInt64LE() == 0x0102030405060708);
119  CPPUNIT_ASSERT(reader.readInt64BE() == 0x0102030405060708);
120  CPPUNIT_ASSERT(reader.readFloat32LE() == 1.125);
121  CPPUNIT_ASSERT(reader.readFloat64LE() == 1.625);
122  CPPUNIT_ASSERT(reader.readFloat32BE() == 1.125);
123  CPPUNIT_ASSERT(reader.readFloat64BE() == 1.625);
124  CPPUNIT_ASSERT(reader.readBool() == false);
125  CPPUNIT_ASSERT(reader.readBool() == true);
126  CPPUNIT_ASSERT(reader.readString(3) == "abc");
127  CPPUNIT_ASSERT(reader.readLengthPrefixedString() == "ABC");
128  CPPUNIT_ASSERT(reader.readTerminatedString() == "def");
129 }
130 
135 {
136  // prepare reading expected data
137  fstream testFile;
138  testFile.exceptions(ios_base::failbit | ios_base::badbit);
139  testFile.open(TestUtilities::testFilePath("some_data"), ios_base::in | ios_base::binary);
140 
141  // prepare output stream
142  stringstream outputStream(ios_base::in | ios_base::out | ios_base::binary);
143  outputStream.exceptions(ios_base::failbit | ios_base::badbit);
144  char testData[95];
145  outputStream.rdbuf()->pubsetbuf(testData, sizeof(testData));
146 
147  // write test data
148  BinaryWriter writer(&outputStream);
149  writer.writeUInt16LE(0x0102u);
150  writer.writeUInt16BE(0x0102u);
151  writer.writeUInt24LE(0x010203u);
152  writer.writeUInt24BE(0x010203u);
153  writer.writeUInt32LE(0x01020304u);
154  writer.writeUInt32BE(0x01020304u);
155  writer.writeUInt40LE(0x0102030405u);
156  writer.writeUInt40BE(0x0102030405u);
157  writer.writeUInt56LE(0x01020304050607u);
158  writer.writeUInt56BE(0x01020304050607u);
159  writer.writeUInt64LE(0x0102030405060708u);
160  writer.writeUInt64BE(0x0102030405060708u);
161 
162  // test written values
163  for(char c : testData) {
164  CPPUNIT_ASSERT(c == static_cast<char>(testFile.get()));
165  if(testFile.tellg() >= 58) {
166  break;
167  }
168  }
169  testFile.seekg(0);
170  outputStream.seekp(0);
171 
172  // write more test data
173  writer.writeInt16LE(0x0102);
174  writer.writeInt16BE(0x0102);
175  writer.writeInt24LE(0x010203);
176  writer.writeInt24BE(0x010203);
177  writer.writeInt32LE(0x01020304);
178  writer.writeInt32BE(0x01020304);
179  writer.writeInt40LE(0x0102030405);
180  writer.writeInt40BE(0x0102030405);
181  writer.writeInt56LE(0x01020304050607);
182  writer.writeInt56BE(0x01020304050607);
183  writer.writeInt64LE(0x0102030405060708);
184  writer.writeInt64BE(0x0102030405060708);
185  writer.writeFloat32LE(1.125);
186  writer.writeFloat64LE(1.625);
187  writer.writeFloat32BE(1.125);
188  writer.writeFloat64BE(1.625);
189  writer.writeBool(false);
190  writer.writeBool(true);
191  writer.writeString("abc");
192  writer.writeLengthPrefixedString("ABC");
193  writer.writeTerminatedString("def");
194 
195  // test written values
196  for(char c : testData) {
197  CPPUNIT_ASSERT(c == static_cast<char>(testFile.get()));
198  }
199 }
200 
205 {
206  const byte testData[] = {0x81, 0x90, 0x3C, 0x44, 0x28, 0x00, 0x44, 0x10, 0x20};
207  BitReader reader(reinterpret_cast<const char *>(testData), sizeof(testData));
208  CPPUNIT_ASSERT(reader.readBit() == 1);
209  reader.skipBits(6);
210  CPPUNIT_ASSERT(reader.showBits<byte>(2) == 3);
211  CPPUNIT_ASSERT(reader.readBits<byte>(2) == 3);
212  CPPUNIT_ASSERT(reader.readBits<uint32>(32) == (0x103C4428 << 1));
213  reader.align();
214  CPPUNIT_ASSERT(reader.readBits<byte>(8) == 0x44);
215  CPPUNIT_ASSERT(reader.readUnsignedExpGolombCodedBits<byte>() == 7);
216  CPPUNIT_ASSERT(reader.readSignedExpGolombCodedBits<sbyte>() == 4);
217  CPPUNIT_ASSERT(reader.readBit() == 0);
218  CPPUNIT_ASSERT(reader.readBit() == 0);
219  try {
220  reader.readBit();
221  } catch(...) {
222  catchIoFailure();
223  }
224 
225 }
226 
231 {
232  CPPUNIT_ASSERT_EQUAL("libc++utilities.so"s, fileName("/usr/lib/libc++utilities.so"));
233  CPPUNIT_ASSERT_EQUAL("/usr/lib/"s, directory("/usr/lib/libc++utilities.so"));
234  CPPUNIT_ASSERT(directory("libc++utilities.so").empty());
235  string invalidPath("lib/c++uti*lities.so?");
236  removeInvalidChars(invalidPath);
237  CPPUNIT_ASSERT(invalidPath == "libc++utilities.so");
238 #ifdef PLATFORM_UNIX
239  const string iniFilePath = TestUtilities::testFilePath("test.ini");
240  const string testFilesDir = iniFilePath.substr(0, iniFilePath.size() - 9);
241  auto testFilesDirEntries = directoryEntries(testFilesDir.c_str(), DirectoryEntryType::All);
242  CPPUNIT_ASSERT(find(testFilesDirEntries.cbegin(), testFilesDirEntries.cend(), "test.ini") != testFilesDirEntries.cend());
243  CPPUNIT_ASSERT(find(testFilesDirEntries.cbegin(), testFilesDirEntries.cend(), ".") != testFilesDirEntries.cend());
244  CPPUNIT_ASSERT(find(testFilesDirEntries.cbegin(), testFilesDirEntries.cend(), "..") != testFilesDirEntries.cend());
245  testFilesDirEntries = directoryEntries(testFilesDir.c_str(), DirectoryEntryType::Directory);
246  CPPUNIT_ASSERT(find(testFilesDirEntries.cbegin(), testFilesDirEntries.cend(), "test.ini") == testFilesDirEntries.cend());
247  CPPUNIT_ASSERT(find(testFilesDirEntries.cbegin(), testFilesDirEntries.cend(), ".") != testFilesDirEntries.cend());
248  CPPUNIT_ASSERT(find(testFilesDirEntries.cbegin(), testFilesDirEntries.cend(), "..") != testFilesDirEntries.cend());
249  testFilesDirEntries = directoryEntries(testFilesDir.c_str(), DirectoryEntryType::File);
250  CPPUNIT_ASSERT(find(testFilesDirEntries.cbegin(), testFilesDirEntries.cend(), "test.ini") != testFilesDirEntries.cend());
251  CPPUNIT_ASSERT(find(testFilesDirEntries.cbegin(), testFilesDirEntries.cend(), ".") == testFilesDirEntries.cend());
252  CPPUNIT_ASSERT(find(testFilesDirEntries.cbegin(), testFilesDirEntries.cend(), "..") == testFilesDirEntries.cend());
253 #endif
254 }
255 
260 {
261  // prepare reading test file
262  fstream inputFile;
263  inputFile.exceptions(ios_base::failbit | ios_base::badbit);
264  inputFile.open(TestUtilities::testFilePath("test.ini"), ios_base::in);
265 
266  IniFile ini;
267  ini.parse(inputFile);
268  const auto globalScope = ini.data().at(0);
269  const auto scope1 = ini.data().at(1);
270  const auto scope2 = ini.data().at(2);
271  CPPUNIT_ASSERT(globalScope.first.empty());
272  CPPUNIT_ASSERT(globalScope.second.find("key0") != globalScope.second.cend());
273  CPPUNIT_ASSERT(globalScope.second.find("key0")->second == "value 0");
274  CPPUNIT_ASSERT(globalScope.second.find("key1") == globalScope.second.cend());
275  CPPUNIT_ASSERT(scope1.first == "scope 1");
276  CPPUNIT_ASSERT(scope1.second.find("key1") != scope1.second.cend());
277  CPPUNIT_ASSERT(scope1.second.find("key1")->second == "value 1");
278  CPPUNIT_ASSERT(scope1.second.find("key2") != scope1.second.cend());
279  CPPUNIT_ASSERT(scope1.second.find("key2")->second == "value=2");
280  CPPUNIT_ASSERT(scope2.first == "scope 2");
281  CPPUNIT_ASSERT(scope2.second.find("key5") == scope2.second.cend());
282 
283  // write values to another file
284  fstream outputFile;
285  outputFile.exceptions(ios_base::failbit | ios_base::badbit);
286  outputFile.open(TestUtilities::testFilePath("output.ini"), ios_base::out | ios_base::trunc);
287  ini.make(outputFile);
288 
289  // parse written values (again)
290  outputFile.close();
291  outputFile.open(TestUtilities::testFilePath("output.ini"), ios_base::in);
292  IniFile ini2;
293  ini2.parse(outputFile);
294  CPPUNIT_ASSERT(ini.data() == ini2.data());
295 }
296 
301 {
302  // prepare streams
303  fstream testFile;
304  testFile.exceptions(ios_base::failbit | ios_base::badbit);
305  testFile.open(TestUtilities::testFilePath("some_data"), ios_base::in | ios_base::binary);
306  stringstream outputStream(ios_base::in | ios_base::out | ios_base::binary);
307  outputStream.exceptions(ios_base::failbit | ios_base::badbit);
308 
309  // copy
310  CopyHelper<13> copyHelper;
311  copyHelper.copy(testFile, outputStream, 50);
312 
313  // test
314  testFile.seekg(0);
315  for(byte i = 0; i < 50; ++i) {
316  CPPUNIT_ASSERT(testFile.get() == outputStream.get());
317  }
318 }
int64 readInt64LE()
Reads a 64-bit little endian signed integer from the current stream and advances the current position...
Definition: binaryreader.h:451
bool readBool()
Reads a boolean value from the current stream and advances the current position of the stream by one ...
Definition: binaryreader.h:506
void writeInt24LE(int32 value)
Writes a 24-bit little endian signed integer to the current stream and advances the current position ...
Definition: binarywriter.h:351
float32 readFloat32BE()
Reads a 32-bit big endian floating point value from the current stream and advances the current posit...
Definition: binaryreader.h:325
int64 readInt40BE()
Reads a 40-bit big endian signed integer from the current stream and advances the current position of...
Definition: binaryreader.h:259
int16 readInt16LE()
Reads a 16-bit little endian signed integer from the current stream and advances the current position...
Definition: binaryreader.h:343
void writeFloat64LE(float64 value)
Writes a 64-bit little endian floating point value to the current stream and advances the current pos...
Definition: binarywriter.h:457
void writeInt56LE(int64 value)
Writes a 56-bit big endian signed integer to the current stream and advances the current position of ...
Definition: binarywriter.h:411
Reads primitive data types from a std::istream.
Definition: binaryreader.h:12
float64 readFloat64LE()
Reads a 64-bit little endian floating point value from the current stream and advances the current po...
Definition: binaryreader.h:478
int32 readInt32LE()
Reads a 32-bit little endian signed integer from the current stream and advances the current position...
Definition: binaryreader.h:385
Writes primitive data types to a std::ostream.
Definition: binarywriter.h:14
float32 readFloat32LE()
Reads a 32-bit little endian floating point value from the current stream and advances the current po...
Definition: binaryreader.h:469
intType readSignedExpGolombCodedBits()
Reads "Exp-Golomb coded" bits (signed).
Definition: bitreader.h:121
uint32 readUInt24BE()
Reads a 24-bit big endian unsigned integer from the current stream and advances the current position ...
Definition: binaryreader.h:231
int16 readInt16BE()
Reads a 16-bit big endian signed integer from the current stream and advances the current position of...
Definition: binaryreader.h:199
intType readUnsignedExpGolombCodedBits()
Reads "Exp-Golomb coded" bits (unsigned).
Definition: bitreader.h:103
CPP_UTILITIES_EXPORT std::list< std::string > directoryEntries(const char *path, DirectoryEntryType types=DirectoryEntryType::All)
Returns the names of the directory entries in the specified path with the specified types...
Definition: path.cpp:181
void testBinaryReader()
Tests the most important methods of the BinaryReader.
Definition: iotests.cpp:88
void writeInt40LE(int64 value)
Writes a 40-bit big endian signed integer to the current stream and advances the current position of ...
Definition: binarywriter.h:391
The IoTests class tests classes and methods of the IoUtilities namespace.
Definition: iotests.cpp:26
void writeUInt24BE(uint32 value)
Writes a 24-bit big endian unsigned integer to the current stream and advances the current position o...
Definition: binarywriter.h:228
STL namespace.
void make(std::ostream &outputStream)
Write the current data to the specified outputStream.
Definition: inifile.cpp:154
void testCopy()
Tests CopyHelper.
Definition: iotests.cpp:300
void writeUInt16BE(uint16 value)
Writes a 16-bit big endian unsigned integer to the current stream and advances the current position o...
Definition: binarywriter.h:208
The CopyHelper class helps to copy bytes from one stream to another.
Definition: copy.h:17
void writeUInt56BE(uint64 value)
Writes a 56-bit big endian unsigned integer to the current stream and advances the current position o...
Definition: binarywriter.h:287
int64 readInt64BE()
Reads a 64-bit big endian signed integer from the current stream and advances the current position of...
Definition: binaryreader.h:307
void writeUInt40BE(uint64 value)
Writes a 40-bit big endian unsigned integer to the current stream and advances the current position o...
Definition: binarywriter.h:267
void writeUInt16LE(uint16 value)
Writes a 16-bit little endian unsigned integer to the current stream and advances the current positio...
Definition: binarywriter.h:341
void writeBool(bool value)
Writes a boolean value to the current stream and advances the current position of the stream by one b...
Definition: binarywriter.h:191
void writeUInt24LE(uint32 value)
Writes a 24-bit little endian unsigned integer to the current stream and advances the current positio...
Definition: binarywriter.h:362
The BitReader class provides bitwise reading of buffered data.
Definition: bitreader.h:14
float64 readFloat64BE()
Reads a 64-bit big endian floating point value from the current stream and advances the current posit...
Definition: binaryreader.h:334
std::vector< std::pair< std::string, std::multimap< std::string, std::string > > > & data()
Returns the data of the file.
Definition: inifile.h:38
int64 readInt56BE()
Reads a 56-bit big endian signed integer from the current stream and advances the current position of...
Definition: binaryreader.h:283
uint64 readUInt56LE()
Reads a 56-bit little endian unsigned integer from the current stream and advances the current positi...
Definition: binaryreader.h:441
void writeInt16LE(int16 value)
Writes a 16-bit little endian signed integer to the current stream and advances the current position ...
Definition: binarywriter.h:332
void writeLengthPrefixedString(const std::string &value)
Writes the length of a string and the string itself to the current stream.
uint32 readUInt32LE()
Reads a 32-bit little endian unsigned integer from the current stream and advances the current positi...
Definition: binaryreader.h:394
CPPUNIT_TEST_SUITE_REGISTRATION(IoTests)
void writeFloat64BE(float64 value)
Writes a 64-bit big endian floating point value to the current stream and advances the current positi...
Definition: binarywriter.h:323
void writeFloat32BE(float32 value)
Writes a 32-bit big endian floating point value to the current stream and advances the current positi...
Definition: binarywriter.h:314
uint32 readUInt32BE()
Reads a 32-bit big endian unsigned integer from the current stream and advances the current position ...
Definition: binaryreader.h:250
Contains utility classes helping to read and write streams.
Definition: binaryreader.h:10
void writeUInt40LE(uint64 value)
Writes a 40-bit big endian unsigned integer to the current stream and advances the current position o...
Definition: binarywriter.h:401
std::int8_t sbyte
signed byte
Definition: types.h:9
void setUp()
Definition: iotests.cpp:53
void testBinaryWriter()
Tests the most important methods of the BinaryWriter.
Definition: iotests.cpp:134
void writeString(const std::string &value)
Writes a string to the current stream and advances the current position of the stream by the length o...
Definition: binarywriter.h:466
uint64 readUInt40BE()
Reads a 40-bit big endian unsigned integer from the current stream and advances the current position ...
Definition: binaryreader.h:273
void writeInt56BE(int64 value)
Writes a 56-bit big endian signed integer to the current stream and advances the current position of ...
Definition: binarywriter.h:277
void copy(std::istream &input, std::ostream &output, std::size_t count)
Copies count bytes from input to output.
Definition: copy.h:41
uint64 readUInt64BE()
Reads a 64-bit big endian unsigned integer from the current stream and advances the current position ...
Definition: binaryreader.h:316
std::uint32_t uint32
unsigned 32-bit integer
Definition: types.h:44
void writeUInt56LE(uint64 value)
Writes a 56-bit big endian unsigned integer to the current stream and advances the current position o...
Definition: binarywriter.h:421
uint16 readUInt16LE()
Reads a 16-bit little endian unsigned integer from the current stream and advances the current positi...
Definition: binaryreader.h:352
uint16 readUInt16BE()
Reads a 16-bit big endian unsigned integer from the current stream and advances the current position ...
Definition: binaryreader.h:208
void writeUInt32LE(uint32 value)
Writes a 32-bit little endian unsigned integer to the current stream and advances the current positio...
Definition: binarywriter.h:381
int32 readInt24LE()
Reads a 24-bit little endian signed integer from the current stream and advances the current position...
Definition: binaryreader.h:361
void writeInt32LE(int32 value)
Writes a 32-bit little endian signed integer to the current stream and advances the current position ...
Definition: binarywriter.h:372
void writeInt16BE(int16 value)
Writes a 16-bit big endian signed integer to the current stream and advances the current position of ...
Definition: binarywriter.h:199
void testPathUtilities()
Tests fileName() and removeInvalidChars().
Definition: iotests.cpp:230
void testIniFile()
Tests IniFile.
Definition: iotests.cpp:259
void writeInt64LE(int64 value)
Writes a 64-bit little endian signed integer to the current stream and advances the current position ...
Definition: binarywriter.h:430
CPP_UTILITIES_EXPORT std::string directory(const std::string &path)
Returns the directory of the specified path string (including trailing slash).
Definition: path.cpp:52
std::string readTerminatedString(byte termination=0)
Reads a terminated string from the current stream.
void writeUInt32BE(uint32 value)
Writes a 32-bit big endian unsigned integer to the current stream and advances the current position o...
Definition: binarywriter.h:247
void writeInt24BE(int32 value)
Writes a 24-bit big endian signed integer to the current stream and advances the current position of ...
Definition: binarywriter.h:218
void skipBits(std::size_t bitCount)
Skips the specified number of bits without reading it.
Definition: bitreader.cpp:19
intType readBits(byte bitCount)
Reads the specified number of bits from the buffer advancing the current position by bitCount bits...
Definition: bitreader.h:68
void writeFloat32LE(float32 value)
Writes a 32-bit little endian floating point value to the current stream and advances the current pos...
Definition: binarywriter.h:448
void parse(std::istream &inputStream)
Parses all data from the specified inputStream.
Definition: inifile.cpp:18
int32 readInt32BE()
Reads a 32-bit big endian signed integer from the current stream and advances the current position of...
Definition: binaryreader.h:241
int32 readInt24BE()
Reads a 24-bit big endian signed integer from the current stream and advances the current position of...
Definition: binaryreader.h:217
std::uint8_t byte
unsigned byte
Definition: types.h:14
void writeInt64BE(int64 value)
Writes a 64-bit big endian signed integer to the current stream and advances the current position of ...
Definition: binarywriter.h:296
The IniFile class parses and makes INI files.
Definition: inifile.h:12
void testFailure()
Tests for GCC Bug 66145.
Definition: iotests.cpp:64
uint32 readUInt24LE()
Reads a 24-bit little endian unsigned integer from the current stream and advances the current positi...
Definition: binaryreader.h:375
int64 readInt56LE()
Reads a 56-bit little endian signed integer from the current stream and advances the current position...
Definition: binaryreader.h:427
void writeUInt64LE(uint64 value)
Writes a 64-bit little endian unsigned integer to the current stream and advances the current positio...
Definition: binarywriter.h:439
void writeInt32BE(int32 value)
Writes a 32-bit big endian signed integer to the current stream and advances the current position of ...
Definition: binarywriter.h:238
CPP_UTILITIES_EXPORT const char * catchIoFailure()
Provides a workaround for GCC Bug 66145.
CPP_UTILITIES_EXPORT std::string fileName(const std::string &path)
Returns the file name and extension of the specified path string.
Definition: path.cpp:32
uint64 readUInt64LE()
Reads a 64-bit little endian unsigned integer from the current stream and advances the current positi...
Definition: binaryreader.h:460
void testBitReader()
Tests the BitReader.
Definition: iotests.cpp:204
CPP_UTILITIES_EXPORT void removeInvalidChars(std::string &fileName)
Removes invalid characters from the specified fileName.
Definition: path.cpp:74
void align()
Re-establishes alignment.
Definition: bitreader.h:174
void tearDown()
Definition: iotests.cpp:56
std::string readLengthPrefixedString()
Reads a length prefixed string from the current stream.
byte readBit()
Reads the one bit from the buffer advancing the current position by one bit.
Definition: bitreader.h:89
void writeUInt64BE(uint64 value)
Writes a 64-bit big endian unsigned integer to the current stream and advances the current position o...
Definition: binarywriter.h:305
void writeTerminatedString(const std::string &value)
Writes a terminated string to the current stream and advances the current position of the stream by t...
Definition: binarywriter.h:474
uint64 readUInt56BE()
Reads a 56-bit big endian unsigned integer from the current stream and advances the current position ...
Definition: binaryreader.h:297
std::string readString(std::size_t length)
Reads a string from the current stream of the given length from the stream and advances the current p...
int64 readInt40LE()
Reads a 40-bit little endian signed integer from the current stream and advances the current position...
Definition: binaryreader.h:403
CPP_UTILITIES_EXPORT std::string testFilePath(const std::string &name)
Convenience function which returns the full path of the test file with the specified name...
Definition: testutils.h:92
intType showBits(byte bitCount)
Reads the specified number of bits from the buffer without advancing the current position.
Definition: bitreader.h:131
uint64 readUInt40LE()
Reads a 40-bit little endian unsigned integer from the current stream and advances the current positi...
Definition: binaryreader.h:417
void writeInt40BE(int64 value)
Writes a 40-bit big endian signed integer to the current stream and advances the current position of ...
Definition: binarywriter.h:257