本文整理汇总了C++中QTEST_ASSERT函数的典型用法代码示例。如果您正苦于以下问题:C++ QTEST_ASSERT函数的具体用法?C++ QTEST_ASSERT怎么用?C++ QTEST_ASSERT使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了QTEST_ASSERT函数的17个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: printMessage
static void printMessage(const char *type, const char *msg, const char *file = 0, int line = 0)
{
QTEST_ASSERT(type);
QTEST_ASSERT(msg);
char buf[1024];
const char *fn = QTestResult::currentTestFunction() ? QTestResult::currentTestFunction()
: "UnknownTestFunc";
const char *tag = QTestResult::currentDataTag() ? QTestResult::currentDataTag() : "";
const char *gtag = QTestResult::currentGlobalDataTag()
? QTestResult::currentGlobalDataTag()
: "";
const char *filler = (tag[0] && gtag[0]) ? ":" : "";
if (file) {
QTest::qt_snprintf(buf, sizeof(buf), "%s: %s::%s(%s%s%s)%s%s\n"
#ifdef Q_OS_WIN
"%s(%d) : failure location\n"
#else
" Loc: [%s(%d)]\n"
#endif
, type, QTestResult::currentTestObjectName(), fn, gtag, filler, tag,
msg[0] ? " " : "", msg, file, line);
} else {
QTest::qt_snprintf(buf, sizeof(buf), "%s: %s::%s(%s%s%s)%s%s\n",
type, QTestResult::currentTestObjectName(), fn, gtag, filler, tag,
msg[0] ? " " : "", msg);
}
memcpy(buf, type, strlen(type));
outputMessage(buf);
}
开发者ID:Fale,项目名称:qtmoko,代码行数:31,代码来源:qplaintestlogger.cpp
示例2: QTEST_ASSERT
void QTestTable::addColumn(int type, const char *name)
{
QTEST_ASSERT(type);
QTEST_ASSERT(name);
d->append(type, name);
}
开发者ID:impuls14,项目名称:qt,代码行数:7,代码来源:qtesttable.cpp
示例3: QTEST_ASSERT
void QTestBasicStreamer::startStreaming()
{
QTEST_ASSERT(!QTest::stream);
const char *out = QTestLog::outputFileName();
if (!out) {
QTest::stream = stdout;
return;
}
#if defined(_MSC_VER) && _MSC_VER >= 1400 && !defined(Q_OS_WINCE)
if (::fopen_s(&QTest::stream, out, "wt")) {
#else
QTest::stream = ::fopen(out, "wt");
if (!QTest::stream) {
#endif
printf("Unable to open file for logging: %s", out);
::exit(1);
}
}
bool QTestBasicStreamer::isTtyOutput()
{
QTEST_ASSERT(QTest::stream);
#if defined(Q_OS_WIN) || defined(Q_OS_INTEGRITY)
return true;
#else
static bool ttyoutput = isatty(fileno(QTest::stream));
return ttyoutput;
#endif
}
开发者ID:husninazer,项目名称:qt,代码行数:31,代码来源:qtestbasicstreamer.cpp
示例4: QTEST_ASSERT
void QTestLog::addPass(const char *msg)
{
QTEST_ASSERT(QTest::testLogger);
QTEST_ASSERT(msg);
QTest::testLogger->addIncident(QAbstractTestLogger::Pass, msg);
}
开发者ID:Fale,项目名称:qtmoko,代码行数:7,代码来源:qtestlog.cpp
示例5: printMessage
static void printMessage(const char *type, const char *msg, const char *file = 0, int line = 0)
{
QTEST_ASSERT(type);
QTEST_ASSERT(msg);
QTestCharBuffer buf;
const char *fn = QTestResult::currentTestFunction() ? QTestResult::currentTestFunction()
: "UnknownTestFunc";
const char *tag = QTestResult::currentDataTag() ? QTestResult::currentDataTag() : "";
const char *gtag = QTestResult::currentGlobalDataTag()
? QTestResult::currentGlobalDataTag()
: "";
const char *filler = (tag[0] && gtag[0]) ? ":" : "";
if (file) {
QTest::qt_asprintf(&buf, "%s: %s::%s(%s%s%s)%s%s\n"
#ifdef Q_OS_WIN
"%s(%d) : failure location\n"
#else
" Loc: [%s(%d)]\n"
#endif
, type, QTestResult::currentTestObjectName(), fn, gtag, filler, tag,
msg[0] ? " " : "", msg, file, line);
} else {
QTest::qt_asprintf(&buf, "%s: %s::%s(%s%s%s)%s%s\n",
type, QTestResult::currentTestObjectName(), fn, gtag, filler, tag,
msg[0] ? " " : "", msg);
}
// In colored mode, printf above stripped our nonprintable control characters.
// Put them back.
memcpy(buf.data(), type, strlen(type));
outputMessage(buf.data());
}
开发者ID:ManoharUpputuri,项目名称:qt-labs-qtest-qml,代码行数:33,代码来源:qplaintestlogger.cpp
示例6: QTEST_ASSERT
void QAbstractTestLogger::startLogging()
{
QTEST_ASSERT(!QTest::stream);
const char *out = QTestLog::outputFileName();
if (!out) {
QTest::stream = stdout;
return;
}
#if defined(_MSC_VER) && _MSC_VER >= 1400
if (::fopen_s(&QTest::stream, out, "wt")) {
#else
QTest::stream = ::fopen(out, "wt");
if (!QTest::stream) {
#endif
printf("Unable to open file for logging: %s", out);
::exit(1);
}
}
void QAbstractTestLogger::stopLogging()
{
QTEST_ASSERT(QTest::stream);
if (QTest::stream != stdout)
fclose(QTest::stream);
QTest::stream = 0;
}
开发者ID:muromec,项目名称:qtopia-ezx,代码行数:27,代码来源:qabstracttestlogger.cpp
示例7: mouseWheel
static void mouseWheel(QWindow* window, QObject* item, Qt::MouseButtons buttons,
Qt::KeyboardModifiers stateKey,
QPointF _pos, int xDelta, int yDelta, int delay = -1)
{
QTEST_ASSERT(window);
QTEST_ASSERT(item);
if (delay == -1 || delay < QTest::defaultMouseDelay())
delay = QTest::defaultMouseDelay();
if (delay > 0)
QTest::qWait(delay);
QPoint pos;
QQuickItem *sgitem = qobject_cast<QQuickItem *>(item);
if (sgitem)
pos = sgitem->mapToScene(_pos).toPoint();
QTEST_ASSERT(buttons == Qt::NoButton || buttons & Qt::MouseButtonMask);
QTEST_ASSERT(stateKey == 0 || stateKey & Qt::KeyboardModifierMask);
stateKey &= static_cast<unsigned int>(Qt::KeyboardModifierMask);
QWheelEvent we(pos, window->mapToGlobal(pos), QPoint(0, 0), QPoint(xDelta, yDelta), 0, Qt::Vertical, buttons, stateKey);
QSpontaneKeyEvent::setSpontaneous(&we); // hmmmm
if (!qApp->notify(window, &we))
QTest::qWarn("Wheel event not accepted by receiving window");
}
开发者ID:2gis,项目名称:2gisqt5android,代码行数:26,代码来源:quicktestevent.cpp
示例8: QTEST_ASSERT
bool QTestResult::compare(bool success, const char *failureMsg,
char *val1, char *val2,
const char *actual, const char *expected,
const char *file, int line)
{
QTEST_ASSERT(expected);
QTEST_ASSERT(actual);
char msg[1024];
if (QTestLog::verboseLevel() >= 2) {
qsnprintf(msg, 1024, "QCOMPARE(%s, %s)", actual, expected);
QTestLog::info(msg, file, line);
}
if (!failureMsg)
failureMsg = "Compared values are not the same";
if (success && QTest::expectFailMode) {
qsnprintf(msg, 1024, "QCOMPARE(%s, %s) returned TRUE unexpectedly.", actual, expected);
} else if (val1 || val2) {
qsnprintf(msg, 1024, "%s\n Actual (%s): %s\n Expected (%s): %s",
failureMsg,
actual, val1 ? val1 : "<null>",
expected, val2 ? val2 : "<null>");
} else
qsnprintf(msg, 1024, "%s", failureMsg);
delete [] val1;
delete [] val2;
return checkStatement(success, msg, file, line);
}
开发者ID:KDE,项目名称:android-qt5-qtbase,代码行数:33,代码来源:qtestresult.cpp
示例9: QTEST_ASSERT
void QAbstractTestLogger::startLogging()
{
QTEST_ASSERT(!QTest::stream);
const char *out = QTestLog::outputFileName();
if (!out) {
QTest::stream = stdout;
return;
}
#if defined(_MSC_VER) && _MSC_VER >= 1400 && !defined(Q_OS_WINCE)
if (::fopen_s(&QTest::stream, out, "wt")) {
#else
QTest::stream = ::fopen(out, "wt");
if (!QTest::stream) {
#endif
printf("Unable to open file for logging: %s", out);
::exit(1);
}
}
void QAbstractTestLogger::stopLogging()
{
QTEST_ASSERT(QTest::stream);
if (QTest::stream != stdout) {
fclose(QTest::stream);
} else {
#ifdef Q_OS_SYMBIAN
// Convenience sleep for Symbian and TRK. Without this sleep depending on the timing the
// user would not see the complete output because it is still pending in any of the buffers
// before arriving via the USB port on the development PC
User::AfterHighRes(2*1000*1000);
#endif
}
QTest::stream = 0;
}
开发者ID:stephaneAG,项目名称:PengPod700,代码行数:35,代码来源:qabstracttestlogger.cpp
示例10: QTEST_ASSERT
QTestData::QTestData(const char *tag, QTestTable *parent)
{
QTEST_ASSERT(tag);
QTEST_ASSERT(parent);
d = new QTestDataPrivate;
d->tag = qstrdup(tag);
d->parent = parent;
d->data = new void *[parent->elementCount()];
memset(d->data, 0, parent->elementCount() * sizeof(void*));
}
开发者ID:maxxant,项目名称:qt,代码行数:10,代码来源:qtestdata.cpp
示例11: QTEST_ASSERT
void QAbstractTestLogger::outputString(const char *msg)
{
QTEST_ASSERT(stream);
QTEST_ASSERT(msg);
char *filtered = new char[strlen(msg) + 1];
strcpy(filtered, msg);
filterUnprintable(filtered);
::fputs(filtered, stream);
::fflush(stream);
delete [] filtered;
}
开发者ID:venkatarajasekhar,项目名称:Qt,代码行数:14,代码来源:qabstracttestlogger.cpp
示例12: FROM
void MainTest::deletePost()
{
auto count = FROM(db.posts())
WHERE(Post::idField() == postId)
DELETE();
QTEST_ASSERT(count == 1);
count = FROM(db.posts())
WHERE(Post::idField() == postId)
COUNT();
QTEST_ASSERT(count == 0);
}
开发者ID:mazandonline,项目名称:Nut,代码行数:14,代码来源:maintest.cpp
示例13: messageHandler
static void messageHandler(QtMsgType type, const char *msg)
{
static QBasicAtomicInt counter = Q_BASIC_ATOMIC_INITIALIZER(QTest::maxWarnings);
if (!msg || !QTest::testLogger) {
// if this goes wrong, something is seriously broken.
qInstallMsgHandler(oldMessageHandler);
QTEST_ASSERT(msg);
QTEST_ASSERT(QTest::testLogger);
}
if (handleIgnoredMessage(type, msg))
// the message is expected, so just swallow it.
return;
if (type != QtFatalMsg) {
if (counter <= 0)
return;
if (!counter.deref()) {
QTest::testLogger->addMessage(QAbstractTestLogger::QSystem,
"Maximum amount of warnings exceeded.");
return;
}
}
switch (type) {
case QtDebugMsg:
QTest::testLogger->addMessage(QAbstractTestLogger::QDebug, msg);
break;
case QtCriticalMsg:
QTest::testLogger->addMessage(QAbstractTestLogger::QSystem, msg);
break;
case QtWarningMsg:
QTest::testLogger->addMessage(QAbstractTestLogger::QWarning, msg);
break;
case QtFatalMsg:
QTest::testLogger->addMessage(QAbstractTestLogger::QFatal, msg);
/* Right now, we're inside the custom message handler and we're
* being qt_message_output in qglobal.cpp. After we return from
* this function, it will proceed with calling exit() and abort()
* and hence crash. Therefore, we call these logging functions such
* that we wrap up nicely, and in particular produce well-formed XML. */
QTestResult::addFailure("Received a fatal error.", "Unknown file", 0);
QTestLog::leaveTestFunction();
QTestLog::stopLogging();
break;
}
}
开发者ID:Fale,项目名称:qtmoko,代码行数:49,代码来源:qtestlog.cpp
示例14: testLogger
QT_BEGIN_NAMESPACE
QTestXunitStreamer::QTestXunitStreamer(QXunitTestLogger *logger)
: testLogger(logger)
{
QTEST_ASSERT(testLogger);
}
开发者ID:ghjinlei,项目名称:qt5,代码行数:7,代码来源:qtestxunitstreamer.cpp
示例15: QTEST_ASSERT
void QTestXunitStreamer::output(QTestElement *element) const
{
QTEST_ASSERT(element);
outputString("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n");
outputElements(element);
}
开发者ID:ghjinlei,项目名称:qt5,代码行数:7,代码来源:qtestxunitstreamer.cpp
示例16: QTEST_ASSERT
void QTestBasicStreamer::outputString(const char *msg) const
{
QTEST_ASSERT(QTest::stream);
::fputs(msg, QTest::stream);
::fflush(QTest::stream);
}
开发者ID:fluxer,项目名称:katie,代码行数:7,代码来源:qtestbasicstreamer.cpp
示例17: QTEST_ASSERT
bool QTestResult::compare(bool success, const char *msg, char *val1, char *val2,
const char *actual, const char *expected, const char *file, int line)
{
QTEST_ASSERT(expected);
QTEST_ASSERT(actual);
if (!val1 && !val2)
return compare(success, msg, file, line);
char buf[1024];
QTest::qt_snprintf(buf, 1024, "%s\n Actual (%s): %s\n Expected (%s): %s", msg,
actual, val1 ? val1 : "<null>",
expected, val2 ? val2 : "<null>");
delete [] val1;
delete [] val2;
return compare(success, buf, file, line);
}
开发者ID:FilipBE,项目名称:qtextended,代码行数:17,代码来源:qtestresult.cpp
注:本文中的QTEST_ASSERT函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论