示例#1
0
TEST(IdsTest, toUrlToStringToVariantTest) {
	QString const idString = "qrm:/editor/diagram/element/id";
	Id const id = Id::loadFromString(idString);

	EXPECT_EQ(id.toString(), idString);
	EXPECT_EQ(id.toUrl(), QUrl(idString));

	QVariant toVariant = id.toVariant();
	EXPECT_EQ(toVariant.value<Id>(), id);
}
示例#2
0
文件: ids.cpp 项目: elenazab/qreal
Id Id::loadFromString(QString const &string)
{
	QStringList path = string.split('/');
	Q_ASSERT(path.count() > 0 && path.count() <= 5);
	Q_ASSERT(path[0] == "qrm:");

	Id result;
	switch (path.count()) {
		case 5: result.mId = path[4];
			// Fall-thru
		case 4: result.mElement = path[3];
			// Fall-thru
		case 3: result.mDiagram = path[2];
			// Fall-thru
		case 2: result.mEditor = path[1];
			// Fall-thru
	}
	Q_ASSERT(string == result.toString());
	Q_ASSERT(string == result.toUrl().toString());
	return result;
}