1
0
mirror of https://sourceware.org/git/glibc.git synced 2025-08-08 17:42:12 +03:00

Add TEST_COMPARE_STRING_WIDE to support/check.h

I'd like to be able to test narrow and wide string interfaces, with
the narrow string tests using TEST_COMPARE_STRING and the wide string
tests using something analogous (possibly generated using macros from
a common test template for both the narrow and wide string tests where
appropriate).

Add such a TEST_COMPARE_STRING_WIDE, along with functions
support_quote_blob_wide and support_test_compare_string_wide that it
builds on.  Those functions are built using macros from common
templates shared by the narrow and wide string implementations, though
I didn't do that for the tests of test functions.  In
support_quote_blob_wide, I chose to use the \x{} delimited escape
sequence syntax proposed for C2X in N2785, rather than e.g. trying to
generate the end of a string and the start of a new string when
ambiguity would result from undelimited \x (when the next character
after such an escape sequence is valid hex) or forcing an escape
sequence to be used for the next character in the case of such
ambiguity.

Tested for x86_64.
This commit is contained in:
Joseph Myers
2021-10-12 13:48:39 +00:00
parent 4912c738fc
commit de82cb0da4
11 changed files with 447 additions and 137 deletions

View File

@@ -73,6 +73,12 @@ void support_write_file_string (const char *path, const char *contents);
the result). */
char *support_quote_blob (const void *blob, size_t length);
/* Quote the contents of the wide character array starting at BLOB, of
LENGTH wide characters, in such a way that the result string can be
included in a C wide string literal (in single/double quotes,
without putting the quotes into the result). */
char *support_quote_blob_wide (const void *blob, size_t length);
/* Quote the contents of the string, in such a way that the result
string can be included in a C literal (in single/double quotes,
without putting the quotes into the result). */