diff options
author | Ingo Klöcker <[email protected]> | 2022-04-28 08:33:23 +0000 |
---|---|---|
committer | Ingo Klöcker <[email protected]> | 2022-04-28 08:33:23 +0000 |
commit | 359906c8bcde7e351540708777e3678fee0cc2c1 (patch) | |
tree | f5c66772415513cf6e7ae13a24dce39c36ef933f /lang/cpp | |
parent | cpp: Support new keylist modes (diff) | |
download | gpgme-359906c8bcde7e351540708777e3678fee0cc2c1.tar.gz gpgme-359906c8bcde7e351540708777e3678fee0cc2c1.zip |
cpp,tests: Verify that requested keylist mode is used
* lang/cpp/tests/run-getkey.cpp, lang/cpp/tests/run-keylist.cpp (main):
Check used keylist mode.
--
Since Context::setKeyListMode() does not return the error returned by
gpgme, we need to verify explicitly that the keylist mode was set
successfully.
GnuPG-bug-id: 5951
Diffstat (limited to 'lang/cpp')
-rw-r--r-- | lang/cpp/tests/run-getkey.cpp | 6 | ||||
-rw-r--r-- | lang/cpp/tests/run-keylist.cpp | 6 |
2 files changed, 12 insertions, 0 deletions
diff --git a/lang/cpp/tests/run-getkey.cpp b/lang/cpp/tests/run-getkey.cpp index 67ca281c..c47da0b5 100644 --- a/lang/cpp/tests/run-getkey.cpp +++ b/lang/cpp/tests/run-getkey.cpp @@ -140,6 +140,12 @@ main (int argc, char **argv) return -1; } ctx->setKeyListMode (mode); + if (ctx->keyListMode() != mode) { + // unfortunately, Context::setKeyListMode() does not return the error + // returned by gpgme + std::cerr << "Failed to set keylist mode. You may have used an invalid combination of options."; + return -1; + } Error err; const GpgME::Key key = ctx->key (*argv, err, only_secret); std::stringstream ss; diff --git a/lang/cpp/tests/run-keylist.cpp b/lang/cpp/tests/run-keylist.cpp index 9446257f..852e321d 100644 --- a/lang/cpp/tests/run-keylist.cpp +++ b/lang/cpp/tests/run-keylist.cpp @@ -141,6 +141,12 @@ main (int argc, char **argv) return -1; } ctx->setKeyListMode (mode); + if (ctx->keyListMode() != mode) { + // unfortunately, Context::setKeyListMode() does not return the error + // returned by gpgme + std::cerr << "Failed to set keylist mode. You may have used an invalid combination of options.\n"; + return -1; + } Error err = ctx->startKeyListing (*argv, only_secret); if (err) { std::cout << "Error: " << err.asString() << "\n"; |