9 #ifndef _STRIOSTREAM_TEST_H_
10 #define _STRIOSTREAM_TEST_H_
14 #include <cxxtest/TestSuite.h>
30 strIOStream <<
"Hello";
31 TS_ASSERT_EQUALS( str,
"Hello" );
34 strIOStream.
write(
" Worldly", 6 );
35 TS_ASSERT_EQUALS( str,
"Hello World" );
43 unsigned short foo( ( (
'<' >> 2 ) << 8 ) | (
'E' >> 2 ) );
45 TS_ASSERT_EQUALS( str,
"E<" );
48 unsigned short bar(
'*' >> 1 | 1 );
50 TS_ASSERT_EQUALS( str,
"*" );
56 const int nValues = 16;
57 long long values[nValues] = { -0x1234567812345678LL,
77 for(
int i = 0; i < nValues; ++i )
79 long long value = values[i];
83 TS_ASSERT_EQUALS( value, newValue );
90 Str str(
"Hello World" );
94 strIOStream.
read( buffer, 5 );
95 TS_ASSERT_SAME_DATA( buffer,
"Hello", 5 );
96 TS_ASSERT_EQUALS( strIOStream.
bytesRead(), 5U );
98 strIOStream.
read( buffer, 20 );
99 TS_ASSERT_SAME_DATA( buffer,
" World", 6 );
100 TS_ASSERT_EQUALS( strIOStream.
bytesRead(), 6U );
107 Str str(
"Hello World" );
111 strIOStream.
readUntil( buffer, 11,
'o' );
112 TS_ASSERT_SAME_DATA( buffer,
"Hello", 6 );
113 TS_ASSERT_EQUALS( strIOStream.
bytesRead(), 5U );
116 TS_ASSERT_SAME_DATA( buffer,
" World", 6 );
117 TS_ASSERT_EQUALS( strIOStream.
bytesRead(), 6U );
123 #endif // _STRIOSTREAM_TEST_H
virtual OutStream & write(const char *buffer, size_t num)
writes num bytes from buffer to the output buffer/stream
Definition: StrIOStream.h:84
size_t bytesRead()
Indicates the number of bytes read in the last operation.
Definition: InStream.h:162
OutStream & writeUShortCompact(const unsigned short &value)
writes an unsigned short integer as 1 to 3 bytes, encoded as follows: xxxxxxx0 - 7 bit value...
Definition: OutStream.cpp:86
void clear()
Definition: StrIOStream.h:60
void testWrite(void)
Definition: StrIOStream_Test.h:26
virtual InStream & read(char *buffer, size_t num)
reads num bytes from stream to the buffer
Definition: StrIOStream.h:38
void testWriteUShortCompact(void)
Definition: StrIOStream_Test.h:39
OutStream & writeLongLongCompact(const long long &value)
writes a signed long long integer as 1 to 9 bytes, encoded as follows: 0xxxxxxx - 7 bit value...
Definition: OutStream.cpp:121
Wraps a Str with an IOStream class.
Definition: StrIOStream.h:24
Replacement for standard template class string.
Definition: Str.h:12
InStream & readLongLongCompact(long long &value)
reads a signed long long integer as 1 to 9 bytes, encoded as follows: 0xxxxxxx - 7 bit value...
Definition: InStream.cpp:130
Unit tests for StrIOStream class.
Definition: StrIOStream_Test.h:21
void testRead(void)
Definition: StrIOStream_Test.h:88
void testReadUntil(void)
Definition: StrIOStream_Test.h:105
static const Str EMPTY_STR
Definition: Str.h:19
size_t bytesWritten()
Definition: OutStream.h:203
void testLongLongCompact(void)
Definition: StrIOStream_Test.h:54
Contains the StrIOStream class declaration.
virtual InStream & readUntil(char *buf, unsigned int num, unsigned char match)
Definition: InStream.cpp:242