示例#1
0
/*
    \req QTOPIA-231

    \groups
*/
void tst_QtopiaCalc::double_instruction()
{
    QFETCH( QStringList, list );
    QFETCH( QString, result );

    //QEXPECT_FAIL("Divide-8", "Task 177589 - calculator doesn't round properly", Continue);

    systemEngine->hardReset();
    systemEngine->setAccType("Double");

    bool instruction = false;
    for (int i = 0; i < list.count(); ++i) {
        if (instruction) {
            systemEngine->pushInstruction(list[i]);
            instruction = false;
        } else {
            systemEngine->push(list[i]);
            instruction = true;
        }
    }

    systemEngine->evaluate();
    if (!systemEngine->checkState()) {
        QTEST( systemEngine->errorString, "result" );
    } else {
        QTEST( systemEngine->getDisplay(), "result" );
    }
}
示例#2
0
void tst_QRegion::emptyPolygonRegion()
{
    QFETCH(QPolygon, pa);

    QRegion r(pa);
    QTEST(r.isEmpty(), "isEmpty");
    QTEST(r.rects().count(), "numRects");
    QTEST(r.rects(), "rects");
}
void tst_QMailMessageBody::fromQString()
{
    QFETCH( QString, input );
    QFETCH( QByteArray, type );
    QFETCH( QMailMessageBody::TransferEncoding, encoding );

    QMailMessageBody body = QMailMessageBody::fromData( input, QMailMessageContentType( type ), encoding );
    QTEST( body.data( QMailMessageBody::Encoded ), "encoded" );
    QTEST( body.data(), "decoded" );
}
void tst_QMailAddress::constructor1()
{
    QFETCH( QString, from ); 

    QMailAddress addr(from);
    QTEST( addr.isEmailAddress(), "valid_email_address" );
    QTEST( addr.name(), "name" );
    QTEST( addr.address(), "address" );
    QTEST( addr.toString(), "to_string" );
}
示例#5
0
void tst_QTabBar::setElideMode()
{
    QFETCH(int, tabElideMode);
    QTabBar tabBar;
    if (tabElideMode != -128)
        tabBar.setElideMode(Qt::TextElideMode(tabElideMode));
    QTEST(int(tabBar.elideMode()), "expectedMode");
    // Make sure style sheet does not override user set mode
    tabBar.setStyleSheet("QWidget { background-color: #ABA8A6;}");
    QTEST(int(tabBar.elideMode()), "expectedMode");
}
示例#6
0
文件: tst_qdate.cpp 项目: maxxant/qt
void tst_QDate::isValid()
{
    QFETCH(int, year);
    QFETCH(int, month);
    QFETCH(int, day);

    QTEST(QDate::isValid(year, month, day), "valid");

    QDate d;
    d.setDate(year, month, day);
    QTEST(d.isValid(), "valid");
}
示例#7
0
void tst_QTabBar::setUsesScrollButtons()
{
    QFETCH(int, usesArrows);
    QTabBar tabBar;
    if (usesArrows != -128)
        tabBar.setUsesScrollButtons(usesArrows);
    QTEST(tabBar.usesScrollButtons(), "expectedArrows");

    // Make sure style sheet does not override user set mode
    tabBar.setStyleSheet("QWidget { background-color: #ABA8A6;}");
    QTEST(tabBar.usesScrollButtons(), "expectedArrows");
}
static int quoted(void)
{
    char *str = 
	ne_strdup("alpha,'beta, a fish called HELLO!?',sandwiches");
    char *pnt = str;
    
    QTEST("alpha");
    QTEST("'beta, a fish called HELLO!?'");
    QLASTTEST("sandwiches");
    
    ne_free(str);
    return OK;
}
示例#9
0
void tst_QTabBar::removeTab()
{
    QTabBar tabbar;

    QFETCH(int, currentIndex);
    QFETCH(int, deleteIndex);
    tabbar.addTab("foo");
    tabbar.addTab("bar");
    tabbar.addTab("baz");
    tabbar.setCurrentIndex(currentIndex);
    QSignalSpy spy(&tabbar, SIGNAL(currentChanged(int)));
    tabbar.removeTab(deleteIndex);
    QTEST(spy.count(), "spyCount");
    QTEST(tabbar.currentIndex(), "finalIndex");
}
void tst_QRegularExpressionValidator::validate()
{
    QFETCH(QRegularExpression, re);
    QFETCH(QString, value);

    QRegularExpressionValidator rv;

    // setting the same regexp won't emit signals
    const int signalCount = (rv.regularExpression() == re) ? 0 : 1;

    QSignalSpy spy(&rv, SIGNAL(regularExpressionChanged(QRegularExpression)));
    QSignalSpy changedSpy(&rv, SIGNAL(changed()));

    rv.setRegularExpression(re);
    QCOMPARE(rv.regularExpression(), re);

    int pos = -1;
    QValidator::State result = rv.validate(value, pos);

    QTEST(result, "state");
    if (result == QValidator::Invalid)
        QCOMPARE(pos, value.length());
    else
        QCOMPARE(pos, -1); // ensure pos is not modified if validate returned Acceptable or Intermediate

    QCOMPARE(spy.count(), signalCount);
    QCOMPARE(changedSpy.count(), signalCount);
}
示例#11
0
void tst_QTcpServer::proxyFactory()
{
    QFETCH_GLOBAL(bool, setProxy);
    if (setProxy)
        return;

    QFETCH(QList<QNetworkProxy>, proxyList);
    QFETCH(QNetworkProxy, proxyUsed);
    QFETCH(bool, fails);

    MyProxyFactory *factory = new MyProxyFactory;
    factory->toReturn = proxyList;
    QNetworkProxyFactory::setApplicationProxyFactory(factory);

    QTcpServer server;
    bool listenResult = server.listen();

    // Verify that the factory was called properly
    QCOMPARE(factory->callCount, 1);
    QCOMPARE(factory->lastQuery, QNetworkProxyQuery(0, QString(), QNetworkProxyQuery::TcpServer));

    QCOMPARE(listenResult, !fails);
    QCOMPARE(server.errorString().isEmpty(), !fails);

    // note: the following test is not a hard failure.
    // Sometimes, error codes change for the better
    QTEST(int(server.serverError()), "expectedError");
}
void tst_QMailAddress::isEmailAddress()
{
    QFETCH( QString, address );

    QMailAddress addr = QMailAddress(QString(), address);
    QTEST(addr.isEmailAddress(), "emailAddress");
}
void tst_QMailAddress::isPhoneNumber()
{
    QFETCH( QString, address );

    QMailAddress addr = QMailAddress(QString(), address);
    QTEST(addr.isPhoneNumber(), "phoneNumber");
}
示例#14
0
void tst_QHostAddress::constructor_QString()
{
    QFETCH(QString, address);
    QFETCH(bool, ok);
    QFETCH(int, protocol);

    QHostAddress hostAddr(address);

    if (address == "0.0.0.0" || address == "::") {
        QVERIFY(ok);
    } else {
        QVERIFY(hostAddr.isNull() != ok);
    }

    if (ok)
        QTEST(hostAddr.toString(), "resAddr");

    if ( protocol == 4 ) {
        QVERIFY( hostAddr.protocol() == QAbstractSocket::IPv4Protocol || hostAddr.protocol() == QAbstractSocket::UnknownNetworkLayerProtocol );
        QVERIFY( hostAddr.protocol() != QAbstractSocket::IPv6Protocol );
    } else if ( protocol == 6 ) {
        QVERIFY( hostAddr.protocol() != QAbstractSocket::IPv4Protocol && hostAddr.protocol() != QAbstractSocket::UnknownNetworkLayerProtocol );
        QVERIFY( hostAddr.protocol() == QAbstractSocket::IPv6Protocol );
    } else {
        QVERIFY( hostAddr.isNull() );
        QVERIFY( hostAddr.protocol() == QAbstractSocket::UnknownNetworkLayerProtocol );
    }
}
示例#15
0
void tst_QByteArray::qCompress()
{
    QFETCH( QByteArray, ba );
    QByteArray compressed = ::qCompress( ba );
    //qDebug( "size uncompressed: %d    size compressed: %d", ba.size(), compressed.size() );
    QTEST( ::qUncompress( compressed ), "ba" );
}
示例#16
0
void tst_QFileInfo::size()
{
    QFETCH(QString, file);

    QFileInfo fi(file);
    (void)fi.permissions();     // see task 104198
    QTEST(int(fi.size()), "size");
}
示例#17
0
void tst_QHostAddress::isInSubnet()
{
    QFETCH(QHostAddress, address);
    QFETCH(QHostAddress, prefix);
    QFETCH(int, prefixLength);

    QTEST(address.isInSubnet(prefix, prefixLength), "result");
}
示例#18
0
void tst_QByteArray::qUncompress()
{
    QFETCH(QByteArray, in);

#if defined Q_OS_HPUX && !defined __ia64 && defined Q_CC_GNU
    QSKIP("Corrupt data causes this tests to lock up on HP-UX / PA-RISC with gcc", SkipAll);
#elif defined Q_OS_SOLARIS
    QSKIP("Corrupt data causes this tests to lock up on Solaris", SkipAll);
#endif

    QTEST(::qUncompress(in), "out");

#if defined Q_WS_MAC && (MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_4)
    QSKIP("Corrupt data causes this test to lock up on Mac OS X Panther", SkipSingle);
#endif

    QTEST(::qUncompress(in + "blah"), "out");
}
static int badquotes(void)
{
    char *str = ne_strdup("alpha,'blah"), *pnt = str;
    
    QTEST("alpha");
    ON(ne_qtoken(&pnt, ',', QUOTES) != NULL);
    
    ne_free(str);
    return OK;
}
void tst_QMailAddress::groupMembers()
{
    QFETCH( QString, input );
    QFETCH( QString, input_name );
    QFETCH( QString, input_address );

    QMailAddress addr;
    if ( !input.isEmpty() )
        addr = QMailAddress( input );
    else
        addr = QMailAddress( input_name, input_address );

    QTEST( addr.name(), "name" );
    QTEST( addr.address(), "address" );
    QTEST( addr.toString(), "to_string" );
    QTEST( addr.isGroup(), "is_group" );

    QStringList names, addresses;
    foreach (const QMailAddress& member, addr.groupMembers()) {
        names.append(member.name());
        addresses.append(member.address());
    }

    QTEST( names, "member_names" );
    QTEST( addresses, "member_addresses" );
}
示例#21
0
void tst_QComplexText::bidiReorderString()
{
    QFETCH( QString, logical );
    QFETCH( int,  basicDir );

    // replace \n with Unicode newline. The new algorithm ignores \n
    logical.replace(QChar('\n'), QChar(0x2028));

    QTextEngine e(logical, QFont());
    e.option.setTextDirection((QChar::Direction)basicDir == QChar::DirL ? Qt::LeftToRight : Qt::RightToLeft);
    e.itemize();
    quint8 levels[256];
    int visualOrder[256];
    int nitems = e.layoutData->items.size();
    int i;
    for (i = 0; i < nitems; ++i) {
        //qDebug("item %d bidiLevel=%d", i,  e.items[i].analysis.bidiLevel);
        levels[i] = e.layoutData->items[i].analysis.bidiLevel;
    }
    e.bidiReorder(nitems, levels, visualOrder);

    QString visual;
    for (i = 0; i < nitems; ++i) {
        QScriptItem &si = e.layoutData->items[visualOrder[i]];
        QString sub = logical.mid(si.position, e.length(visualOrder[i]));
        if (si.analysis.bidiLevel % 2) {
            // reverse sub
            QChar *a = (QChar *)sub.unicode();
            QChar *b = a + sub.length() - 1;
            while (a < b) {
                QChar tmp = *a;
                *a = *b;
                *b = tmp;
                ++a;
                --b;
            }
            a = (QChar *)sub.unicode();
            b = a + sub.length();
            while (a<b) {
                *a = a->mirroredChar();
                ++a;
            }
        }
        visual += sub;
    }
    // replace Unicode newline back with  \n to compare.
    visual.replace(QChar(0x2028), QChar('\n'));

    QTEST(visual, "VISUAL");
}
示例#22
0
void tst_QBitArray::size()
{
    QFETCH(int,count);

    QString S;
    QBitArray a(count);
    a.fill(1);
    int len = a.size();
    for (int j=0; j<len; j++) {
	bool b = a[j];
	if (b)
	    S+= "1";
	else
	    S+= "0";
    }
    QTEST(S,"res");
}
示例#23
0
void tst_QTcpServer::invalidProxy()
{
    QFETCH_GLOBAL(bool, setProxy);
    if (setProxy)
        return;

    QFETCH(int, type);
    QFETCH(QString, host);
    QFETCH(int, port);
    QNetworkProxy::ProxyType proxyType = QNetworkProxy::ProxyType(type);
    QNetworkProxy proxy(proxyType, host, port);

    QTcpServer server;
    server.setProxy(proxy);
    bool listenResult = server.listen();

    QVERIFY(!listenResult);
    QVERIFY(!server.errorString().isEmpty());

    // note: the following test is not a hard failure.
    // Sometimes, error codes change for the better
    QTEST(int(server.serverError()), "expectedError");
}
示例#24
0
void tst_QStringIterator::sweep()
{
    QFETCH(QString, string);
    QFETCH(bool, valid);

    QStringIterator i(string);
    int count = 0;
    QString rebuiltString;

    while (i.hasNext()) {
        const uint peekedCodePoint = i.peekNext(~0u);
        const uint codePoint = i.next(~0u);

        QVERIFY(peekedCodePoint == codePoint);

        if (codePoint == ~0u)
            rebuiltString += *(i.position() - 1);
        else
            rebuiltString += QString::fromUcs4(&codePoint, 1);

        ++count;
    }

    QTEST(count, "count");
    QTEST(rebuiltString, "string");
    rebuiltString.clear();

    while (i.hasPrevious()) {
        const uint peekedCodePoint = i.peekPrevious(~0u);
        const uint codePoint = i.previous(~0u);

        QVERIFY(peekedCodePoint == codePoint);

        --count;
    }

    QCOMPARE(count, 0);

    while (i.hasNext()) {
        i.advance();
        ++count;
    }

    QTEST(count, "count");

    while (i.hasPrevious()) {
        i.recede();
        --count;
    }

    QCOMPARE(count, 0);

    if (valid) {
        while (i.hasNext()) {
            const uint peekedCodePoint = i.peekNextUnchecked();
            const uint codePoint = i.nextUnchecked();

            QVERIFY(peekedCodePoint == codePoint);
            QVERIFY(codePoint <= 0x10FFFFu);
            rebuiltString += QString::fromUcs4(&codePoint, 1);
            ++count;
        }

        QTEST(count, "count");
        QTEST(rebuiltString, "string");

        while (i.hasPrevious()) {
            const uint peekedCodePoint = i.peekPreviousUnchecked();
            const uint codePoint = i.previousUnchecked();

            QVERIFY(peekedCodePoint == codePoint);

            --count;
        }

        QCOMPARE(count, 0);

        while (i.hasNext()) {
            i.advanceUnchecked();
            ++count;
        }

        QTEST(count, "count");

        while (i.hasPrevious()) {
            i.recedeUnchecked();
            --count;
        }

        QCOMPARE(count, 0);
    }
}
void tst_QMailAddress::removeComments()
{
    QFETCH( QString, input );
    QTEST( QMailAddress::removeComments(input), "output" );
}
示例#26
0
void tst_QHashFunctions::qthash()
{
    QFETCH(QString, key);
    const uint result = qt_hash(key);
    QTEST(result, "hash");
}
void tst_QMailAddress::removeWhitespace()
{
    QFETCH( QString, input );
    QTEST( QMailAddress::removeWhitespace(input), "output" );
}
void tst_QMailAddress::toStringList()
{
    QFETCH( QList<QMailAddress>, address_list );
    QTEST( QMailAddress::toStringList(address_list), "string_list");
}
void tst_QMailAddress::fromStringList1()
{
    QFETCH( QString, string_list );
    QTEST( QMailAddress::fromStringList(string_list), "address_list");
}
示例#30
0
void tst_Q3CString::length()
{
    QFETCH( Q3CString, s1 );
    QTEST( (int)s1.length(), "res" );
}