37 CPPUNIT_ASSERT(b->
getData() == 0);
42 CPPUNIT_ASSERT(b1.getData() == 0);
43 CPPUNIT_ASSERT(b1.capacity() == 0);
44 CPPUNIT_ASSERT(b1.bytesUsed() == 0);
55 CPPUNIT_ASSERT(b->
getData() != 0);
56 CPPUNIT_ASSERT(b->
capacity() == 100);
60 CPPUNIT_ASSERT(b1.getData() != 0);
61 CPPUNIT_ASSERT(b1.capacity() == 100);
62 CPPUNIT_ASSERT(b1.bytesUsed() == 0);
74 strcpy(data,
"12345678901234567890");
81 size_t s = strlen(dataR);
82 CPPUNIT_ASSERT(memcmp(data,dataR,s) == 0);
83 CPPUNIT_ASSERT(strlen(data) == strlen(dataR));
84 CPPUNIT_ASSERT( data == dataR );
85 CPPUNIT_ASSERT( *data == *dataR );
86 CPPUNIT_ASSERT( strncmp(data,dataR,20) == 0);
97 strcpy(data2,
"12345678901234567890123456789012");
99 CPPUNIT_ASSERT(b2->
capacity() == 100);
103 size_t s = strlen(dataR2);
104 CPPUNIT_ASSERT(strlen(data2) == strlen(dataR2));
105 CPPUNIT_ASSERT(memcmp(data2,dataR2,s) == 0);
106 CPPUNIT_ASSERT(data2 == dataR2);
118 strcpy(data,
"12345678901234567890");
122 CPPUNIT_ASSERT(b->
capacity() == 20);
124 size_t s = strlen(dataR);
125 CPPUNIT_ASSERT(strlen(data) == strlen(dataR));
126 CPPUNIT_ASSERT(data == dataR );
127 CPPUNIT_ASSERT(strncmp(data,dataR,strlen(data)) == 0);
128 CPPUNIT_ASSERT(memcmp(data,dataR,s) == 0);
141 strcpy(data,
"12345678901234567890123456789012");
143 CPPUNIT_ASSERT(b2->
capacity() == 100);
146 b2->
take(data,100,32);
148 CPPUNIT_ASSERT(b2->
capacity() == 100);
152 CPPUNIT_ASSERT(data == dataR2);
153 CPPUNIT_ASSERT(strncmp(data,dataR2,strlen(data)) == 0);
154 CPPUNIT_ASSERT(memcmp(data,dataR2,strlen(data)) == 0);
166 strcpy(data,
"12345678901234567890");
170 CPPUNIT_ASSERT(b->
capacity() == 20);
172 CPPUNIT_ASSERT(data != dataR );
173 CPPUNIT_ASSERT(strncmp(data,dataR,strlen(data)) == 0);
174 CPPUNIT_ASSERT(memcmp(data,dataR,strlen(data)) == 0);
186 strcpy(data,
"12345678901234567890");
188 CPPUNIT_ASSERT(b->
capacity() == 100);
192 CPPUNIT_ASSERT(b->
capacity() == 100);
196 data2 =
new char[33];
197 strcpy(data2,
"12345678901234567890123456789012");
199 b->
copy(data2,32,20);
204 CPPUNIT_ASSERT(b->
capacity() == 100);
208 CPPUNIT_ASSERT(strlen(data2)+strlen(data) == b->
bytesUsed());
218 char* d20 =
new char[21];
219 strcpy(d20,
"12345678901234567890");
220 size_t s = strlen(d20);
222 CPPUNIT_ASSERT(b->
capacity() == 20);
237 char* data =
new char[21];
238 strcpy(data,
"12345678901234567890");
239 size_t s = strlen(data);
241 CPPUNIT_ASSERT(b->
capacity() == 20);
244 CPPUNIT_ASSERT(bclone.capacity() == 20);
245 CPPUNIT_ASSERT(bclone.bytesUsed() == 20);
247 CPPUNIT_ASSERT(b->
getData() != bclone.getData());
249 CPPUNIT_ASSERT(strncmp(data,dataR,s) == 0);
250 CPPUNIT_ASSERT(memcmp(data,dataR,strlen(data)) == 0);
263 strcpy(data,
"12345678901234567890");
270 CPPUNIT_ASSERT(memcmp(b.
getData(),baux.
getData(),strlen(data)) == 0);
271 CPPUNIT_ASSERT(memcmp(b1.
getData(),b.
getData(),strlen(data)) == 0);
272 CPPUNIT_ASSERT(strncmp(b1.
getData(),b.
getData(), strlen(data)) == 0);
280 char* d20 =
new char[21];
281 strcpy(d20,
"12345678901234567890");
282 std::string hex(
"3132333435363738393031323334353637383930");
283 strcpy(d20,
"12345678901234567890");
284 size_t s = strlen(d20);
286 CPPUNIT_ASSERT(b->
capacity() == 20);
290 CPPUNIT_ASSERT(strncmp(hex.c_str(),ss.c_str(),s*2) == 0);
299 char* d20 =
new char[21];
300 strcpy(d20,
"12345678901234567890");
301 size_t s = strlen(d20);
330 CPPUNIT_ASSERT(*res == i );
333 unsigned int ui = 127 ;
338 CPPUNIT_ASSERT(*res1 == ui );
347 CPPUNIT_ASSERT(*res == f );
355 CPPUNIT_ASSERT(*res == d );
void tcSetBytesUsed()
Test Case: Set bytes used by ByteArray.
void tcGetTypeCode()
Test Case: Get Type code of ByteArray.
void tcTake1()
Test Case: It takes the ownership of the external data buffer.
void tcInit1()
Test Case: Creates a new byte array initializing it with data less than capacity. ...
void tcOperator()
Test Case: Test operator << (writes simple data types (int,double, float) to bytearray.
void tcClear()
Test Case: Clear the byte array.
std::size_t bytesUsed() const
It returns the number of used bytes in the internal buffer.
std::ostream & operator<<(std::ostream &os, const authority &v)
Stream out URI authority.
void tcByteArrayConstructor()
Test Case: Copy Constructor with size bigger than data.
std::string toString() const
It returns the byte array in an string notation.
Test suite for the ByteArray class.
Test suite for the ByteArray Class.
char * getData() const
It returns the data array.
AbstractData * clone() const
It creates a new clone of the byte array.
void tcInit()
Test Case: Creates a new byte array initializing it with data using all capacity. ...
static te::dt::DateTime d(2010, 8, 9, 15, 58, 39)
void tcClone()
Test Case: Clone ByteArray.
void tcCopy1()
Test Case: It copies the data from the given pointer to the byte array and will expand the internal b...
CPPUNIT_TEST_SUITE_REGISTRATION(TsByteArray)
std::size_t capacity() const
It returns the size of the internal buffer.
int getTypeCode() const
The type code for byte array data: BYTE_ARRAY_TYPE.
void tcCopy()
Test Case: It copies the data from the given pointer to the byte array.
void tcByteArraySize()
Test Case: Creates a new byte array and allocate size bytes.
void tcByteArray()
Test Case: Constructs an empty byte array.
void copy(char *data, std::size_t size)
It copies the data from the given pointer to the byte array.
void setBytesUsed(std::size_t size)
It sets the number of used bytes in the internal buffer.
void clear()
It clears the byte array.
void tcTake()
Test Case: It takes the ownership of the external data buffer.
A class for representing binary data.
void take(char *data, std::size_t size)
It takes the ownership of the external data buffer.
void tcToString()
Test Case: It return an string representation of ByteArray.