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
This commit is contained in:
parent
dea872f21f
commit
359906c8bc
@ -140,6 +140,12 @@ main (int argc, char **argv)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
ctx->setKeyListMode (mode);
|
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;
|
Error err;
|
||||||
const GpgME::Key key = ctx->key (*argv, err, only_secret);
|
const GpgME::Key key = ctx->key (*argv, err, only_secret);
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
|
@ -141,6 +141,12 @@ main (int argc, char **argv)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
ctx->setKeyListMode (mode);
|
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);
|
Error err = ctx->startKeyListing (*argv, only_secret);
|
||||||
if (err) {
|
if (err) {
|
||||||
std::cout << "Error: " << err.asString() << "\n";
|
std::cout << "Error: " << err.asString() << "\n";
|
||||||
|
Loading…
Reference in New Issue
Block a user