2013-11-10 20:14:10 +00:00
|
|
|
#include "BaseTestCase.h"
|
2013-06-21 13:02:49 +00:00
|
|
|
|
2013-10-30 11:46:18 +00:00
|
|
|
#include "PackStream.h"
|
2013-06-21 13:02:49 +00:00
|
|
|
|
2013-11-10 20:14:10 +00:00
|
|
|
TEST(PackStream, All)
|
2013-06-21 13:02:49 +00:00
|
|
|
{
|
|
|
|
PackStream* stream;
|
|
|
|
int i;
|
|
|
|
int data_i;
|
|
|
|
double data_d;
|
2013-11-11 14:42:11 +00:00
|
|
|
const char* data_s;
|
2013-06-21 13:02:49 +00:00
|
|
|
char buffer[100];
|
|
|
|
|
|
|
|
/* Writing to pack */
|
2013-11-10 20:14:10 +00:00
|
|
|
stream = new PackStream();
|
|
|
|
stream->bindToFile("/tmp/test_paysages_pack", true);
|
2013-06-21 13:02:49 +00:00
|
|
|
for (i = 0; i < 5; i++)
|
|
|
|
{
|
|
|
|
data_i = i;
|
2013-11-10 20:14:10 +00:00
|
|
|
stream->write(&data_i);
|
2013-06-21 13:02:49 +00:00
|
|
|
|
|
|
|
data_d = (double)i;
|
2013-11-10 20:14:10 +00:00
|
|
|
stream->write(&data_d);
|
2013-06-21 13:02:49 +00:00
|
|
|
|
2013-10-30 11:46:18 +00:00
|
|
|
data_s = "Testing string 0123 (accentué) !";
|
2013-11-10 20:14:10 +00:00
|
|
|
stream->write(data_s, 100);
|
|
|
|
stream->write(data_s, 4);
|
|
|
|
stream->write(data_s, 5);
|
2013-06-21 13:02:49 +00:00
|
|
|
}
|
2013-11-10 20:14:10 +00:00
|
|
|
delete stream;
|
2013-06-21 13:02:49 +00:00
|
|
|
|
|
|
|
/* Reading from pack */
|
2013-11-10 20:14:10 +00:00
|
|
|
stream = new PackStream();
|
|
|
|
stream->bindToFile("/tmp/test_paysages_pack");
|
2013-06-21 13:02:49 +00:00
|
|
|
for (i = 0; i < 5; i++)
|
|
|
|
{
|
2013-11-10 20:14:10 +00:00
|
|
|
stream->read(&data_i);
|
|
|
|
ASSERT_EQ(i, data_i);
|
|
|
|
|
|
|
|
stream->read(&data_d);
|
|
|
|
ASSERT_DOUBLE_EQ((double)i, data_d);
|
|
|
|
|
|
|
|
stream->read(buffer, 100);
|
|
|
|
ASSERT_STREQ("Testing string 0123 (accentué) !", buffer);
|
|
|
|
stream->read(buffer, 4);
|
|
|
|
ASSERT_STREQ("Tes", buffer);
|
|
|
|
stream->read(buffer, 3);
|
|
|
|
ASSERT_STREQ("Te", buffer);
|
2013-06-21 13:02:49 +00:00
|
|
|
}
|
2013-11-10 20:14:10 +00:00
|
|
|
delete stream;
|
2013-06-21 13:02:49 +00:00
|
|
|
}
|