diff options
author | Kitsune Ral <Kitsune-Ral@users.sf.net> | 2020-06-26 18:57:52 +0200 |
---|---|---|
committer | Kitsune Ral <Kitsune-Ral@users.sf.net> | 2020-07-18 18:20:27 +0200 |
commit | 227d7c0ba26c3eb3e7394e0a5b7cc79544db7515 (patch) | |
tree | c826009e375e9ccf7e419309a3cedb8f4ccbdca3 /tests | |
parent | 4dd51859c9ada4660e2a9cd16c3d0a99ad13761f (diff) | |
download | libquotient-227d7c0ba26c3eb3e7394e0a5b7cc79544db7515.tar.gz libquotient-227d7c0ba26c3eb3e7394e0a5b7cc79544db7515.zip |
quotest: unit tests for MatrixUri
Diffstat (limited to 'tests')
-rw-r--r-- | tests/quotest.cpp | 25 |
1 files changed, 23 insertions, 2 deletions
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, }; |