diff options
author | Andre Heinecke <[email protected]> | 2018-10-09 07:37:28 +0000 |
---|---|---|
committer | Andre Heinecke <[email protected]> | 2018-10-09 07:37:28 +0000 |
commit | bf4aae45129c1093ee7712bdbcdfe1c8f2ca7c0f (patch) | |
tree | 144026c7f3a59a80890c4e00cbba6da3b70b5365 | |
parent | Post release updates (diff) | |
download | gpgme-bf4aae45129c1093ee7712bdbcdfe1c8f2ca7c0f.tar.gz gpgme-bf4aae45129c1093ee7712bdbcdfe1c8f2ca7c0f.zip |
qt, tests: Add test for single get key
* lang/qt/tests/t-keylist.cpp (testGetKey): New.
--
Added this to check if there was a memleak in that function.
-rw-r--r-- | lang/qt/tests/t-keylist.cpp | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/lang/qt/tests/t-keylist.cpp b/lang/qt/tests/t-keylist.cpp index bf57ba75..21349c1c 100644 --- a/lang/qt/tests/t-keylist.cpp +++ b/lang/qt/tests/t-keylist.cpp @@ -42,6 +42,10 @@ #include "qgpgmebackend.h" #include "keylistresult.h" +#include "context.h" + +#include <memory> + #include "t-support.h" using namespace QGpgME; @@ -72,6 +76,35 @@ private Q_SLOTS: QVERIFY (keys[0].subkeys()[1].publicKeyAlgorithm() == Subkey::AlgoELG_E); } + // This test can help with valgrind to check for memleaks when handling + // keys + void testGetKey() + { + GpgME::Key key; + { + auto ctx = std::unique_ptr<GpgME::Context> (GpgME::Context::createForProtocol(GpgME::OpenPGP)); + ctx->setKeyListMode (GpgME::KeyListMode::Local | + GpgME::KeyListMode::Signatures | + GpgME::KeyListMode::Validate | + GpgME::KeyListMode::WithTofu); + GpgME::Error err; + key = ctx->key ("A0FF4590BB6122EDEF6E3C542D727CC768697734", err, false); + } + QVERIFY(key.primaryFingerprint()); + QVERIFY(!strcmp(key.primaryFingerprint(), "A0FF4590BB6122EDEF6E3C542D727CC768697734")); + { + auto ctx = std::unique_ptr<GpgME::Context> (GpgME::Context::createForProtocol(GpgME::OpenPGP)); + ctx->setKeyListMode (GpgME::KeyListMode::Local | + GpgME::KeyListMode::Signatures | + GpgME::KeyListMode::Validate | + GpgME::KeyListMode::WithTofu); + GpgME::Error err; + key = ctx->key ("A0FF4590BB6122EDEF6E3C542D727CC768697734", err, false); + } + QVERIFY(key.primaryFingerprint()); + QVERIFY(!strcmp(key.primaryFingerprint(), "A0FF4590BB6122EDEF6E3C542D727CC768697734")); + } + void testPubkeyAlgoAsString() { static const QMap<Subkey::PubkeyAlgo, QString> expected { |