Esempio n. 1
0
 def test_shrinking(self):
     sb = StringBuilderRepr.ll_new(100)
     StringBuilderRepr.ll_append(sb, llstr("abc" * 11))
     assert StringBuilderRepr.ll_getlength(sb) == 33
     s = StringBuilderRepr.ll_build(sb)
     assert hlstr(s) == "abc" * 11
     assert StringBuilderRepr.ll_getlength(sb) == 33
Esempio n. 2
0
 def test_nooveralloc(self):
     sb = StringBuilderRepr.ll_new(33)
     StringBuilderRepr.ll_append(sb, llstr("abc" * 11))
     assert StringBuilderRepr.ll_getlength(sb) == 33
     s = StringBuilderRepr.ll_build(sb)
     assert hlstr(s) == "abc" * 11
     assert StringBuilderRepr.ll_getlength(sb) == 33
Esempio n. 3
0
 def test_shrinking(self):
     sb = StringBuilderRepr.ll_new(100)
     StringBuilderRepr.ll_append(sb, llstr("abc" * 11))
     assert StringBuilderRepr.ll_getlength(sb) == 33
     s = StringBuilderRepr.ll_build(sb)
     assert hlstr(s) == "abc" * 11
     assert StringBuilderRepr.ll_getlength(sb) == 33
Esempio n. 4
0
 def test_nooveralloc(self):
     sb = StringBuilderRepr.ll_new(33)
     StringBuilderRepr.ll_append(sb, llstr("abc" * 11))
     assert StringBuilderRepr.ll_getlength(sb) == 33
     s = StringBuilderRepr.ll_build(sb)
     assert hlstr(s) == "abc" * 11
     assert StringBuilderRepr.ll_getlength(sb) == 33
Esempio n. 5
0
 def test_simple(self):
     sb = StringBuilderRepr.ll_new(3)
     assert StringBuilderRepr.ll_getlength(sb) == 0
     StringBuilderRepr.ll_append_char(sb, 'x')
     assert StringBuilderRepr.ll_getlength(sb) == 1
     StringBuilderRepr.ll_append(sb, llstr("abc"))
     assert StringBuilderRepr.ll_getlength(sb) == 4
     StringBuilderRepr.ll_append_slice(sb, llstr("foobar"), 2, 5)
     assert StringBuilderRepr.ll_getlength(sb) == 7
     StringBuilderRepr.ll_append_multiple_char(sb, 'y', 3)
     assert StringBuilderRepr.ll_getlength(sb) == 10
     s = StringBuilderRepr.ll_build(sb)
     assert hlstr(s) == "xabcobayyy"
     assert StringBuilderRepr.ll_getlength(sb) == 10
Esempio n. 6
0
 def test_simple(self):
     sb = StringBuilderRepr.ll_new(3)
     assert StringBuilderRepr.ll_getlength(sb) == 0
     StringBuilderRepr.ll_append_char(sb, 'x')
     assert StringBuilderRepr.ll_getlength(sb) == 1
     StringBuilderRepr.ll_append(sb, llstr("abc"))
     assert StringBuilderRepr.ll_getlength(sb) == 4
     StringBuilderRepr.ll_append_slice(sb, llstr("foobar"), 2, 5)
     assert StringBuilderRepr.ll_getlength(sb) == 7
     StringBuilderRepr.ll_append_multiple_char(sb, 'y', 3)
     assert StringBuilderRepr.ll_getlength(sb) == 10
     s = StringBuilderRepr.ll_build(sb)
     assert hlstr(s) == "xabcobayyy"
     assert StringBuilderRepr.ll_getlength(sb) == 10