aboutsummaryrefslogtreecommitdiffstats
path: root/tests/t-name-value.c
diff options
context:
space:
mode:
authorWerner Koch <[email protected]>2025-04-07 09:20:53 +0000
committerWerner Koch <[email protected]>2025-04-07 09:20:53 +0000
commitafb277e5bdd92c16a4fdbd33b89dab4c03a5ae62 (patch)
tree6a8e48b7fe17fbd2175aae54329e18e22d32ddde /tests/t-name-value.c
parentNew public API gpgrt_nvc_* and gpgrt_nve_* (diff)
downloadlibgpg-error-afb277e5bdd92c16a4fdbd33b89dab4c03a5ae62.tar.gz
libgpg-error-afb277e5bdd92c16a4fdbd33b89dab4c03a5ae62.zip
Allow name-value lookup w/o a trailing colon for the name.
* src/name-value.c (_gpgrt_name_value_entry): Add field namelen. (ascii_memcasecmp): New. (same_name_p): New. (valid_name): Strip the colon and return the length. (do_nvc_add): Set namelen. (_gpgrt_nvc_lookup): Simplify. * tests/t-name-value.c (test_getting_values): Add some extra tests. -- The requirement for a colon after the name is too cumbersome.
Diffstat (limited to 'tests/t-name-value.c')
-rw-r--r--tests/t-name-value.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/t-name-value.c b/tests/t-name-value.c
index 7a28bf4..b4c618c 100644
--- a/tests/t-name-value.c
+++ b/tests/t-name-value.c
@@ -139,6 +139,24 @@ test_getting_values (gpgrt_nvc_t pk)
e = gpgrt_nvc_lookup (pk, "SomeOtherName:");
gpgrt_assert (e);
+
+ /* The colon is optional. */
+ e = gpgrt_nvc_lookup (pk, "comment");
+ gpgrt_assert (e);
+ e = gpgrt_nvc_lookup (pk, "COMMENT");
+ gpgrt_assert (e);
+
+ e = gpgrt_nvc_lookup (pk, "SomeOtherName");
+ gpgrt_assert (e);
+
+ /* And check one which does not exist. */
+ e = gpgrt_nvc_lookup (pk, "SomeOtherNam");
+ gpgrt_assert (!e);
+ e = gpgrt_nvc_lookup (pk, "SomeOtherNam:");
+ gpgrt_assert (!e);
+ e = gpgrt_nvc_lookup (pk, "SomeOtherNam :");
+ gpgrt_assert (!e);
+
}