Ocean
Loading...
Searching...
No Matches
TestBitstream.h
Go to the documentation of this file.
1/*
2 * Copyright (c) Meta Platforms, Inc. and affiliates.
3 *
4 * This source code is licensed under the MIT license found in the
5 * LICENSE file in the root directory of this source tree.
6 */
7
8#ifndef META_OCEAN_TEST_TESTIO_TEST_BITSTREAM_H
9#define META_OCEAN_TEST_TESTIO_TEST_BITSTREAM_H
10
12
13#include "ocean/io/Bitstream.h"
14
16
17namespace Ocean
18{
19
20namespace Test
21{
22
23namespace TestIO
24{
25
26/**
27 * This class implements a test for the Bitstream class.
28 * @ingroup testio
29 */
30class OCEAN_TEST_IO_EXPORT TestBitstream
31{
32 public:
33
34 /**
35 * Tests all functions of the Bitstream class.
36 * @param testDuration The number of seconds for each test
37 * @param selector The test selector
38 * @return True, if succeeded
39 */
40 static bool test(const double testDuration, const TestSelector& selector);
41
42 /**
43 * Tests the input and output bitstream functions.
44 * @return True, if succeeded
45 */
47
48 /**
49 * Reads one value from an input stream and checks whether the value matches with a given value.
50 * @param inputStream The input stream
51 * @param expectedValue The expected value
52 * @return True, if succeeded
53 * @tparam T The data type of the value to be read
54 */
55 template <typename T>
56 static bool readValue(IO::InputBitstream& inputStream, const T& expectedValue);
57};
58
59template <typename T>
60bool TestBitstream::readValue(IO::InputBitstream& inputStream, const T& expectedValue)
61{
62 ocean_assert(inputStream);
63
64 T value;
65 if (!inputStream.read<T>(value))
66 {
67 return false;
68 }
69
70 return value == expectedValue;
71}
72
73}
74
75}
76
77}
78
79#endif // META_OCEAN_TEST_TESTIO_TEST_BITSTREAM_H
This class implements an input bitstream.
Definition Bitstream.h:51
bool read(T &value)
Reads a value from the bitstream and moves the internal position inside the bitstream accordingly.
This class implements a test for the Bitstream class.
Definition TestBitstream.h:31
static bool testInputOutputBitstream()
Tests the input and output bitstream functions.
static bool test(const double testDuration, const TestSelector &selector)
Tests all functions of the Bitstream class.
static bool readValue(IO::InputBitstream &inputStream, const T &expectedValue)
Reads one value from an input stream and checks whether the value matches with a given value.
Definition TestBitstream.h:60
This class implements a test selector that parses test function strings and determines which tests sh...
Definition TestSelector.h:51
The namespace covering the entire Ocean framework.
Definition Accessor.h:15