summaryrefslogtreecommitdiff
path: root/src/or/test.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2005-08-29 18:01:38 +0000
committerNick Mathewson <nickm@torproject.org>2005-08-29 18:01:38 +0000
commit29a6c17d6796119f57cfaae32b887cbd253a4c9f (patch)
tree3bf23c5f3515eb783717584711801b2bbe7d783f /src/or/test.c
parent445bce75dcfa0abda711a2dfa3fafa1da25b3215 (diff)
downloadtor-29a6c17d6796119f57cfaae32b887cbd253a4c9f.tar.gz
tor-29a6c17d6796119f57cfaae32b887cbd253a4c9f.zip
Allow tor_gzip_uncompress to handle multiple concatenated compressed strings.
svn:r4882
Diffstat (limited to 'src/or/test.c')
-rw-r--r--src/or/test.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/or/test.c b/src/or/test.c
index 067cb9c6c1..3ba9a7fcfa 100644
--- a/src/or/test.c
+++ b/src/or/test.c
@@ -908,7 +908,7 @@ test_gzip(void)
char *buf1, *buf2=NULL, *buf3=NULL;
size_t len1, len2;
- buf1 = tor_strdup("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA");
+ buf1 = tor_strdup("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAZAAAAAAAAAAAAAAAAAAAZ");
test_eq(detect_compression_method(buf1, strlen(buf1)), 0);
if (is_gzip_supported()) {
test_assert(!tor_gzip_compress(&buf2, &len1, buf1, strlen(buf1)+1,
@@ -935,6 +935,16 @@ test_gzip(void)
test_assert(buf3);
test_streq(buf1,buf3);
+ tor_free(buf3);
+ buf2 = tor_realloc(buf2, len1*2);
+ memcpy(buf2+len1, buf2, len1);
+ test_assert(!tor_gzip_uncompress(&buf3, &len2, buf2, len1*2, ZLIB_METHOD));
+ test_eq(len2, (strlen(buf1)+1)*2);
+ test_memeq(buf3,
+ "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAZAAAAAAAAAAAAAAAAAAAZ\0"
+ "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAZAAAAAAAAAAAAAAAAAAAZ\0",
+ (strlen(buf1)+1)*2);
+
tor_free(buf2);
tor_free(buf3);
tor_free(buf1);