mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-24 04:13:28 +01:00
Use tt_int_op() over tt_assert() and do explicit NULL checks in test_util_gzip().
This patch changes some of the tt_assert() usage in test_util_gzip() to use tt_int_op() to get better error messages upon failure. Additionally we move to use explicit NULL checks. See https://bugs.torproject.org/21663
This commit is contained in:
parent
b081a7ed21
commit
a8821d8366
@ -2257,13 +2257,13 @@ test_util_gzip(void *arg)
|
||||
|
||||
tt_assert(!tor_gzip_compress(&buf2, &len1, buf1, strlen(buf1)+1,
|
||||
GZIP_METHOD));
|
||||
tt_assert(buf2);
|
||||
tt_assert(len1 < strlen(buf1));
|
||||
tt_assert(detect_compression_method(buf2, len1) == GZIP_METHOD);
|
||||
tt_assert(buf2 != NULL);
|
||||
tt_int_op(len1, OP_LT, strlen(buf1));
|
||||
tt_int_op(detect_compression_method(buf2, len1), OP_EQ, GZIP_METHOD);
|
||||
|
||||
tt_assert(!tor_gzip_uncompress(&buf3, &len2, buf2, len1,
|
||||
GZIP_METHOD, 1, LOG_INFO));
|
||||
tt_assert(buf3);
|
||||
tt_assert(buf3 != NULL);
|
||||
tt_int_op(strlen(buf1) + 1,OP_EQ, len2);
|
||||
tt_str_op(buf1,OP_EQ, buf3);
|
||||
|
||||
@ -2273,11 +2273,11 @@ test_util_gzip(void *arg)
|
||||
tt_assert(!tor_gzip_compress(&buf2, &len1, buf1, strlen(buf1)+1,
|
||||
ZLIB_METHOD));
|
||||
tt_assert(buf2);
|
||||
tt_assert(detect_compression_method(buf2, len1) == ZLIB_METHOD);
|
||||
tt_int_op(detect_compression_method(buf2, len1), OP_EQ, ZLIB_METHOD);
|
||||
|
||||
tt_assert(!tor_gzip_uncompress(&buf3, &len2, buf2, len1,
|
||||
ZLIB_METHOD, 1, LOG_INFO));
|
||||
tt_assert(buf3);
|
||||
tt_assert(buf3 != NULL);
|
||||
tt_int_op(strlen(buf1) + 1,OP_EQ, len2);
|
||||
tt_str_op(buf1,OP_EQ, buf3);
|
||||
|
||||
@ -2302,7 +2302,7 @@ test_util_gzip(void *arg)
|
||||
tor_strdup("String with low redundancy that won't be compressed much.");
|
||||
tt_assert(!tor_gzip_compress(&buf2, &len1, buf1, strlen(buf1)+1,
|
||||
ZLIB_METHOD));
|
||||
tt_assert(len1>16);
|
||||
tt_int_op(len1, OP_GT, 16);
|
||||
/* when we allow an incomplete string, we should succeed.*/
|
||||
tt_assert(!tor_gzip_uncompress(&buf3, &len2, buf2, len1-16,
|
||||
ZLIB_METHOD, 0, LOG_INFO));
|
||||
@ -2314,7 +2314,7 @@ test_util_gzip(void *arg)
|
||||
tor_free(buf3);
|
||||
tt_assert(tor_gzip_uncompress(&buf3, &len2, buf2, len1-16,
|
||||
ZLIB_METHOD, 1, LOG_INFO));
|
||||
tt_assert(!buf3);
|
||||
tt_assert(buf3 == NULL);
|
||||
|
||||
/* Now, try streaming compression. */
|
||||
tor_free(buf1);
|
||||
|
Loading…
Reference in New Issue
Block a user