add test case for recursive placeholders

This commit is contained in:
thez3ro 2018-03-05 23:32:04 +01:00 committed by TheZ3ro
parent 18628612b2
commit 10170a555e
2 changed files with 12 additions and 1 deletions

View File

@ -796,7 +796,7 @@ QString Entry::resolvePlaceholderRecursive(const QString& placeholder, int maxDe
switch (typeOfPlaceholder) {
case PlaceholderType::NotPlaceholder:
case PlaceholderType::Unknown:
return placeholder;
return resolveMultiplePlaceholdersRecursive(placeholder, maxDepth - 1);
case PlaceholderType::Title:
if (placeholderType(title()) == PlaceholderType::Title) {
return title();

View File

@ -279,6 +279,17 @@ void TestEntry::testResolveRecursivePlaceholders()
QCOMPARE(entry6->resolvePlaceholder(entry6->title()), QString("Entry2Title"));
QCOMPARE(entry6->resolvePlaceholder(entry6->username()), QString("Entry2Title"));
QCOMPARE(entry6->resolvePlaceholder(entry6->password()), QString("{PASSWORD}"));
auto* entry7 = new Entry();
entry7->setGroup(root);
entry7->setUuid(Uuid::random());
entry7->setTitle(QString("{REF:T@I:%1} and something else").arg(entry3->uuid().toHex()));
entry7->setUsername(QString("{TITLE}"));
entry7->setPassword(QString("PASSWORD"));
QCOMPARE(entry7->resolvePlaceholder(entry7->title()), QString("Entry2Title and something else"));
QCOMPARE(entry7->resolvePlaceholder(entry7->username()), QString("Entry2Title and something else"));
QCOMPARE(entry7->resolvePlaceholder(entry7->password()), QString("PASSWORD"));
}
void TestEntry::testResolveReferencePlaceholders()