@@ -17,6 +17,15 @@ fn test_string_compare() {
1717 with_str ( "teststring" , |t| assert_eq ! ( t, t) ) ; // mlua::String
1818 with_str ( "teststring" , |t| assert_eq ! ( t, Cow :: from( b"teststring" . as_ref( ) ) ) ) ; // Cow (borrowed)
1919 with_str ( "bla" , |t| assert_eq ! ( t, Cow :: from( b"bla" . to_vec( ) ) ) ) ; // Cow (owned)
20+
21+ // Test ordering
22+ with_str ( "a" , |a| {
23+ assert ! ( !( a < a) ) ;
24+ assert ! ( !( a > a) ) ;
25+ } ) ;
26+ with_str ( "a" , |a| assert ! ( a < "b" ) ) ;
27+ with_str ( "a" , |a| assert ! ( a < b"b" ) ) ;
28+ with_str ( "a" , |a| with_str ( "b" , |b| assert ! ( a < b) ) ) ;
2029}
2130
2231#[ test]
@@ -52,7 +61,7 @@ fn test_string_views() -> Result<()> {
5261}
5362
5463#[ test]
55- fn test_raw_string ( ) -> Result < ( ) > {
64+ fn test_string_from_bytes ( ) -> Result < ( ) > {
5665 let lua = Lua :: new ( ) ;
5766
5867 let rs = lua. create_string ( & [ 0 , 1 , 2 , 3 , 0 , 1 , 2 , 3 ] ) ?;
@@ -77,12 +86,14 @@ fn test_string_hash() -> Result<()> {
7786}
7887
7988#[ test]
80- fn test_string_debug ( ) -> Result < ( ) > {
89+ fn test_string_fmt_debug ( ) -> Result < ( ) > {
8190 let lua = Lua :: new ( ) ;
8291
8392 // Valid utf8
8493 let s = lua. create_string ( "hello" ) ?;
8594 assert_eq ! ( format!( "{s:?}" ) , r#""hello""# ) ;
95+ assert_eq ! ( format!( "{:?}" , s. to_str( ) ?) , r#""hello""# ) ;
96+ assert_eq ! ( format!( "{:?}" , s. as_bytes( ) ) , "[104, 101, 108, 108, 111]" ) ;
8697
8798 // Invalid utf8
8899 let s = lua. create_string ( b"hello\0 world\r \n \t \xF0 \x90 \x80 " ) ?;
0 commit comments