forked from OSchip/llvm-project
parent
b98294d006
commit
d4c1efcb69
|
@ -316,17 +316,15 @@ TEST(MappedBlockStreamTest, TestWriteThenRead) {
|
||||||
StringRef ZStr[] = {"Zero Str", ""};
|
StringRef ZStr[] = {"Zero Str", ""};
|
||||||
StringRef FStr[] = {"Fixed Str", ""};
|
StringRef FStr[] = {"Fixed Str", ""};
|
||||||
ArrayRef<uint8_t> byteArray[] = {{'1', '2'}, {'0', '0'}};
|
ArrayRef<uint8_t> byteArray[] = {{'1', '2'}, {'0', '0'}};
|
||||||
ArrayRef<support::ulittle32_t> intArray[] = {
|
ArrayRef<uint32_t> intArray[] = {{890723408, 29082234}, {0, 0}};
|
||||||
{ulittle32_t(890723408), ulittle32_t(29082234)},
|
|
||||||
{ulittle32_t(0), ulittle32_t(0)}};
|
|
||||||
|
|
||||||
StreamReader Reader(S);
|
StreamReader Reader(S);
|
||||||
StreamWriter Writer(S);
|
StreamWriter Writer(S);
|
||||||
EXPECT_NO_ERROR(Writer.writeInteger(u16[0]));
|
EXPECT_NO_ERROR(Writer.writeInteger(u16[0]));
|
||||||
EXPECT_NO_ERROR(Reader.readInteger(u16[1]));
|
EXPECT_NO_ERROR(Reader.readInteger(u16[1]));
|
||||||
EXPECT_EQ(u16[0], u16[1]);
|
EXPECT_EQ(u16[0], u16[1]);
|
||||||
EXPECT_EQ(DataBytes,
|
EXPECT_EQ(std::vector<uint8_t>({0, 0x7A, 0xEC, 0, 0, 0, 0, 0, 0, 0}),
|
||||||
std::vector<uint8_t>({0, 0x7A, 0xEC, 0, 0, 0, 0, 0, 0, 0}));
|
DataBytes);
|
||||||
|
|
||||||
Reader.setOffset(0);
|
Reader.setOffset(0);
|
||||||
Writer.setOffset(0);
|
Writer.setOffset(0);
|
||||||
|
@ -334,8 +332,8 @@ TEST(MappedBlockStreamTest, TestWriteThenRead) {
|
||||||
EXPECT_NO_ERROR(Writer.writeInteger(u32[0]));
|
EXPECT_NO_ERROR(Writer.writeInteger(u32[0]));
|
||||||
EXPECT_NO_ERROR(Reader.readInteger(u32[1]));
|
EXPECT_NO_ERROR(Reader.readInteger(u32[1]));
|
||||||
EXPECT_EQ(u32[0], u32[1]);
|
EXPECT_EQ(u32[0], u32[1]);
|
||||||
EXPECT_EQ(DataBytes,
|
EXPECT_EQ(std::vector<uint8_t>({0x17, 0x5C, 0x50, 0, 0, 0, 0x35, 0, 0, 0}),
|
||||||
std::vector<uint8_t>({0x17, 0x5C, 0x50, 0, 0, 0, 0x35, 0, 0, 0}));
|
DataBytes);
|
||||||
|
|
||||||
Reader.setOffset(0);
|
Reader.setOffset(0);
|
||||||
Writer.setOffset(0);
|
Writer.setOffset(0);
|
||||||
|
@ -343,8 +341,8 @@ TEST(MappedBlockStreamTest, TestWriteThenRead) {
|
||||||
EXPECT_NO_ERROR(Writer.writeEnum(Enum[0]));
|
EXPECT_NO_ERROR(Writer.writeEnum(Enum[0]));
|
||||||
EXPECT_NO_ERROR(Reader.readEnum(Enum[1]));
|
EXPECT_NO_ERROR(Reader.readEnum(Enum[1]));
|
||||||
EXPECT_EQ(Enum[0], Enum[1]);
|
EXPECT_EQ(Enum[0], Enum[1]);
|
||||||
EXPECT_EQ(DataBytes,
|
EXPECT_EQ(std::vector<uint8_t>({0x2C, 0x60, 0x4A, 0, 0, 0, 0, 0, 0, 0}),
|
||||||
std::vector<uint8_t>({0x2C, 0x60, 0x4A, 0, 0, 0, 0, 0, 0, 0}));
|
DataBytes);
|
||||||
|
|
||||||
Reader.setOffset(0);
|
Reader.setOffset(0);
|
||||||
Writer.setOffset(0);
|
Writer.setOffset(0);
|
||||||
|
@ -352,8 +350,9 @@ TEST(MappedBlockStreamTest, TestWriteThenRead) {
|
||||||
EXPECT_NO_ERROR(Writer.writeZeroString(ZStr[0]));
|
EXPECT_NO_ERROR(Writer.writeZeroString(ZStr[0]));
|
||||||
EXPECT_NO_ERROR(Reader.readZeroString(ZStr[1]));
|
EXPECT_NO_ERROR(Reader.readZeroString(ZStr[1]));
|
||||||
EXPECT_EQ(ZStr[0], ZStr[1]);
|
EXPECT_EQ(ZStr[0], ZStr[1]);
|
||||||
EXPECT_EQ(DataBytes, std::vector<uint8_t>(
|
EXPECT_EQ(
|
||||||
{'r', 'e', 'Z', ' ', 'S', 't', 'o', 'r', 0, 0}));
|
std::vector<uint8_t>({'r', 'e', 'Z', ' ', 'S', 't', 'o', 'r', 0, 0}),
|
||||||
|
DataBytes);
|
||||||
|
|
||||||
Reader.setOffset(0);
|
Reader.setOffset(0);
|
||||||
Writer.setOffset(0);
|
Writer.setOffset(0);
|
||||||
|
@ -361,8 +360,9 @@ TEST(MappedBlockStreamTest, TestWriteThenRead) {
|
||||||
EXPECT_NO_ERROR(Writer.writeFixedString(FStr[0]));
|
EXPECT_NO_ERROR(Writer.writeFixedString(FStr[0]));
|
||||||
EXPECT_NO_ERROR(Reader.readFixedString(FStr[1], FStr[0].size()));
|
EXPECT_NO_ERROR(Reader.readFixedString(FStr[1], FStr[0].size()));
|
||||||
EXPECT_EQ(FStr[0], FStr[1]);
|
EXPECT_EQ(FStr[0], FStr[1]);
|
||||||
EXPECT_EQ(DataBytes, std::vector<uint8_t>(
|
EXPECT_EQ(
|
||||||
{'x', 'i', 'F', 'd', ' ', 'S', 'e', 't', 0, 'r'}));
|
std::vector<uint8_t>({'x', 'i', 'F', 'd', ' ', 'S', 'e', 't', 0, 'r'}),
|
||||||
|
DataBytes);
|
||||||
|
|
||||||
Reader.setOffset(0);
|
Reader.setOffset(0);
|
||||||
Writer.setOffset(0);
|
Writer.setOffset(0);
|
||||||
|
@ -370,8 +370,8 @@ TEST(MappedBlockStreamTest, TestWriteThenRead) {
|
||||||
EXPECT_NO_ERROR(Writer.writeArray(byteArray[0]));
|
EXPECT_NO_ERROR(Writer.writeArray(byteArray[0]));
|
||||||
EXPECT_NO_ERROR(Reader.readArray(byteArray[1], byteArray[0].size()));
|
EXPECT_NO_ERROR(Reader.readArray(byteArray[1], byteArray[0].size()));
|
||||||
EXPECT_EQ(byteArray[0], byteArray[1]);
|
EXPECT_EQ(byteArray[0], byteArray[1]);
|
||||||
EXPECT_EQ(DataBytes,
|
EXPECT_EQ(std::vector<uint8_t>({0, 0x32, 0x31, 0, 0, 0, 0, 0, 0, 0}),
|
||||||
std::vector<uint8_t>({0, 0x32, 0x31, 0, 0, 0, 0, 0, 0, 0}));
|
DataBytes);
|
||||||
|
|
||||||
Reader.setOffset(0);
|
Reader.setOffset(0);
|
||||||
Writer.setOffset(0);
|
Writer.setOffset(0);
|
||||||
|
@ -379,8 +379,6 @@ TEST(MappedBlockStreamTest, TestWriteThenRead) {
|
||||||
EXPECT_NO_ERROR(Writer.writeArray(intArray[0]));
|
EXPECT_NO_ERROR(Writer.writeArray(intArray[0]));
|
||||||
EXPECT_NO_ERROR(Reader.readArray(intArray[1], intArray[0].size()));
|
EXPECT_NO_ERROR(Reader.readArray(intArray[1], intArray[0].size()));
|
||||||
EXPECT_EQ(intArray[0], intArray[1]);
|
EXPECT_EQ(intArray[0], intArray[1]);
|
||||||
EXPECT_EQ(DataBytes, std::vector<uint8_t>({0x17, 0x5C, 0x50, 0x7A, 0xC2, 0xBB,
|
|
||||||
0x35, 0x01, 0, 0}));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(MappedBlockStreamTest, TestWriteContiguousStreamRef) {
|
TEST(MappedBlockStreamTest, TestWriteContiguousStreamRef) {
|
||||||
|
|
Loading…
Reference in New Issue