本文整理汇总了C++中CID::Pack方法的典型用法代码示例。如果您正苦于以下问题:C++ CID::Pack方法的具体用法?C++ CID::Pack怎么用?C++ CID::Pack使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CID
的用法示例。
在下文中一共展示了CID::Pack方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: testSimpleRootPDUToOutputStream
/**
* Check that writing an Root PDU to an output stream works
*/
void RootPDUTest::testSimpleRootPDUToOutputStream() {
CID cid = CID::Generate();
RootPDU pdu1(TEST_VECTOR, cid, NULL);
OLA_ASSERT(cid == pdu1.Cid());
OLA_ASSERT_EQ(16u, pdu1.HeaderSize());
OLA_ASSERT_EQ(4u, pdu1.VectorSize());
OLA_ASSERT_EQ(0u, pdu1.DataSize());
OLA_ASSERT_EQ(22u, pdu1.Size());
IOQueue output;
OutputStream stream(&output);
pdu1.Write(&stream);
OLA_ASSERT_EQ(22u, output.Size());
uint8_t *raw_pdu = new uint8_t[output.Size()];
unsigned int raw_pdu_size = output.Peek(raw_pdu, output.Size());
OLA_ASSERT_EQ(output.Size(), raw_pdu_size);
uint8_t EXPECTED[] = {
0x70, 22,
0, 0, 0, 4,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
};
cid.Pack(EXPECTED + 6);
ASSERT_DATA_EQUALS(__LINE__,
EXPECTED, sizeof(EXPECTED),
raw_pdu, raw_pdu_size);
output.Pop(output.Size());
delete[] raw_pdu;
}
示例2: testNestedRootPDUToOutputStream
/*
* Test that packing a RootPDU with nested data works
*/
void RootPDUTest::testNestedRootPDUToOutputStream() {
FakePDU pdu1(1);
FakePDU pdu2(42);
PDUBlock<PDU> block;
block.AddPDU(&pdu1);
block.AddPDU(&pdu2);
CID cid = CID::Generate();
RootPDU pdu(TEST_VECTOR, cid, &block);
OLA_ASSERT(cid == pdu.Cid());
OLA_ASSERT_EQ(30u, pdu.Size());
IOQueue output;
OutputStream stream(&output);
pdu.Write(&stream);
OLA_ASSERT_EQ(30u, output.Size());
uint8_t *raw_pdu = new uint8_t[output.Size()];
unsigned int raw_pdu_size = output.Peek(raw_pdu, output.Size());
OLA_ASSERT_EQ(output.Size(), raw_pdu_size);
uint8_t EXPECTED[] = {
0x70, 30,
0, 0, 0, 4,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 1,
0, 0, 0, 42
};
cid.Pack(EXPECTED + 6);
ASSERT_DATA_EQUALS(__LINE__,
EXPECTED, sizeof(EXPECTED),
raw_pdu, raw_pdu_size);
output.Pop(output.Size());
delete[] raw_pdu;
}
示例3: testSetPack
void CIDTest::testSetPack() {
uint8_t buffer[CID::CID_LENGTH];
CID cid = CID::FromData(TEST_DATA);
cid.Pack(buffer);
OLA_ASSERT_FALSE(memcmp(TEST_DATA, buffer, CID::CID_LENGTH));
}