@@ -41,6 +41,13 @@ fn string_equality() {
4141 assert_ne ! ( string, different) ;
4242}
4343
44+ #[ itest]
45+ fn string_eq_str ( ) {
46+ let gstring = GString :: from ( "hello" ) ;
47+ assert_eq ! ( gstring, "hello" ) ;
48+ assert_ne ! ( gstring, "hallo" ) ;
49+ }
50+
4451#[ itest]
4552fn string_ordering ( ) {
4653 let low = GString :: from ( "Alpha" ) ;
@@ -130,12 +137,12 @@ fn string_with_null() {
130137#[ itest]
131138fn string_substr ( ) {
132139 let string = GString :: from ( "stable" ) ;
133- assert_eq ! ( string. substr( ..) , "stable" . into ( ) ) ;
134- assert_eq ! ( string. substr( 1 ..) , "table" . into ( ) ) ;
135- assert_eq ! ( string. substr( ..4 ) , "stab" . into ( ) ) ;
136- assert_eq ! ( string. substr( ..=3 ) , "stab" . into ( ) ) ;
137- assert_eq ! ( string. substr( 2 ..5 ) , "abl" . into ( ) ) ;
138- assert_eq ! ( string. substr( 2 ..=4 ) , "abl" . into ( ) ) ;
140+ assert_eq ! ( string. substr( ..) , "stable" ) ;
141+ assert_eq ! ( string. substr( 1 ..) , "table" ) ;
142+ assert_eq ! ( string. substr( ..4 ) , "stab" ) ;
143+ assert_eq ! ( string. substr( ..=3 ) , "stab" ) ;
144+ assert_eq ! ( string. substr( 2 ..5 ) , "abl" ) ;
145+ assert_eq ! ( string. substr( 2 ..=4 ) , "abl" ) ;
139146}
140147
141148#[ itest]
@@ -217,42 +224,42 @@ fn gstring_erase() {
217224 let s = GString :: from ( "Hello World" ) ;
218225 assert_eq ! ( s. erase( ..) , GString :: new( ) ) ;
219226 assert_eq ! ( s. erase( 4 ..4 ) , s) ;
220- assert_eq ! ( s. erase( 2 ..=2 ) , "Helo World" . into ( ) ) ;
221- assert_eq ! ( s. erase( 1 ..=3 ) , "Ho World" . into ( ) ) ;
222- assert_eq ! ( s. erase( 1 ..4 ) , "Ho World" . into ( ) ) ;
223- assert_eq ! ( s. erase( ..6 ) , "World" . into ( ) ) ;
224- assert_eq ! ( s. erase( 5 ..) , "Hello" . into ( ) ) ;
227+ assert_eq ! ( s. erase( 2 ..=2 ) , "Helo World" ) ;
228+ assert_eq ! ( s. erase( 1 ..=3 ) , "Ho World" ) ;
229+ assert_eq ! ( s. erase( 1 ..4 ) , "Ho World" ) ;
230+ assert_eq ! ( s. erase( ..6 ) , "World" ) ;
231+ assert_eq ! ( s. erase( 5 ..) , "Hello" ) ;
225232}
226233
227234#[ itest]
228235fn gstring_insert ( ) {
229236 let s = GString :: from ( "H World" ) ;
230- assert_eq ! ( s. insert( 1 , "i" ) , "Hi World" . into ( ) ) ;
231- assert_eq ! ( s. insert( 1 , "ello" ) , "Hello World" . into ( ) ) ;
232- assert_eq ! ( s. insert( 7 , "." ) , "H World." . into ( ) ) ;
233- assert_eq ! ( s. insert( 0 , "¿" ) , "¿H World" . into ( ) ) ;
237+ assert_eq ! ( s. insert( 1 , "i" ) , "Hi World" ) ;
238+ assert_eq ! ( s. insert( 1 , "ello" ) , "Hello World" ) ;
239+ assert_eq ! ( s. insert( 7 , "." ) , "H World." ) ;
240+ assert_eq ! ( s. insert( 0 , "¿" ) , "¿H World" ) ;
234241
235242 // Special behavior in Godot, but maybe the idea is to allow large constants to mean "end".
236- assert_eq ! ( s. insert( 123 , "!" ) , "H World!" . into ( ) ) ;
243+ assert_eq ! ( s. insert( 123 , "!" ) , "H World!" ) ;
237244}
238245
239246#[ itest]
240247fn gstring_pad ( ) {
241248 let s = GString :: from ( "123" ) ;
242- assert_eq ! ( s. lpad( 5 , '0' ) , "00123" . into ( ) ) ;
243- assert_eq ! ( s. lpad( 2 , ' ' ) , "123" . into ( ) ) ;
244- assert_eq ! ( s. lpad( 4 , ' ' ) , " 123" . into ( ) ) ;
249+ assert_eq ! ( s. lpad( 5 , '0' ) , "00123" ) ;
250+ assert_eq ! ( s. lpad( 2 , ' ' ) , "123" ) ;
251+ assert_eq ! ( s. lpad( 4 , ' ' ) , " 123" ) ;
245252
246- assert_eq ! ( s. rpad( 5 , '+' ) , "123++" . into ( ) ) ;
247- assert_eq ! ( s. rpad( 2 , ' ' ) , "123" . into ( ) ) ;
248- assert_eq ! ( s. rpad( 4 , ' ' ) , "123 " . into ( ) ) ;
253+ assert_eq ! ( s. rpad( 5 , '+' ) , "123++" ) ;
254+ assert_eq ! ( s. rpad( 2 , ' ' ) , "123" ) ;
255+ assert_eq ! ( s. rpad( 4 , ' ' ) , "123 " ) ;
249256
250257 let s = GString :: from ( "123.456" ) ;
251- assert_eq ! ( s. pad_decimals( 5 ) , "123.45600" . into ( ) ) ;
252- assert_eq ! ( s. pad_decimals( 2 ) , "123.45" . into ( ) ) ; // note: Godot rounds down
258+ assert_eq ! ( s. pad_decimals( 5 ) , "123.45600" ) ;
259+ assert_eq ! ( s. pad_decimals( 2 ) , "123.45" ) ; // note: Godot rounds down
253260
254- assert_eq ! ( s. pad_zeros( 5 ) , "00123.456" . into ( ) ) ;
255- assert_eq ! ( s. pad_zeros( 2 ) , "123.456" . into ( ) ) ;
261+ assert_eq ! ( s. pad_zeros( 5 ) , "00123.456" ) ;
262+ assert_eq ! ( s. pad_zeros( 2 ) , "123.456" ) ;
256263}
257264
258265// Byte and C-string conversions.
0 commit comments