You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by gs...@apache.org on 2011/09/20 16:14:58 UTC
svn commit: r1173162 -
/subversion/trunk/subversion/tests/libsvn_subr/spillbuf-test.c
Author: gstein
Date: Tue Sep 20 14:14:57 2011
New Revision: 1173162
URL: http://svn.apache.org/viewvc?rev=1173162&view=rev
Log:
Add a test of interleaving reads and writes.
* subversion/test/libsvn_subr/spillbuf-test.c:
(test_spillbuf_interleaving): interleave a series of writes and reads to
ensure the data comes out in the proper order and content.
(test_funcs): add new test
Modified:
subversion/trunk/subversion/tests/libsvn_subr/spillbuf-test.c
Modified: subversion/trunk/subversion/tests/libsvn_subr/spillbuf-test.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/libsvn_subr/spillbuf-test.c?rev=1173162&r1=1173161&r2=1173162&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/libsvn_subr/spillbuf-test.c (original)
+++ subversion/trunk/subversion/tests/libsvn_subr/spillbuf-test.c Tue Sep 20 14:14:57 2011
@@ -141,11 +141,67 @@ test_spillbuf_file(apr_pool_t *pool)
}
+static svn_error_t *
+test_spillbuf_interleaving(apr_pool_t *pool)
+{
+ svn_spillbuf_t *buf = svn_spillbuf_create(8 /* blocksize */,
+ 11 /* maxsize */,
+ pool);
+ const char *readptr;
+ apr_size_t readlen;
+
+ SVN_ERR(svn_spillbuf_write(buf, "abcdef", 6, pool));
+ SVN_ERR(svn_spillbuf_write(buf, "ghijkl", 6, pool));
+ /* now: two blocks of 6 bytes each */
+
+ SVN_ERR(svn_spillbuf_read(&readptr, &readlen, buf, pool));
+ SVN_TEST_ASSERT(readptr != NULL
+ && readlen == 6
+ && memcmp(readptr, "abcdef", 6) == 0);
+ /* now: one block of 6 bytes */
+
+ SVN_ERR(svn_spillbuf_write(buf, "mnopqr", 6, pool));
+ /* now: two blocks of 6 bytes each */
+
+ SVN_ERR(svn_spillbuf_read(&readptr, &readlen, buf, pool));
+ SVN_TEST_ASSERT(readptr != NULL
+ && readlen == 6
+ && memcmp(readptr, "ghijkl", 6) == 0);
+ /* now: one block of 6 bytes */
+
+ SVN_ERR(svn_spillbuf_write(buf, "stuvwx", 6, pool));
+ SVN_ERR(svn_spillbuf_write(buf, "ABCDEF", 6, pool));
+ SVN_ERR(svn_spillbuf_write(buf, "GHIJKL", 6, pool));
+ /* now: two blocks of 6 bytes each, and 12 bytes spilled to a file */
+
+ SVN_ERR(svn_spillbuf_read(&readptr, &readlen, buf, pool));
+ SVN_TEST_ASSERT(readptr != NULL
+ && readlen == 6
+ && memcmp(readptr, "mnopqr", 6) == 0);
+ SVN_ERR(svn_spillbuf_read(&readptr, &readlen, buf, pool));
+ SVN_TEST_ASSERT(readptr != NULL
+ && readlen == 6
+ && memcmp(readptr, "stuvwx", 6) == 0);
+ SVN_ERR(svn_spillbuf_read(&readptr, &readlen, buf, pool));
+ SVN_TEST_ASSERT(readptr != NULL
+ && readlen == 8
+ && memcmp(readptr, "ABCDEFGH", 8) == 0);
+ SVN_ERR(svn_spillbuf_read(&readptr, &readlen, buf, pool));
+ SVN_TEST_ASSERT(readptr != NULL
+ && readlen == 4
+ && memcmp(readptr, "IJKL", 4) == 0);
+
+ return SVN_NO_ERROR;
+}
+
+
/* The test table. */
struct svn_test_descriptor_t test_funcs[] =
{
SVN_TEST_NULL,
SVN_TEST_PASS2(test_spillbuf_basic, "basic spill buffer test"),
SVN_TEST_PASS2(test_spillbuf_file, "spill buffer file test"),
+ SVN_TEST_PASS2(test_spillbuf_interleaving,
+ "interleaving reads and writes"),
SVN_TEST_NULL
};