Example #1
0
void tst_QUrlQuery::setQueryItems()
{
    QFETCH(QueryItems, items);
    QUrlQuery query;

    QueryItems::const_iterator it = items.constBegin();
    for ( ; it != items.constEnd(); ++it)
        query.addQueryItem(it->first, it->second);
    COMPARE_ITEMS(query.queryItems(), items);

    query.clear();

    query.setQueryItems(items);
    COMPARE_ITEMS(query.queryItems(), items);
}
Example #2
0
void tst_QUrlQuery::basicParsing()
{
    QFETCH(QString, queryString);
    QFETCH(QueryItems, items);

    QUrlQuery query(queryString);
    QCOMPARE(query.isEmpty(), items.isEmpty());
    COMPARE_ITEMS(query.queryItems(), items);
}
Example #3
0
void tst_QUrlQuery::encodedParsing()
{
    QFETCH(QString, queryString);
    QFETCH(QString, expectedQuery);
    QFETCH(QString, expectedKey);
    QFETCH(QString, expectedValue);
    QFETCH(QUrl::ComponentFormattingOptions, encoding);

    QUrlQuery query(queryString);
    COMPARE_ITEMS(query.queryItems(encoding), QueryItems() << qItem(expectedKey, expectedValue));
    QCOMPARE(query.query(encoding), expectedQuery);
}
Example #4
0
void tst_QUrlQuery::differentDelimiters()
{
    QUrlQuery query;
    query.setQueryDelimiters('(', ')');

    {
        // parse:
        query.setQuery("foo(bar)hello(world)");

        QueryItems expected;
        expected << qItem("foo", "bar") << qItem("hello", "world");
        COMPARE_ITEMS(query.queryItems(), expected);
        COMPARE_ITEMS(query.queryItems(QUrl::FullyEncoded), expected);
        COMPARE_ITEMS(query.queryItems(QUrl::PrettyDecoded), expected);
    }

    {
        // reconstruct:
        // note the final ')' is missing because there are no further items
        QCOMPARE(query.query(), QString("foo(bar)hello(world"));
    }

    {
        // set items containing the new delimiters and the old ones
        query.clear();
        query.addQueryItem("z(=)", "y(&)");
        QCOMPARE(query.query(), QString("z%28=%29(y%28&%29"));

        QUrlQuery copy = query;
        QCOMPARE(query.query(), QString("z%28=%29(y%28&%29"));

        copy.setQueryDelimiters(QUrlQuery::defaultQueryValueDelimiter(),
                                QUrlQuery::defaultQueryPairDelimiter());
        QCOMPARE(copy.query(), QString("z(%3D)=y(%26)"));
    }
}
Example #5
0
int ADVBPatterns::SortTermsByAssign(uptr_t item1, uptr_t item2, void *context)
{
	const TERM *term1 = (const TERM *)item1;
	const TERM *term2 = (const TERM *)item2;
	bool assign1 = RANGE(term1->data.opcode, Operator_First_Assignable, Operator_Last_Assignable);
	bool assign2 = RANGE(term2->data.opcode, Operator_First_Assignable, Operator_Last_Assignable);

	UNUSED(context);

	if ( assign1 && !assign2) return  1;
	if (!assign1 &&  assign2) return -1;
	if ( assign1 &&  assign2) return COMPARE_ITEMS(term1->data.field, term2->data.field);

	return 0;
}
Example #6
0
sint_t AFileNode::CompareBySize(const AListNode *pNode1, const AListNode *pNode2, void *context)
{
	const AFileNode *fNode1 = AFileNode::Cast(pNode1);
	const AFileNode *fNode2 = AFileNode::Cast(pNode2);
	uint_t flags = context ? *(uint_t *)context : 0;
	sint_t ret = 0, mul = (flags & SORT_FLAG_REVERSE) ? -1 : 1;
	bool mixed = ((flags & SORT_FLAG_MIXED) != 0);

	if (fNode1 && fNode2) {
		if (mixed || (fNode1->IsDir() == fNode2->IsDir())) {
			ret = mul * COMPARE_ITEMS(fNode1->GetFileSize(), fNode2->GetFileSize());
			if (ret == 0) ret = mul * CompareNoCase(fNode1->GetShortName(), fNode2->GetShortName());
		}
		else if (fNode1->IsDir()) ret = -1;
		else					  ret =  1;
	}

	return ret;
}