Fix ClipboardChunkTests unit test (Fixes #5840)

This commit is contained in:
Epakai 2017-02-12 15:18:44 -06:00 committed by Andrew Nelless
parent a5140aa1b9
commit c5b83ce4c4
1 changed files with 9 additions and 3 deletions

View File

@ -26,9 +26,11 @@ TEST(ClipboardChunkTests, start_formatStartChunk)
UInt32 sequence = 0; UInt32 sequence = 0;
String mockDataSize("10"); String mockDataSize("10");
ClipboardChunk* chunk = ClipboardChunk::start(id, sequence, mockDataSize); ClipboardChunk* chunk = ClipboardChunk::start(id, sequence, mockDataSize);
UInt32 temp_m_chunk;
memcpy(&temp_m_chunk, &(chunk->m_chunk[1]), 4);
EXPECT_EQ(id, chunk->m_chunk[0]); EXPECT_EQ(id, chunk->m_chunk[0]);
EXPECT_EQ(sequence, (UInt32)chunk->m_chunk[1]); EXPECT_EQ(sequence, temp_m_chunk);
EXPECT_EQ(kDataStart, chunk->m_chunk[5]); EXPECT_EQ(kDataStart, chunk->m_chunk[5]);
EXPECT_EQ('1', chunk->m_chunk[6]); EXPECT_EQ('1', chunk->m_chunk[6]);
EXPECT_EQ('0', chunk->m_chunk[7]); EXPECT_EQ('0', chunk->m_chunk[7]);
@ -43,9 +45,11 @@ TEST(ClipboardChunkTests, data_formatDataChunk)
UInt32 sequence = 1; UInt32 sequence = 1;
String mockData("mock data"); String mockData("mock data");
ClipboardChunk* chunk = ClipboardChunk::data(id, sequence, mockData); ClipboardChunk* chunk = ClipboardChunk::data(id, sequence, mockData);
UInt32 temp_m_chunk;
memcpy(&temp_m_chunk, &(chunk->m_chunk[1]), 4);
EXPECT_EQ(id, chunk->m_chunk[0]); EXPECT_EQ(id, chunk->m_chunk[0]);
EXPECT_EQ(sequence, (UInt32)chunk->m_chunk[1]); EXPECT_EQ(sequence, temp_m_chunk);
EXPECT_EQ(kDataChunk, chunk->m_chunk[5]); EXPECT_EQ(kDataChunk, chunk->m_chunk[5]);
EXPECT_EQ('m', chunk->m_chunk[6]); EXPECT_EQ('m', chunk->m_chunk[6]);
EXPECT_EQ('o', chunk->m_chunk[7]); EXPECT_EQ('o', chunk->m_chunk[7]);
@ -66,9 +70,11 @@ TEST(ClipboardChunkTests, end_formatDataChunk)
ClipboardID id = 1; ClipboardID id = 1;
UInt32 sequence = 1; UInt32 sequence = 1;
ClipboardChunk* chunk = ClipboardChunk::end(id, sequence); ClipboardChunk* chunk = ClipboardChunk::end(id, sequence);
UInt32 temp_m_chunk;
memcpy(&temp_m_chunk, &(chunk->m_chunk[1]), 4);
EXPECT_EQ(id, chunk->m_chunk[0]); EXPECT_EQ(id, chunk->m_chunk[0]);
EXPECT_EQ(sequence, (UInt32)chunk->m_chunk[1]); EXPECT_EQ(sequence, temp_m_chunk);
EXPECT_EQ(kDataEnd, chunk->m_chunk[5]); EXPECT_EQ(kDataEnd, chunk->m_chunk[5]);
EXPECT_EQ('\0', chunk->m_chunk[6]); EXPECT_EQ('\0', chunk->m_chunk[6]);