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/21 16:24:37 UTC
svn commit: r1173667 -
/subversion/trunk/subversion/tests/libsvn_subr/spillbuf-test.c
Author: gstein
Date: Wed Sep 21 14:24:37 2011
New Revision: 1173667
URL: http://svn.apache.org/viewvc?rev=1173667&view=rev
Log:
Add a test for the new spillbuf reader.
* subversion/tests/libsvn_subr/spillbuf-test.c:
(test_spillbuf_reader): new test
(test_funcs): add the 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=1173667&r1=1173666&r2=1173667&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/libsvn_subr/spillbuf-test.c (original)
+++ subversion/trunk/subversion/tests/libsvn_subr/spillbuf-test.c Wed Sep 21 14:24:37 2011
@@ -241,6 +241,38 @@ test_spillbuf_interleaving(apr_pool_t *p
}
+static svn_error_t *
+test_spillbuf_reader(apr_pool_t *pool)
+{
+ svn_spillbuf_reader_t *sbr;
+ apr_size_t amt;
+ char buf[10];
+
+ sbr = svn_spillbuf_reader_create(4 /* blocksize */,
+ 100 /* maxsize */,
+ pool);
+
+ SVN_ERR(svn_spillbuf_reader_write(sbr, "abcdef", 6, pool));
+
+ /* Get a buffer from the underlying reader, and grab a couple bytes. */
+ SVN_ERR(svn_spillbuf_reader_read(&amt, sbr, buf, 2, pool));
+ SVN_TEST_ASSERT(amt == 2 && memcmp(buf, "ab", 2) == 0);
+
+ /* Trigger the internal "save" feature of the SBR. */
+ SVN_ERR(svn_spillbuf_reader_write(sbr, "ghijkl", 6, pool));
+
+ /* Read from the save buffer, and from the internal blocks. */
+ SVN_ERR(svn_spillbuf_reader_read(&amt, sbr, buf, 10, pool));
+ SVN_TEST_ASSERT(amt == 10 && memcmp(buf, "cdefghijkl", 10) == 0);
+
+ /* Should be done. */
+ SVN_ERR(svn_spillbuf_reader_read(&amt, sbr, buf, 10, pool));
+ SVN_TEST_ASSERT(amt == 0);
+
+ return SVN_NO_ERROR;
+}
+
+
/* The test table. */
struct svn_test_descriptor_t test_funcs[] =
{
@@ -250,5 +282,6 @@ struct svn_test_descriptor_t test_funcs[
SVN_TEST_PASS2(test_spillbuf_file, "spill buffer file test"),
SVN_TEST_PASS2(test_spillbuf_interleaving,
"interleaving reads and writes"),
+ SVN_TEST_PASS2(test_spillbuf_reader, "spill buffer reader test"),
SVN_TEST_NULL
};