From 449d2fbcde630974628285d3405feb6ab2a812f9 Mon Sep 17 00:00:00 2001 From: Werner Koch Date: Fri, 18 Mar 2022 13:47:10 +0100 Subject: 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. --- common/t-mapstrings.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'common/t-mapstrings.c') 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; } -- cgit v1.2.3