From 227d7c0ba26c3eb3e7394e0a5b7cc79544db7515 Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Fri, 26 Jun 2020 18:57:52 +0200 Subject: quotest: unit tests for MatrixUri --- tests/quotest.cpp | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) (limited to 'tests/quotest.cpp') diff --git a/tests/quotest.cpp b/tests/quotest.cpp index f9e25284..52915454 100644 --- a/tests/quotest.cpp +++ b/tests/quotest.cpp @@ -635,7 +635,7 @@ TEST_IMPL(visitResources) MatrixUri uri { uriString }; clog << "Checking " << uriString.toStdString() << " -> " << uri.toDisplayString().toStdString() << endl; - rr.openResource(connection(), uri); + rr.openResource(connection(), uriString); if (spy.count() != 1) { clog << "Wrong number of signal emissions (" << spy.count() << ')' << endl; @@ -663,6 +663,27 @@ TEST_IMPL(visitResources) return false; }; + // Basic tests + QUrl invalidUrl { "https://" }; + invalidUrl.setAuthority("---:@@@"); + const MatrixUri emptyUri {}, uriFromEmptyUrl {}, + invalidMatrixUri { QStringLiteral("matrix:&invalid@") }, + matrixUriFromInvalidUrl { invalidUrl }; + + for (const auto& u: { emptyUri, uriFromEmptyUrl }) + if (u.isValid() || !u.isEmpty()) { + clog << "Empty Matrix URI test failed" << endl; + FAIL_TEST(); + } + if (matrixUriFromInvalidUrl.isEmpty() || matrixUriFromInvalidUrl.isValid()) { + clog << "Invalid Matrix URI test failed" << endl; + FAIL_TEST(); + } + if (invalidMatrixUri.isEmpty() || invalidMatrixUri.isValid()) { + clog << "Invalid sigil in a Matrix URI - test failed" << endl; + FAIL_TEST(); + } + // Matrix identifiers used throughout all URI tests const auto& roomId = room()->id(); const auto& roomAlias = room()->canonicalAlias(); @@ -675,7 +696,7 @@ TEST_IMPL(visitResources) const QStringList roomUris { roomId, "matrix:roomid/" + roomId.mid(1), - "https://matrix.to/#/%21" + roomId.mid(1), + "https://matrix.to/#/%21"/*`!`*/ + roomId.mid(1), roomAlias, "matrix:room/" + roomAlias.mid(1), "https://matrix.to/#/" + roomAlias, }; -- cgit v1.2.3