Skip to content

Commit 360da82

Browse files
committed
checksum-test: Add test case to ensure that a context without any updates gives
the exact same result when finalized as one with a dummy update that pushes zero-sized data. * subversion/tests/libsvn_subr/checksum-test.c (test_checksum_ctx_no_updates): New test. (test_funcs): Run new test. git-svn-id: https://svn.apache.org/repos/asf/subversion/trunk@1931079 13f79535-47bb-0310-9956-ffa450edef68
1 parent 8052354 commit 360da82

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

subversion/tests/libsvn_subr/checksum-test.c

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525

2626
#include <zlib.h>
2727

28+
#include "svn_checksum.h"
2829
#include "svn_error.h"
2930
#include "svn_io.h"
3031

@@ -405,6 +406,29 @@ do_bench_test(apr_size_t blocksize, svn_checksum_kind_t kind, apr_pool_t *pool)
405406
return SVN_NO_ERROR;
406407
}
407408

409+
static svn_error_t *
410+
test_checksum_ctx_no_updates(apr_pool_t *pool)
411+
{
412+
svn_checksum_kind_t kind;
413+
414+
for (kind = svn_checksum_md5; kind <= svn_checksum_fnv1a_32x4; ++kind)
415+
{
416+
svn_checksum_ctx_t *ctx;
417+
svn_checksum_t *checksum1, *checksum2;
418+
419+
ctx = svn_checksum_ctx_create(kind, pool);
420+
SVN_ERR(svn_checksum_final(&checksum1, ctx, pool));
421+
422+
ctx = svn_checksum_ctx_create(kind, pool);
423+
SVN_ERR(svn_checksum_update(ctx, "", 0));
424+
SVN_ERR(svn_checksum_final(&checksum2, ctx, pool));
425+
426+
SVN_TEST_INT_ASSERT(svn_checksum_match(checksum1, checksum2), TRUE);
427+
}
428+
429+
return SVN_NO_ERROR;
430+
}
431+
408432
static svn_error_t *
409433
test_checksum_performance(apr_pool_t *pool)
410434
{
@@ -456,6 +480,8 @@ static struct svn_test_descriptor_t test_funcs[] =
456480
"reset checksummed stream"),
457481
SVN_TEST_PASS2(test_checksum_performance,
458482
"test checksum performance"),
483+
SVN_TEST_PASS2(test_checksum_ctx_no_updates,
484+
"test checksum context without updates"),
459485
SVN_TEST_NULL
460486
};
461487

0 commit comments

Comments
 (0)