diff options
author | Joseph Myers <joseph@codesourcery.com> | 2021-10-12 13:48:39 +0000 |
---|---|---|
committer | Joseph Myers <joseph@codesourcery.com> | 2021-10-12 13:48:39 +0000 |
commit | de82cb0da4b8fa5b3d56c457438d2568c67ab1b1 (patch) | |
tree | 396836ad8aa0a466b0cc8a379c6933b972780ce9 /support/check.h | |
parent | 4912c738fcbc6def723370ec3a7ab4a732361322 (diff) | |
download | glibc-de82cb0da4b8fa5b3d56c457438d2568c67ab1b1.tar.gz glibc-de82cb0da4b8fa5b3d56c457438d2568c67ab1b1.tar.xz glibc-de82cb0da4b8fa5b3d56c457438d2568c67ab1b1.zip |
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.
Diffstat (limited to 'support/check.h')
-rw-r--r-- | support/check.h | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/support/check.h b/support/check.h index 83662b2d10..9b1844352f 100644 --- a/support/check.h +++ b/support/check.h @@ -20,6 +20,7 @@ #define SUPPORT_CHECK_H #include <sys/cdefs.h> +#include <stddef.h> __BEGIN_DECLS @@ -171,11 +172,25 @@ void support_test_compare_blob (const void *left, (support_test_compare_string (left, right, __FILE__, __LINE__, \ #left, #right)) +/* Compare the wide strings LEFT and RIGHT and report a test failure + if they are different. Also report failure if one of the arguments + is a null pointer and the other is not. The strings should be + reasonably short because on mismatch, both are printed. */ +#define TEST_COMPARE_STRING_WIDE(left, right) \ + (support_test_compare_string_wide (left, right, __FILE__, __LINE__, \ + #left, #right)) + void support_test_compare_string (const char *left, const char *right, const char *file, int line, const char *left_expr, const char *right_expr); +void support_test_compare_string_wide (const wchar_t *left, + const wchar_t *right, + const char *file, int line, + const char *left_expr, + const char *right_expr); + /* Internal function called by the test driver. */ int support_report_failure (int status) __attribute__ ((weak, warn_unused_result)); |