mirror of
https://github.com/openssl/openssl.git
synced 2026-01-18 17:11:31 +01:00
test: get rid of the TEST_strn2_ functions
Their semantics are poorly defined and they are rarely used. The _ne version being completely unused & tricky to define properly. Reviewed-by: Norbert Pocs <norbertp@openssl.org> Reviewed-by: Nikola Pajkovsky <nikolap@openssl.org> Reviewed-by: Frederik Wedel-Heinen <fwh.openssl@gmail.com> (Merged from https://github.com/openssl/openssl/pull/29627)
This commit is contained in:
@@ -355,9 +355,9 @@ DECLARE_COMPARISON(char *, str, ne)
|
||||
* Same as above, but for strncmp.
|
||||
*/
|
||||
int test_strn_eq(const char *file, int line, const char *, const char *,
|
||||
const char *a, size_t an, const char *b, size_t bn);
|
||||
const char *a, const char *b, size_t n);
|
||||
int test_strn_ne(const char *file, int line, const char *, const char *,
|
||||
const char *a, size_t an, const char *b, size_t bn);
|
||||
const char *a, const char *b, size_t n);
|
||||
|
||||
/*
|
||||
* Equality test for memory blocks where NULL is a legitimate value.
|
||||
@@ -511,10 +511,8 @@ void test_perror(const char *s);
|
||||
|
||||
#define TEST_str_eq(a, b) test_str_eq(__FILE__, __LINE__, #a, #b, a, b)
|
||||
#define TEST_str_ne(a, b) test_str_ne(__FILE__, __LINE__, #a, #b, a, b)
|
||||
#define TEST_strn_eq(a, b, n) test_strn_eq(__FILE__, __LINE__, #a, #b, a, n, b, n)
|
||||
#define TEST_strn_ne(a, b, n) test_strn_ne(__FILE__, __LINE__, #a, #b, a, n, b, n)
|
||||
#define TEST_strn2_eq(a, m, b, n) test_strn_eq(__FILE__, __LINE__, #a, #b, a, m, b, n)
|
||||
#define TEST_strn2_ne(a, m, b, n) test_strn_ne(__FILE__, __LINE__, #a, #b, a, m, b, n)
|
||||
#define TEST_strn_eq(a, b, n) test_strn_eq(__FILE__, __LINE__, #a, #b, a, b, n)
|
||||
#define TEST_strn_ne(a, b, n) test_strn_ne(__FILE__, __LINE__, #a, #b, a, b, n)
|
||||
|
||||
#define TEST_mem_eq(a, m, b, n) test_mem_eq(__FILE__, __LINE__, #a, #b, a, m, b, n)
|
||||
#define TEST_mem_ne(a, m, b, n) test_mem_ne(__FILE__, __LINE__, #a, #b, a, m, b, n)
|
||||
|
||||
@@ -302,28 +302,28 @@ int test_str_ne(const char *file, int line, const char *st1, const char *st2,
|
||||
}
|
||||
|
||||
int test_strn_eq(const char *file, int line, const char *st1, const char *st2,
|
||||
const char *s1, size_t n1, const char *s2, size_t n2)
|
||||
const char *s1, const char *s2, size_t n)
|
||||
{
|
||||
if (s1 == NULL && s2 == NULL)
|
||||
return 1;
|
||||
if (n1 != n2 || s1 == NULL || s2 == NULL || strncmp(s1, s2, n1) != 0) {
|
||||
if (s1 == NULL || s2 == NULL || strncmp(s1, s2, n) != 0) {
|
||||
test_fail_string_message(NULL, file, line, "string", st1, st2, "==",
|
||||
s1, s1 == NULL ? 0 : OPENSSL_strnlen(s1, n1),
|
||||
s2, s2 == NULL ? 0 : OPENSSL_strnlen(s2, n2));
|
||||
s1, s1 == NULL ? 0 : OPENSSL_strnlen(s1, n),
|
||||
s2, s2 == NULL ? 0 : OPENSSL_strnlen(s2, n));
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
int test_strn_ne(const char *file, int line, const char *st1, const char *st2,
|
||||
const char *s1, size_t n1, const char *s2, size_t n2)
|
||||
const char *s1, const char *s2, size_t n)
|
||||
{
|
||||
if ((s1 == NULL) ^ (s2 == NULL))
|
||||
return 1;
|
||||
if (n1 != n2 || s1 == NULL || strncmp(s1, s2, n1) == 0) {
|
||||
if (s1 == NULL || strncmp(s1, s2, n) == 0) {
|
||||
test_fail_string_message(NULL, file, line, "string", st1, st2, "!=",
|
||||
s1, s1 == NULL ? 0 : OPENSSL_strnlen(s1, n1),
|
||||
s2, s2 == NULL ? 0 : OPENSSL_strnlen(s2, n2));
|
||||
s1, s1 == NULL ? 0 : OPENSSL_strnlen(s1, n),
|
||||
s2, s2 == NULL ? 0 : OPENSSL_strnlen(s2, n));
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
|
||||
Reference in New Issue
Block a user