MCPcopy Create free account
hub / github.com/MEONMedical/Log4Qt / testBinaryLayout

Method testBinaryLayout

tests/binaryloggertest/binaryloggertest.cpp:322–348  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

320}
321
322void BinaryLoggerTest::testBinaryLayout()
323{
324 auto clogger = logger();
325 auto appender = new Log4Qt::BinaryWriterAppender(clogger);
326 auto layout = new Log4Qt::BinaryLayout(appender);
327 layout->setBinaryHeader("This is the header:");
328 layout->setBinaryFooter(":This is the footer");
329 appender->setLayout(Log4Qt::LayoutSharedPtr(layout));
330 clogger->addAppender(appender);
331 auto _ = createScopeExitGuard([clogger, appender] {clogger->removeAppender(appender);});
332 QByteArray data;
333 QDataStream ds(&data, QIODevice::WriteOnly);
334 ds.setByteOrder(QDataStream::LittleEndian);
335 appender->setWriter(&ds);
336 appender->activateOptions();
337
338 clogger->debug("Hello world!");
339 appender->close();
340
341 char expected[] =
342 {
343 0x54, 0x68, 0x69, 0x73, 0x20, 0x69, 0x73, 0x20, 0x74, 0x68, 0x65, 0x20, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x3a,
344 0x0c, 0x00, 0x00, 0x00, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x20, 0x77, 0x6f, 0x72, 0x6c, 0x64, 0x21,
345 0x3a, 0x54, 0x68, 0x69, 0x73, 0x20, 0x69, 0x73, 0x20, 0x74, 0x68, 0x65, 0x20, 0x66, 0x6f, 0x6f, 0x74, 0x65, 0x72
346 };
347 QCOMPARE(QByteArray(expected, elementsInArray(expected)), data);
348}
349
350QTEST_GUILESS_MAIN(BinaryLoggerTest)
351

Callers

nothing calls this directly

Calls 13

createScopeExitGuardFunction · 0.85
elementsInArrayFunction · 0.85
setBinaryHeaderMethod · 0.80
setBinaryFooterMethod · 0.80
setLayoutMethod · 0.80
addAppenderMethod · 0.80
removeAppenderMethod · 0.80
setByteOrderMethod · 0.80
QByteArrayClass · 0.70
setWriterMethod · 0.45
activateOptionsMethod · 0.45
debugMethod · 0.45

Tested by

no test coverage detected