@@ -71,6 +71,26 @@ object StringBufferTest extends JasmineTest {
71
71
shouldThrow[StringIndexOutOfBoundsException ](initBuf(" abcd" ).insert(- 1 , " whatever" ))
72
72
}
73
73
74
+ it(" should respond to `deleteCharAt`" ) {
75
+ expect(initBuf(" 0123" ).deleteCharAt(1 ).toString).toEqual(" 023" )
76
+ expect(initBuf(" 0123" ).deleteCharAt(0 ).toString).toEqual(" 123" )
77
+ expect(initBuf(" 0123" ).deleteCharAt(3 ).toString).toEqual(" 012" )
78
+ shouldThrow[StringIndexOutOfBoundsException ](initBuf(" 0123" ).deleteCharAt(- 1 ))
79
+ shouldThrow[StringIndexOutOfBoundsException ](initBuf(" 0123" ).deleteCharAt(4 ))
80
+ }
81
+
82
+ it(" should respond to `replace`" ) {
83
+ expect(initBuf(" 0123" ).replace(1 ,3 ," bc" ).toString).toEqual(" 0bc3" )
84
+ expect(initBuf(" 0123" ).replace(0 ,4 ," abcd" ).toString).toEqual(" abcd" )
85
+ expect(initBuf(" 0123" ).replace(0 ,10 ," abcd" ).toString).toEqual(" abcd" )
86
+ expect(initBuf(" 0123" ).replace(3 ,10 ," defg" ).toString).toEqual(" 012defg" )
87
+ expect(initBuf(" 0123" ).replace(0 ,1 ," xxxx" ).toString).toEqual(" xxxx123" )
88
+ expect(initBuf(" 0123" ).replace(1 ,1 ," xxxx" ).toString).toEqual(" 0xxxx123" )
89
+
90
+ shouldThrow[StringIndexOutOfBoundsException ](initBuf(" 0123" ).replace(- 1 ,3 ," x" ))
91
+ shouldThrow[StringIndexOutOfBoundsException ](initBuf(" 0123" ).replace(4 ,5 ," x" ))
92
+ }
93
+
74
94
it(" should respond to `setCharAt`" ) {
75
95
val buf = newBuf
76
96
buf.append(" foobar" )
@@ -151,6 +171,26 @@ object StringBufferTest extends JasmineTest {
151
171
expect(s " ${js.undefined}" ).toEqual(" undefined" )
152
172
}
153
173
174
+ it(" should respond to `deleteCharAt`" ) {
175
+ expect(initBuilder(" 0123" ).deleteCharAt(1 ).toString).toEqual(" 023" )
176
+ expect(initBuilder(" 0123" ).deleteCharAt(0 ).toString).toEqual(" 123" )
177
+ expect(initBuilder(" 0123" ).deleteCharAt(3 ).toString).toEqual(" 012" )
178
+ shouldThrow[StringIndexOutOfBoundsException ](initBuilder(" 0123" ).deleteCharAt(- 1 ))
179
+ shouldThrow[StringIndexOutOfBoundsException ](initBuilder(" 0123" ).deleteCharAt(4 ))
180
+ }
181
+
182
+ it(" should respond to `replace`" ) {
183
+ expect(initBuilder(" 0123" ).replace(1 ,3 ," bc" ).toString).toEqual(" 0bc3" )
184
+ expect(initBuilder(" 0123" ).replace(0 ,4 ," abcd" ).toString).toEqual(" abcd" )
185
+ expect(initBuilder(" 0123" ).replace(0 ,10 ," abcd" ).toString).toEqual(" abcd" )
186
+ expect(initBuilder(" 0123" ).replace(3 ,10 ," defg" ).toString).toEqual(" 012defg" )
187
+ expect(initBuilder(" 0123" ).replace(0 ,1 ," xxxx" ).toString).toEqual(" xxxx123" )
188
+ expect(initBuilder(" 0123" ).replace(1 ,1 ," xxxx" ).toString).toEqual(" 0xxxx123" )
189
+
190
+ shouldThrow[StringIndexOutOfBoundsException ](initBuilder(" 0123" ).replace(- 1 ,3 ," x" ))
191
+ shouldThrow[StringIndexOutOfBoundsException ](initBuilder(" 0123" ).replace(4 ,5 ," x" ))
192
+ }
193
+
154
194
it(" should respond to `setCharAt`" ) {
155
195
val b = newBuilder
156
196
b.append(" foobar" )
0 commit comments