diff options
author | Werner Koch <wk@gnupg.org> | 2019-05-07 11:01:15 +0200 |
---|---|---|
committer | Werner Koch <wk@gnupg.org> | 2019-05-07 11:09:09 +0200 |
commit | b5985d0ca21ca376f22c050857bfda05592cebef (patch) | |
tree | 8b74f3c0b662ce05981c86a6d7683583d8ce8d4d /common/t-name-value.c | |
parent | scd: Support direct use of app with PKSIGN/PKAUTH/PKDECRYPT. (diff) | |
download | gnupg2-b5985d0ca21ca376f22c050857bfda05592cebef.tar.xz gnupg2-b5985d0ca21ca376f22c050857bfda05592cebef.zip |
common: New functions nvc_delete_named and nvc_get_string.
* common/name-value.c (nvc_delete_named): New.
(nvc_get_string): New.
Signed-off-by: Werner Koch <wk@gnupg.org>
Diffstat (limited to 'common/t-name-value.c')
-rw-r--r-- | common/t-name-value.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/common/t-name-value.c b/common/t-name-value.c index 57f685ffb..13a383ddb 100644 --- a/common/t-name-value.c +++ b/common/t-name-value.c @@ -292,6 +292,7 @@ run_modification_tests (void) { gpg_error_t err; nvc_t pk; + nve_t e; gcry_sexp_t key; char *buf; @@ -344,6 +345,30 @@ run_modification_tests (void) assert (strcmp (buf, "") == 0); xfree (buf); + /* Test whether we can delete an entry by name. */ + err = nvc_add (pk, "Key:", "(3:foo)"); + assert (!err); + e = nvc_lookup (pk, "Key:"); + assert (e); + nvc_delete_named (pk, "Kez:"); /* Delete an inexistant name. */ + e = nvc_lookup (pk, "Key:"); + assert (e); + nvc_delete_named (pk, "Key:"); + e = nvc_lookup (pk, "Key:"); + assert (!e); + + /* Ditto but now whether it deletes all entries with that name. We + * don't use "Key" because that name is special in private key mode. */ + err = nvc_add (pk, "AKey:", "A-value"); + assert (!err); + err = nvc_add (pk, "AKey:", "B-value"); + assert (!err); + e = nvc_lookup (pk, "AKey:"); + assert (e); + nvc_delete_named (pk, "AKey:"); + e = nvc_lookup (pk, "AKey:"); + assert (!e); + nvc_set (pk, "Foo:", "A really long value spanning across multiple lines" " that has to be wrapped at a convenient space."); buf = nvc_to_string (pk); |