1
0
Fork 0
mirror of git://git.gnupg.org/gnupg.git synced 2025-07-03 22:56:33 +02:00

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.
This commit is contained in:
Werner Koch 2022-03-18 13:47:10 +01:00
parent 8631d4cfe2
commit 449d2fbcde
No known key found for this signature in database
GPG key ID: E3FDFF218E45B72B
4 changed files with 86 additions and 5 deletions

View file

@ -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;
}