当前位置: 首页>>代码示例>>C++>>正文


C++ QFETCH函数代码示例

本文整理汇总了C++中QFETCH函数的典型用法代码示例。如果您正苦于以下问题:C++ QFETCH函数的具体用法?C++ QFETCH怎么用?C++ QFETCH使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了QFETCH函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: QFETCH

void LccnTest::testFormalization() {
  QFETCH(QString, string);
  QFETCH(QString, result);

  QCOMPARE(Tellico::LCCNValidator::formalize(string), result);
}
开发者ID:KDE,项目名称:tellico,代码行数:6,代码来源:lccntest.cpp

示例2: QFETCH

void WirelessSecuritySetting::testSetting()
{
    QFETCH(QString, keyMgmt);
    QFETCH(quint32, wepTxKeyidx);
    QFETCH(QString, authAlg);
    QFETCH(QStringList, proto);
    QFETCH(QStringList, pairwise);
    QFETCH(QStringList, group);
    QFETCH(QString, leapUsername);
    QFETCH(QString, wepKey0);
    QFETCH(QString, wepKey1);
    QFETCH(QString, wepKey2);
    QFETCH(QString, wepKey3);
    QFETCH(quint32, wepKeyFlags);
    QFETCH(quint32, wepKeyType);
    QFETCH(QString, psk);
    QFETCH(quint32, pskFlags);
    QFETCH(QString, leapPassword);
    QFETCH(quint32, leapPasswordFlags);

    QVariantMap map;

    map.insert(QLatin1String(NM_SETTING_WIRELESS_SECURITY_KEY_MGMT), keyMgmt);
    map.insert(QLatin1String(NM_SETTING_WIRELESS_SECURITY_WEP_TX_KEYIDX), wepTxKeyidx);
    map.insert(QLatin1String(NM_SETTING_WIRELESS_SECURITY_AUTH_ALG), authAlg);
    map.insert(QLatin1String(NM_SETTING_WIRELESS_SECURITY_PROTO), proto);
    map.insert(QLatin1String(NM_SETTING_WIRELESS_SECURITY_PAIRWISE), pairwise);
    map.insert(QLatin1String(NM_SETTING_WIRELESS_SECURITY_GROUP), group);
    map.insert(QLatin1String(NM_SETTING_WIRELESS_SECURITY_LEAP_USERNAME), leapUsername);
    map.insert(QLatin1String(NM_SETTING_WIRELESS_SECURITY_WEP_KEY0), wepKey0);
    map.insert(QLatin1String(NM_SETTING_WIRELESS_SECURITY_WEP_KEY1), wepKey1);
    map.insert(QLatin1String(NM_SETTING_WIRELESS_SECURITY_WEP_KEY2), wepKey2);
    map.insert(QLatin1String(NM_SETTING_WIRELESS_SECURITY_WEP_KEY3), wepKey3);
    map.insert(QLatin1String(NM_SETTING_WIRELESS_SECURITY_WEP_KEY_FLAGS), wepKeyFlags);
    map.insert(QLatin1String(NM_SETTING_WIRELESS_SECURITY_WEP_KEY_TYPE), wepKeyType);
    map.insert(QLatin1String(NM_SETTING_WIRELESS_SECURITY_PSK), psk);
    map.insert(QLatin1String(NM_SETTING_WIRELESS_SECURITY_PSK_FLAGS), pskFlags);
    map.insert(QLatin1String(NM_SETTING_WIRELESS_SECURITY_LEAP_PASSWORD), leapPassword);
    map.insert(QLatin1String(NM_SETTING_WIRELESS_SECURITY_LEAP_PASSWORD_FLAGS), leapPasswordFlags);

    NetworkManager::WirelessSecuritySetting setting;
    setting.fromMap(map);

    QVariantMap map1 = setting.toMap();

    // Will fail if set some default values, because they are skipped in toMap() method
    QVariantMap::const_iterator it = map.constBegin();
    while (it != map.constEnd()) {
        QCOMPARE(it.value(), map1.value(it.key()));
        ++it;
    }
}
开发者ID:Bridges,项目名称:libnm-qt5,代码行数:52,代码来源:wirelesssecuritysetting.cpp

示例3: QFETCH

void tst_QVideoFrame::assign()
{
    QFETCH(QAbstractVideoBuffer::HandleType, handleType);
    QFETCH(QSize, size);
    QFETCH(QVideoFrame::PixelFormat, pixelFormat);
    QFETCH(QVideoFrame::FieldType, fieldType);
    QFETCH(qint64, startTime);
    QFETCH(qint64, endTime);

    QPointer<QtTestVideoBuffer> buffer = new QtTestVideoBuffer(handleType);

    QVideoFrame frame;
    {
        QVideoFrame otherFrame(buffer, size, pixelFormat);
        otherFrame.setFieldType(fieldType);
        otherFrame.setStartTime(startTime);
        otherFrame.setEndTime(endTime);

        frame = otherFrame;

        QVERIFY(!buffer.isNull());

        QVERIFY(otherFrame.isValid());
        QCOMPARE(otherFrame.handleType(), handleType);
        QCOMPARE(otherFrame.pixelFormat(), pixelFormat);
        QCOMPARE(otherFrame.size(), size);
        QCOMPARE(otherFrame.width(), size.width());
        QCOMPARE(otherFrame.height(), size.height());
        QCOMPARE(otherFrame.fieldType(), fieldType);
        QCOMPARE(otherFrame.startTime(), startTime);
        QCOMPARE(otherFrame.endTime(), endTime);

        otherFrame.setStartTime(-1);

        QVERIFY(!buffer.isNull());

        QVERIFY(otherFrame.isValid());
        QCOMPARE(otherFrame.handleType(), handleType);
        QCOMPARE(otherFrame.pixelFormat(), pixelFormat);
        QCOMPARE(otherFrame.size(), size);
        QCOMPARE(otherFrame.width(), size.width());
        QCOMPARE(otherFrame.height(), size.height());
        QCOMPARE(otherFrame.fieldType(), fieldType);
        QCOMPARE(otherFrame.startTime(), qint64(-1));
        QCOMPARE(otherFrame.endTime(), endTime);
    }

    QVERIFY(!buffer.isNull());

    QVERIFY(frame.isValid());
    QCOMPARE(frame.handleType(), handleType);
    QCOMPARE(frame.pixelFormat(), pixelFormat);
    QCOMPARE(frame.size(), size);
    QCOMPARE(frame.width(), size.width());
    QCOMPARE(frame.height(), size.height());
    QCOMPARE(frame.fieldType(), fieldType);
    QCOMPARE(frame.startTime(), qint64(-1));
    QCOMPARE(frame.endTime(), endTime);

    frame = QVideoFrame();

    QVERIFY(buffer.isNull());

    QVERIFY(!frame.isValid());
    QCOMPARE(frame.handleType(), QAbstractVideoBuffer::NoHandle);
    QCOMPARE(frame.pixelFormat(), QVideoFrame::Format_Invalid);
    QCOMPARE(frame.size(), QSize());
    QCOMPARE(frame.width(), -1);
    QCOMPARE(frame.height(), -1);
    QCOMPARE(frame.fieldType(), QVideoFrame::ProgressiveFrame);
    QCOMPARE(frame.startTime(), qint64(-1));
    QCOMPARE(frame.endTime(), qint64(-1));
}
开发者ID:KDE,项目名称:android-qt-mobility,代码行数:73,代码来源:tst_qvideoframe.cpp

示例4: QFETCH

void KisFixedPaintDeviceTest::testMirroring()
{
    QFETCH(QRect, rc);
    QFETCH(bool, mirrorHorizontally);
    QFETCH(bool, mirrorVertically);

    const KoColorSpace *cs = KoColorSpaceRegistry::instance()->rgb8();
    KisFixedPaintDeviceSP dev = new KisFixedPaintDevice(cs);
    dev->setRect(rc);
    dev->initialize();

    KoColor c(Qt::black, cs);

    qsrand(1);
    int value = 0;

    for (int i = rc.x(); i < rc.x() + rc.width(); i++) {
        for (int j = rc.y(); j < rc.y() + rc.height(); j++) {
            setPixel(dev, i, j, value);
            value = qrand() % 255;
        }
        value = qrand() % 255;
    }

    //dev->convertToQImage(0).save("0_a.png");
    dev->mirror(mirrorHorizontally, mirrorVertically);
    //dev->convertToQImage(0).save("0_b.png");

    int startX;
    int endX;
    int incX;

    int startY;
    int endY;
    int incY;

    if (mirrorHorizontally) {
        startX = rc.x() + rc.width() - 1;
        endX = rc.x() - 1;
        incX = -1;
    } else {
        startX = rc.x();
        endX = rc.x() + rc.width();
        incX = 1;
    }

    if (mirrorVertically) {
        startY = rc.y() + rc.height() - 1;
        endY = rc.y() - 1;
        incY = -1;
    } else {
        startY = rc.y();
        endY = rc.y() + rc.height();
        incY = 1;
    }

    qsrand(1);
    value = 0;

    for (int i = startX; i != endX ; i += incX) {
        for (int j = startY; j != endY; j += incY) {
            QCOMPARE(pixel(dev, i, j), (quint8)value);
            value = qrand() % 255;
        }
        value = qrand() % 255;
    }
}
开发者ID:crayonink,项目名称:calligra-2,代码行数:67,代码来源:kis_fixed_paint_device_test.cpp

示例5: QFETCH

// public QIcon icon(QFileIconProvider::IconType const& type) const
void tst_QFileIconProvider::iconType()
{
    QFETCH(QFileIconProvider::IconType, type);
    SubQFileIconProvider provider;
    QVERIFY(!provider.icon(type).isNull());
}
开发者ID:CodeDJ,项目名称:qt5-hidpi,代码行数:7,代码来源:tst_qfileiconprovider.cpp

示例6: QFETCH

void tst_QPdfWriter::testPageMetrics()
{
    QFETCH(int, pageSize);
    QFETCH(qreal, widthMMf);
    QFETCH(qreal, heightMMf);
    QFETCH(bool, setMargins);
    QFETCH(qreal, leftMMf);
    QFETCH(qreal, rightMMf);
    QFETCH(qreal, topMMf);
    QFETCH(qreal, bottomMMf);

    QSizeF sizeMMf = QSizeF(widthMMf, heightMMf);

    QTemporaryFile file;
    if (!file.open())
        QSKIP("Couldn't open temp file!");
    QPdfWriter writer(file.fileName());
    QCOMPARE(writer.pageLayout().orientation(), QPageLayout::Portrait);

    if (setMargins) {
        // Setup the given margins
        QPdfWriter::Margins margins;
        margins.left = leftMMf;
        margins.right = rightMMf;
        margins.top = topMMf;
        margins.bottom = bottomMMf;
        writer.setMargins(margins);
        QCOMPARE(writer.margins().left, leftMMf);
        QCOMPARE(writer.margins().right, rightMMf);
        QCOMPARE(writer.margins().top, topMMf);
        QCOMPARE(writer.margins().bottom, bottomMMf);
    }


    // Set the given size, in Portrait mode
    if (pageSize < 0) {
        writer.setPageSizeMM(sizeMMf);
        QCOMPARE(writer.pageSize(), QPdfWriter::Custom);
        QCOMPARE(writer.pageLayout().pageSize().id(), QPageSize::Custom);
    } else {
        writer.setPageSize(QPdfWriter::PageSize(pageSize));
        QCOMPARE(writer.pageSize(), QPdfWriter::PageSize(pageSize));
        QCOMPARE(writer.pageLayout().pageSize().id(), QPageSize::PageSizeId(pageSize));
    }
    QCOMPARE(writer.pageLayout().orientation(), QPageLayout::Portrait);
    QCOMPARE(writer.margins().left, leftMMf);
    QCOMPARE(writer.margins().right, rightMMf);
    QCOMPARE(writer.margins().top, topMMf);
    QCOMPARE(writer.margins().bottom, bottomMMf);

    // QPagedPaintDevice::pageSizeMM() always returns Portrait
    QCOMPARE(writer.pageSizeMM(), sizeMMf);

    // QPagedPaintDevice::widthMM() and heightMM() are paint metrics and always return set orientation
    QCOMPARE(writer.widthMM(), qRound(widthMMf - leftMMf - rightMMf));
    QCOMPARE(writer.heightMM(), qRound(heightMMf - topMMf - bottomMMf));

    // Now switch to Landscape mode, size should be unchanged, but rect and metrics should change
    writer.setPageOrientation(QPageLayout::Landscape);
    if (pageSize < 0) {
        QCOMPARE(writer.pageSize(), QPdfWriter::Custom);
        QCOMPARE(writer.pageLayout().pageSize().id(), QPageSize::Custom);
    } else {
        QCOMPARE(writer.pageSize(), QPdfWriter::PageSize(pageSize));
        QCOMPARE(writer.pageLayout().pageSize().id(), QPageSize::PageSizeId(pageSize));
    }
    QCOMPARE(writer.pageLayout().orientation(), QPageLayout::Landscape);
    QCOMPARE(writer.margins().left, leftMMf);
    QCOMPARE(writer.margins().right, rightMMf);
    QCOMPARE(writer.margins().top, topMMf);
    QCOMPARE(writer.margins().bottom, bottomMMf);

    // QPagedPaintDevice::pageSizeMM() always returns Portrait
    QCOMPARE(writer.pageSizeMM(), sizeMMf);

    // QPagedPaintDevice::widthMM() and heightMM() are paint metrics and always return set orientation
    QCOMPARE(writer.widthMM(), qRound(heightMMf - leftMMf - rightMMf));
    QCOMPARE(writer.heightMM(), qRound(widthMMf - topMMf - bottomMMf));

    // QPdfWriter::fullRect() always returns set orientation
    QCOMPARE(writer.pageLayout().fullRect(QPageLayout::Millimeter), QRectF(0, 0, heightMMf, widthMMf));

    // QPdfWriter::paintRect() always returns set orientation
    QCOMPARE(writer.pageLayout().paintRect(QPageLayout::Millimeter), QRectF(leftMMf, topMMf, heightMMf - leftMMf - rightMMf, widthMMf - topMMf - bottomMMf));


    // Now while in Landscape mode, set the size again, results should be the same
    if (pageSize < 0) {
        writer.setPageSizeMM(sizeMMf);
        QCOMPARE(writer.pageSize(), QPdfWriter::Custom);
        QCOMPARE(writer.pageLayout().pageSize().id(), QPageSize::Custom);
    } else {
        writer.setPageSize(QPdfWriter::PageSize(pageSize));
        QCOMPARE(writer.pageSize(), QPdfWriter::PageSize(pageSize));
        QCOMPARE(writer.pageLayout().pageSize().id(), QPageSize::PageSizeId(pageSize));
    }
    QCOMPARE(writer.pageLayout().orientation(), QPageLayout::Landscape);
    QCOMPARE(writer.margins().left, leftMMf);
    QCOMPARE(writer.margins().right, rightMMf);
    QCOMPARE(writer.margins().top, topMMf);
//.........这里部分代码省略.........
开发者ID:MarianMMX,项目名称:MarianMMX,代码行数:101,代码来源:tst_qpdfwriter.cpp

示例7: QFETCH

void TestGudermannian::testGudermannian()
{
    QFETCH( qreal, angle );

    QFUZZYCOMPARE( atan( sinh ( angle * DEG2RAD ) ) * RAD2DEG, gd( angle * DEG2RAD ) * RAD2DEG, 0.1 );
}
开发者ID:Earthwings,项目名称:marble,代码行数:6,代码来源:TestGudermannian.cpp

示例8: QFETCH

void tst_qdesktopservices::storageLocation()
{
    QFETCH(QDesktopServices::StandardLocation, location);
#ifdef Q_OS_SYMBIAN
    QString storageLocation = QDesktopServices::storageLocation(location);
    QString displayName = QDesktopServices::displayName(location);
    //qDebug( "displayName: %s",  displayName );

    storageLocation = storageLocation.toLower();
    displayName = displayName.toLower();

    QString drive = QDir::currentPath().left(2).toLower();
    if( drive == "z:" )
        drive = "c:";

    switch(location) {
    case QDesktopServices::DesktopLocation:
        QCOMPARE( storageLocation, drive + QString("/data") );
        break;
    case QDesktopServices::DocumentsLocation:
        QCOMPARE( storageLocation, drive + QString("/data") );
        break;
    case QDesktopServices::FontsLocation:
        // Currently point always to ROM
        QCOMPARE( storageLocation, QString("z:/resource/fonts") );
        break;
    case QDesktopServices::ApplicationsLocation:
#ifdef Q_CC_NOKIAX86
        QCOMPARE( storageLocation, QString("z:/sys/bin") );
#else
        QCOMPARE( storageLocation, drive + QString("/sys/bin") );
#endif
        break;
    case QDesktopServices::MusicLocation:
        QCOMPARE( storageLocation, drive + QString("/data/sounds") );
        break;
    case QDesktopServices::MoviesLocation:
        QCOMPARE( storageLocation, drive + QString("/data/videos") );
        break;
    case QDesktopServices::PicturesLocation:
        QCOMPARE( storageLocation, drive + QString("/data/images") );
        break;
    case QDesktopServices::TempLocation:
        QCOMPARE( storageLocation, QDir::tempPath().toLower());
        break;
    case QDesktopServices::HomeLocation:
        QCOMPARE( storageLocation, QDir::homePath().toLower());
        break;
    case QDesktopServices::DataLocation:
        // Just check the folder not the drive
        QCOMPARE( storageLocation.mid(2), QDir::currentPath().mid(2).toLower());
        break;
    default:
        QCOMPARE( storageLocation, QString() );
        break;
    }

#else
    QDesktopServices::storageLocation(location);
    QDesktopServices::displayName(location);
#endif
}
开发者ID:mpvader,项目名称:qt,代码行数:62,代码来源:tst_qdesktopservices.cpp

示例9: QFETCH

void tst_QScriptValueGenerated::testHelper(TestFunction fun)
{
    QFETCH(QString, __expression__);
    QScriptValue value = m_values.value(__expression__);
    (this->*fun)(__expression__.toLatin1(), value);
}
开发者ID:venkatarajasekhar,项目名称:Qt,代码行数:6,代码来源:tst_qscriptvalue.cpp

示例10: QFETCH

void tst_Q3CString::length()
{
    QFETCH( Q3CString, s1 );
    QTEST( (int)s1.length(), "res" );
}
开发者ID:mpvader,项目名称:qt,代码行数:5,代码来源:tst_q3cstring.cpp

示例11: QFETCH

void TestPluginEffectLoader::testLoadPluginEffect()
{
    QFETCH(QString, name);
    QFETCH(bool, expected);
    QFETCH(KWin::CompositingType, type);
    QFETCH(KWin::LoadEffectFlags, loadFlags);
    QFETCH(bool, enabledByDefault);

    MockEffectsHandler mockHandler(type);
    mockHandler.setProperty("testEnabledByDefault", enabledByDefault);
    KWin::PluginEffectLoader loader;
    loader.setPluginSubDirectory(QString());
    KSharedConfig::Ptr config = KSharedConfig::openConfig(QString(), KConfig::SimpleConfig);
    loader.setConfig(config);

    const auto plugins = KPluginLoader::findPlugins(QString(),
        [name] (const KPluginMetaData &data) {
            return data.pluginId().compare(name, Qt::CaseInsensitive) == 0 && data.serviceTypes().contains(QStringLiteral("KWin/Effect"));
        }
    );
    QCOMPARE(plugins.size(), 1);

    qRegisterMetaType<KWin::Effect*>();
    QSignalSpy spy(&loader, SIGNAL(effectLoaded(KWin::Effect*,QString)));
    // connect to signal to ensure that we delete the Effect again as the Effect doesn't have a parent
    connect(&loader, &KWin::PluginEffectLoader::effectLoaded,
        [&name](KWin::Effect *effect, const QString &effectName) {
            QCOMPARE(effectName, name);
            effect->deleteLater();
        }
    );
    // try to load the Effect
    QCOMPARE(loader.loadEffect(plugins.first(), loadFlags), expected);
    // loading again should fail
    QVERIFY(!loader.loadEffect(plugins.first(), loadFlags));

    // signal spy should have got the signal if it was expected
    QCOMPARE(spy.isEmpty(), !expected);
    if (!spy.isEmpty()) {
        QCOMPARE(spy.count(), 1);
        // if we caught a signal it should have the effect name we passed in
        QList<QVariant> arguments = spy.takeFirst();
        QCOMPARE(arguments.count(), 2);
        QCOMPARE(arguments.at(1).toString(), name);
    }
    spy.clear();
    QVERIFY(spy.isEmpty());

    // now if we wait for the events being processed, the effect will get deleted and it should load again
    QTest::qWait(1);
    QCOMPARE(loader.loadEffect(plugins.first(), loadFlags), expected);
    // signal spy should have got the signal if it was expected
    QCOMPARE(spy.isEmpty(), !expected);
    if (!spy.isEmpty()) {
        QCOMPARE(spy.count(), 1);
        // if we caught a signal it should have the effect name we passed in
        QList<QVariant> arguments = spy.takeFirst();
        QCOMPARE(arguments.count(), 2);
        QCOMPARE(arguments.at(1).toString(), name);
    }
}
开发者ID:CyberShadow,项目名称:kwin,代码行数:61,代码来源:test_plugin_effectloader.cpp

示例12: QFETCH

void Pt_MButton::toggledPaintPerformance()
{
    QFETCH(qint32, width);
    QFETCH(qint32, height);
    QFETCH(QString, view);
    QFETCH(QString, icon1);
    QFETCH(QString, icon2);
    QFETCH(QString, text);

    QPixmap pixmap(width, height);
    QPainter painter(&pixmap);
    painter.fillRect(QRect(0, 0, width, height), QColor(0, 0, 0));

    MWidgetView *buttonView = MClassFactory::instance()->createView(view.toStdString().c_str(), m_subject);
    m_subject->setView(buttonView);

    m_subject->setGeometry(QRectF(0, 0, width, height));
    if (!text.isEmpty()) {
        m_subject->setText(text);
        m_subject->setTextVisible(true);
    } else
        m_subject->setTextVisible(false);

    if (!icon1.isEmpty()) {
        m_subject->setIconID(icon1);
        m_subject->setIconVisible(true);
    } else
        m_subject->setIconVisible(false);

    if (!icon2.isEmpty()) {
        m_subject->setToggledIconID(icon2);
        m_subject->setIconVisible(true);
    }
    //else
    //    button->setIconVisible(false);

    while (MTheme::hasPendingRequests()) {
        usleep(10000);
        QCoreApplication::processEvents();
    }

    m_subject->setDown(true);
    m_subject->setDown(false);

    while (MTheme::hasPendingRequests()) {
        usleep(10000);
        QCoreApplication::processEvents();
    }
    // actual benchmark
    QBENCHMARK {
        painter.save();
        m_subject->paint(&painter, NULL);
        painter.restore();
    }

    // save a shot (for debugging)
//#define SCREENSHOT
#ifdef SCREENSHOT
    QString kuva;
    QTextStream(&kuva)
            << view
            << "_toggled"
            << "\"" << icon1 << "\""
            << "_"
            << "\"" << icon2 << "\""
            << "_"
            << "\"" << text << "\""
            << "_"
            << width
            << "x"
            << height
            << ".png";
    pixmap.save(kuva, "png", -1);
#endif
}
开发者ID:arcean,项目名称:libmeegotouch-framework,代码行数:75,代码来源:pt_mbutton.cpp

示例13: QFETCH

void TestChordsParser::validChords()
{
    QFETCH(QString, chordText);

    QVERIFY(ChatChordsProgressionParser::isValidChord(chordText));
}
开发者ID:pljones,项目名称:JamTaba,代码行数:6,代码来源:TestChordsParser.cpp

示例14: evaluation

    void evaluation()
    {
      QFETCH( QString, string );
      QFETCH( bool, evalError );
      QFETCH( QVariant, result );

      QgsExpression exp( string );
      QCOMPARE( exp.hasParserError(), false );
      if ( exp.hasParserError() )
        qDebug() << exp.parserErrorString();

      QVariant res = exp.evaluate();
      if ( exp.hasEvalError() )
        qDebug() << exp.evalErrorString();
      if ( res.type() != result.type() )
      {
        qDebug() << "got " << res.typeName() << " instead of " << result.typeName();
      }
      //qDebug() << res.type() << " " << result.type();
      //qDebug() << "type " << res.typeName();
      QCOMPARE( exp.hasEvalError(), evalError );

      QCOMPARE( res.type(), result.type() );
      switch ( res.type() )
      {
        case QVariant::Invalid:
          break; // nothing more to check
        case QVariant::Int:
          QCOMPARE( res.toInt(), result.toInt() );
          break;
        case QVariant::Double:
          QCOMPARE( res.toDouble(), result.toDouble() );
          break;
        case QVariant::String:
          QCOMPARE( res.toString(), result.toString() );
          break;
        case QVariant::Date:
          QCOMPARE( res.toDate(), result.toDate() );
          break;
        case QVariant::DateTime:
          QCOMPARE( res.toDateTime(), result.toDateTime() );
          break;
        case QVariant::Time:
          QCOMPARE( res.toTime(), result.toTime() );
          break;
        case QVariant::UserType:
        {
          if ( res.userType() == qMetaTypeId<QgsExpression::Interval>() )
          {
            QgsExpression::Interval inter = res.value<QgsExpression::Interval>();
            QgsExpression::Interval gotinter = result.value<QgsExpression::Interval>();
            QCOMPARE( inter.seconds(), gotinter.seconds() );
          }
          else
          {
            QFAIL( "unexpected user type" );
          }
          break;
        }
        default:
          Q_ASSERT( false ); // should never happen
      }
    }
开发者ID:carsonfarmer,项目名称:Quantum-GIS,代码行数:63,代码来源:testqgsexpression.cpp

示例15: QFETCH

void WirelessSettingTest::testSetting()
{
    QFETCH(QByteArray, ssid);
    QFETCH(QString, mode);
    QFETCH(QString, band);
    QFETCH(quint32, channel);
    QFETCH(QByteArray, bssid);
    QFETCH(quint32, rate);
    QFETCH(quint32, txPower);
    QFETCH(QByteArray, macAddress);
    QFETCH(QByteArray, clonedMacAddress);
    QFETCH(QStringList, macAddressBlacklist);
    QFETCH(quint32, mtu);
    QFETCH(QStringList, seenBssids);
    QFETCH(QString, security);
    QFETCH(bool, hidden);

    QVariantMap map;

    map.insert(QLatin1String(NM_SETTING_WIRELESS_SSID), ssid);
    map.insert(QLatin1String(NM_SETTING_WIRELESS_MODE), mode);
    map.insert(QLatin1String(NM_SETTING_WIRELESS_BAND), band);
    map.insert(QLatin1String(NM_SETTING_WIRELESS_CHANNEL), channel);
    map.insert(QLatin1String(NM_SETTING_WIRELESS_BSSID), bssid);
    map.insert(QLatin1String(NM_SETTING_WIRELESS_RATE), rate);
    map.insert(QLatin1String(NM_SETTING_WIRELESS_TX_POWER), txPower);
    map.insert(QLatin1String(NM_SETTING_WIRELESS_MAC_ADDRESS), macAddress);
    map.insert(QLatin1String(NM_SETTING_WIRELESS_CLONED_MAC_ADDRESS), clonedMacAddress);
    map.insert(QLatin1String(NM_SETTING_WIRELESS_MAC_ADDRESS_BLACKLIST), macAddressBlacklist);
    map.insert(QLatin1String(NM_SETTING_WIRELESS_MTU), mtu);
    map.insert(QLatin1String(NM_SETTING_WIRELESS_SEEN_BSSIDS), seenBssids);
#if NM_CHECK_VERSION(1, 0, 0)
    map.insert(QLatin1String("security"), security);
#else
    map.insert(QLatin1String(NM_SETTING_WIRELESS_SEC), security);
#endif
    map.insert(QLatin1String(NM_SETTING_WIRELESS_HIDDEN), hidden);

    NetworkManager::WirelessSetting setting;
    setting.fromMap(map);

    QVariantMap map1 = setting.toMap();

    // Will fail if set some default values, because they are skipped in toMap() method
    QVariantMap::const_iterator it = map.constBegin();
    while (it != map.constEnd()) {
        QCOMPARE(it.value(), map1.value(it.key()));
        ++it;
    }
}
开发者ID:KDE,项目名称:networkmanager-qt,代码行数:50,代码来源:wirelesssettingtest.cpp


注:本文中的QFETCH函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。