[svn:parrot] r49189 - trunk/t/pmc
NotFound at svn.parrot.org
NotFound at svn.parrot.org
Mon Sep 20 22:45:01 UTC 2010
Author: NotFound
Date: Mon Sep 20 22:45:00 2010
New Revision: 49189
URL: https://trac.parrot.org/parrot/changeset/49189
Log:
add a StringBuilder test for code coverage completeness
Modified:
trunk/t/pmc/stringbuilder.t
Modified: trunk/t/pmc/stringbuilder.t
==============================================================================
--- trunk/t/pmc/stringbuilder.t Mon Sep 20 21:56:06 2010 (r49188)
+++ trunk/t/pmc/stringbuilder.t Mon Sep 20 22:45:00 2010 (r49189)
@@ -23,6 +23,7 @@
test_create() # 3 tests
test_init_pmc()
test_push_string()
+ test_push_string_resize()
test_push_pmc() # 4 tests
test_push_string_unicode() # 1 test
test_i_concatenate() # 1 test
@@ -109,6 +110,29 @@
is( $S0, $S1, "push a null string does nothing" )
.end
+.sub 'test_push_string_resize'
+ # Try to cover the case of resizing a buffer while converting it to utf8
+ # Depends on internal details of StringBuffer, so it may need changes
+ # when that internals do.
+ .local pmc sb
+ sb = new ["StringBuilder"]
+ .local string s
+ .local int i, n
+ # Get the allocated capacity and almost fill it
+ n = sb
+ n -= 2
+ s = repeat iso-8859-1:"x", n
+ push sb, s
+ # push a string that needs reallocation and has incompatible encoding rep.
+ s = unicode:"yyyy"
+ push sb, s
+ # Check the expected string length. Not a rock solid check, but the
+ # purpose of this test is just code coverage, so is enough.
+ i = sb.'get_string_length'()
+ n = n + 4
+ is(i, n, 'test_push_string_resize')
+.end
+
.sub 'test_push_pmc'
.local pmc sb
sb = new ["StringBuilder"]
More information about the parrot-commits
mailing list