aboutsummaryrefslogtreecommitdiffstats
path: root/common/t-mapstrings.c
diff options
context:
space:
mode:
authorWerner Koch <[email protected]>2022-03-18 12:47:10 +0000
committerWerner Koch <[email protected]>2022-03-18 13:14:39 +0000
commit449d2fbcde630974628285d3405feb6ab2a812f9 (patch)
treee2eef0f8d1ff5e68d3bacb5a8193829cb31333b1 /common/t-mapstrings.c
parentgpg: Allow decryption of symencr even for non-compliant cipher. (diff)
downloadgnupg-449d2fbcde630974628285d3405feb6ab2a812f9.tar.gz
gnupg-449d2fbcde630974628285d3405feb6ab2a812f9.zip
common: New function map_static_strings
* common/mapstrings.c (struct intmapping_s): New. (map_static_strings): New. * common/stringhelp.c (do_strconcat): Rename to ... (vstrconcat): this and make global. * common/t-mapstrings.c (test_map_static_strings): New test.
Diffstat (limited to 'common/t-mapstrings.c')
-rw-r--r--common/t-mapstrings.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/common/t-mapstrings.c b/common/t-mapstrings.c
index 0856c3cc4..7dc622177 100644
--- a/common/t-mapstrings.c
+++ b/common/t-mapstrings.c
@@ -88,6 +88,31 @@ test_map_static_macro_string (void)
}
+static void
+test_map_static_strings (void)
+{
+ const char *s, *s1;
+
+ s1 = map_static_strings ("mydomain", 0, 42,
+ "This", " ", "is", " ", "my"," ","string", NULL);
+ if (strcmp (s1, "This is my string"))
+ fail (1);
+ s = map_static_strings ("mydomain", 0, 42,
+ "This", " ", "is", " ", "my"," ","string", NULL);
+ if (strcmp (s1, s))
+ fail (2);
+ s = map_static_strings ("mydomain", 0, 42, "foo", NULL);
+ if (strcmp (s1, s))
+ fail (3);
+ s = map_static_strings ("mydomain", 1, 42, "foo 1.42", NULL);
+ if (!strcmp (s1, s))
+ fail (4);
+ s = map_static_strings ("xdomain", 1, 42, "foo 1.42 other domain", NULL);
+ if (!strcmp (s1, s))
+ fail (5);
+}
+
+
int
main (int argc, char **argv)
{
@@ -95,6 +120,7 @@ main (int argc, char **argv)
(void)argv;
test_map_static_macro_string ();
+ test_map_static_strings ();
return 0;
}