paysages3d/src/tests/PackStream_Test.cpp

52 lines
1.2 KiB
C++
Raw Normal View History

2013-11-10 20:14:10 +00:00
#include "BaseTestCase.h"
#include "PackStream.h"
2013-11-10 20:14:10 +00:00
TEST(PackStream, All)
{
PackStream* stream;
int i;
int data_i;
double data_d;
const char* data_s;
char buffer[100];
/* Writing to pack */
2013-11-10 20:14:10 +00:00
stream = new PackStream();
stream->bindToFile("/tmp/test_paysages_pack", true);
for (i = 0; i < 5; i++)
{
data_i = i;
2013-11-10 20:14:10 +00:00
stream->write(&data_i);
data_d = (double)i;
2013-11-10 20:14:10 +00:00
stream->write(&data_d);
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-11-10 20:14:10 +00:00
delete stream;
/* Reading from pack */
2013-11-10 20:14:10 +00:00
stream = new PackStream();
stream->bindToFile("/tmp/test_paysages_pack");
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-11-10 20:14:10 +00:00
delete stream;
}