subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject svn commit: r1066445 - /subversion/trunk/subversion/tests/libsvn_subr/stream-test.c
Date Wed, 02 Feb 2011 12:37:15 GMT
Author: stsp
Date: Wed Feb  2 12:37:14 2011
New Revision: 1066445

URL: http://svn.apache.org/viewvc?rev=1066445&view=rev
Log:
Final fix for issue #3616 "Mark/seek in svn_subst_stream_translated() -
                           needs to restore translation state"

* subversion/tests/libsvn_subr/stream-test.c
  (test_stream_seek_translated): Fix test expectations.
   This test was making incorrect assumptions. 
   The correct keyword expansion for the test string is:
     "One$MyKeyword: my keyword was expanded $Two"
   This test was expecting something like the following instead:
     "Onemy keyword was expandedTwo"
   Also, this test was trying to use a mark set on the translated stream
   to seek within the underlying stream. But using marks set on one stream
   instance with another stream instance isn't valid.
  (test_funcs): Remove XFail marker for test_stream_seek_translated.

Modified:
    subversion/trunk/subversion/tests/libsvn_subr/stream-test.c

Modified: subversion/trunk/subversion/tests/libsvn_subr/stream-test.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/libsvn_subr/stream-test.c?rev=1066445&r1=1066444&r2=1066445&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/libsvn_subr/stream-test.c (original)
+++ subversion/trunk/subversion/tests/libsvn_subr/stream-test.c Wed Feb  2 12:37:14 2011
@@ -342,71 +342,72 @@ test_stream_seek_translated(apr_pool_t *
 {
   svn_stream_t *stream, *translated_stream;
   svn_stringbuf_t *stringbuf;
-  char buf[23];
+  char buf[44]; /* strlen("One$MyKeyword: my keyword was expanded $Two") + \0 */
   apr_size_t len;
-  svn_stream_mark_t *mark, *mark2;
+  svn_stream_mark_t *mark;
   apr_hash_t *keywords;
   svn_string_t *keyword_val;
 
   keywords = apr_hash_make(pool);
-  keyword_val = svn_string_create("my key word was expanded", pool);
+  keyword_val = svn_string_create("my keyword was expanded", pool);
   apr_hash_set(keywords, "MyKeyword", APR_HASH_KEY_STRING, keyword_val);
   stringbuf = svn_stringbuf_create("One$MyKeyword$Two", pool);
   stream = svn_stream_from_stringbuf(stringbuf, pool);
   translated_stream = svn_subst_stream_translated(stream, APR_EOL_STR,
                                                   FALSE, keywords, TRUE, pool);
-  len = 3;
-  SVN_ERR(svn_stream_read(translated_stream, buf, &len));
-  SVN_TEST_ASSERT(len == 3);
-  buf[3] = '\0';
-  SVN_TEST_STRING_ASSERT(buf, "One");
-
   /* Seek from outside of keyword to inside of keyword. */
+  len = 25;
+  SVN_ERR(svn_stream_read(translated_stream, buf, &len));
+  SVN_TEST_ASSERT(len == 25);
+  buf[25] = '\0';
+  SVN_TEST_STRING_ASSERT(buf, "One$MyKeyword: my keyword");
   SVN_ERR(svn_stream_mark(translated_stream, &mark, pool));
-  len = 3;
+  SVN_ERR(svn_stream_reset(translated_stream));
+  SVN_ERR(svn_stream_seek(translated_stream, mark));
+  len = 4;
   SVN_ERR(svn_stream_read(translated_stream, buf, &len));
-  SVN_TEST_ASSERT(len == 3);
-  buf[3] = '\0';
-  /* ### The test currently fails here because the keyword isn't
-   * ### expanded correctly. buf contains "$My\0" */
-  SVN_TEST_STRING_ASSERT(buf, "my ");
-  SVN_ERR(svn_stream_seek(stream, mark));
-  len = 3;
-  SVN_ERR(svn_stream_read(stream, buf, &len));
-  SVN_TEST_ASSERT(len == 3);
-  buf[3] = '\0';
-  SVN_TEST_STRING_ASSERT(buf, "my ");
+  SVN_TEST_ASSERT(len == 4);
+  buf[4] = '\0';
+  SVN_TEST_STRING_ASSERT(buf, " was");
 
   /* Seek from inside of keyword to inside of keyword. */
   SVN_ERR(svn_stream_mark(translated_stream, &mark, pool));
-  len = 3;
+  len = 9;
+  SVN_ERR(svn_stream_read(translated_stream, buf, &len));
+  SVN_TEST_ASSERT(len == 9);
+  buf[9] = '\0';
+  SVN_TEST_STRING_ASSERT(buf, " expanded");
+  SVN_ERR(svn_stream_seek(translated_stream, mark));
+  len = 9;
   SVN_ERR(svn_stream_read(translated_stream, buf, &len));
-  SVN_TEST_ASSERT(len == 3);
-  buf[3] = '\0';
-  SVN_TEST_STRING_ASSERT(buf, "key");
-  SVN_ERR(svn_stream_seek(stream, mark));
-  len = 3;
-  SVN_ERR(svn_stream_read(stream, buf, &len));
-  SVN_TEST_ASSERT(len == 3);
-  buf[3] = '\0';
-  SVN_TEST_STRING_ASSERT(buf, "my ");
+  SVN_TEST_ASSERT(len == 9);
+  buf[9] = '\0';
+  SVN_TEST_STRING_ASSERT(buf, " expanded");
 
   /* Seek from inside of keyword to outside of keyword. */
-  len = 22;
+  SVN_ERR(svn_stream_mark(translated_stream, &mark, pool));
+  len = 4;
+  SVN_ERR(svn_stream_read(translated_stream, buf, &len));
+  SVN_TEST_ASSERT(len == 4);
+  buf[4] = '\0';
+  SVN_TEST_STRING_ASSERT(buf, " $Tw");
+  SVN_ERR(svn_stream_seek(translated_stream, mark));
+  len = 4;
+  SVN_ERR(svn_stream_read(translated_stream, buf, &len));
+  SVN_TEST_ASSERT(len == 4);
+  buf[4] = '\0';
+  SVN_TEST_STRING_ASSERT(buf, " $Tw");
+
+  /* Seek from outside of keyword to outside of keyword. */
+  SVN_ERR(svn_stream_mark(translated_stream, &mark, pool));
+  len = 1;
   SVN_ERR(svn_stream_read(translated_stream, buf, &len));
-  SVN_TEST_ASSERT(len == 22);
-  buf[22] = '\0';
-  SVN_TEST_STRING_ASSERT(buf, "keyword was expandedTw");
-  SVN_ERR(svn_stream_mark(translated_stream, &mark2, pool));
-  SVN_ERR(svn_stream_seek(stream, mark));
-  len = 3;
-  SVN_ERR(svn_stream_read(stream, buf, &len));
-  SVN_TEST_ASSERT(len == 3);
-  buf[3] = '\0';
-  SVN_TEST_STRING_ASSERT(buf, "my ");
-  SVN_ERR(svn_stream_seek(stream, mark2));
+  SVN_TEST_ASSERT(len == 1);
+  buf[1] = '\0';
+  SVN_TEST_STRING_ASSERT(buf, "o");
+  SVN_ERR(svn_stream_seek(translated_stream, mark));
   len = 1;
-  SVN_ERR(svn_stream_read(stream, buf, &len));
+  SVN_ERR(svn_stream_read(translated_stream, buf, &len));
   SVN_TEST_ASSERT(len == 1);
   buf[1] = '\0';
   SVN_TEST_STRING_ASSERT(buf, "o");
@@ -433,7 +434,7 @@ struct svn_test_descriptor_t test_funcs[
                    "test stream seeking for files"),
     SVN_TEST_PASS2(test_stream_seek_stringbuf,
                    "test stream seeking for stringbufs"),
-    SVN_TEST_XFAIL2(test_stream_seek_translated,
-                    "test stream seeking for translated streams"),
+    SVN_TEST_PASS2(test_stream_seek_translated,
+                   "test stream seeking for translated streams"),
     SVN_TEST_NULL
   };



Mime
View raw message