Skip to content

Commit

Permalink
feat: #77 Fix build error XCode
Browse files Browse the repository at this point in the history
  • Loading branch information
ducphamhong committed Jun 10, 2020
1 parent bcad7f4 commit 3097db0
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
4 changes: 4 additions & 0 deletions Projects/Skylicht/Engine/Source/Utils/CMemoryStream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,14 @@ namespace Skylicht
m_size += size;
}

/*
void CMemoryStream::writeLong(u64 data)
{
int size = sizeof(data);
memcpy(&m_memory[m_size], &data, size);
m_size += size;
}
*/

void CMemoryStream::writeFloat(float data)
{
Expand Down Expand Up @@ -172,6 +174,7 @@ namespace Skylicht
return ret;
}

/*
u64 CMemoryStream::readLong()
{
u64 ret = 0;
Expand All @@ -180,6 +183,7 @@ namespace Skylicht
m_pos += size;
return ret;
}
*/

float CMemoryStream::readFloat()
{
Expand Down
4 changes: 2 additions & 2 deletions Projects/Skylicht/Engine/Source/Utils/CMemoryStream.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ namespace Skylicht
void writeChar(char data);
void writeShort(short data);
void writeInt(int data);
void writeLong(u64 data);
// void writeLong(u64 data);
void writeFloat(float data);
void writeDouble(double data);
void writeString(const std::string& s);
Expand All @@ -58,7 +58,7 @@ namespace Skylicht
char readChar();
short readShort();
int readInt();
u64 readLong();
// u64 readLong();
float readFloat();
double readDouble();
std::string readString();
Expand Down
4 changes: 1 addition & 3 deletions UnitTest/TestApp/TestMemoryStream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,18 @@ void testMemoryStream()
writeStream.writeInt(3);
writeStream.writeFloat(4.0f);
writeStream.writeDouble(5.0);
writeStream.writeLong(6);
writeStream.writeString(std::string("CMemoryStream"));
writeStream.writeData(testWrite, sizeof(testWrite));

int size = writeStream.getSize();
TEST_ASSERT_THROW(size == 57);
TEST_ASSERT_THROW(size == 49);

CMemoryStream readStream(writeStream.getData(), writeStream.getSize());
TEST_ASSERT_THROW(readStream.readChar() == 1);
TEST_ASSERT_THROW(readStream.readShort() == 2);
TEST_ASSERT_THROW(readStream.readInt() == 3);
TEST_ASSERT_FLOAT_EQUAL(readStream.readFloat(), 4.0f);
TEST_ASSERT_FLOAT_EQUAL(readStream.readDouble(), 5.0);
TEST_ASSERT_THROW(readStream.readLong() == 6);
TEST_ASSERT_STRING_EQUAL(readStream.readString().c_str(), "CMemoryStream");
readStream.readData(testRead, sizeof(int) * 3);
TEST_ASSERT_THROW(memcmp(testWrite, testRead, sizeof(int) * 3) == 0);
Expand Down

0 comments on commit 3097db0

Please sign in to comment.