@@ -732,6 +732,22 @@ mod tests {
732732 use super :: * ;
733733 use crate :: test_util:: { get_font_funcs, test_faces} ;
734734
735+ #[ test]
736+ fn test_tag ( ) {
737+ let raw = u32:: from_be_bytes ( [ b't' , b'e' , b's' , b't' ] ) ;
738+
739+ assert_eq ! ( Tag :: new( raw) . to_raw( ) , raw) ;
740+ assert_eq ! ( Tag :: from_str( "test" ) , Tag :: new( raw) ) ;
741+ assert_eq ! ( Tag :: from_cstr( c"test" ) , Tag :: new( raw) ) ;
742+ }
743+
744+ #[ test]
745+ fn test_language ( ) {
746+ assert_eq ! ( Language :: from_string( "en-US" ) . to_string( ) , Some ( c"en-us" ) ) ;
747+ assert_eq ! ( Language :: from_cstr( c"en-gb" ) . to_string( ) , Some ( c"en-gb" ) ) ;
748+ assert ! ( Language :: default ( ) . to_string( ) . is_none( ) ) ;
749+ }
750+
735751 #[ test]
736752 fn test_face_ot_math_data ( ) {
737753 for ( _, face) in test_faces ( ) {
@@ -775,40 +791,55 @@ mod tests {
775791 . add_utf16 ( & "Hello World!" . encode_utf16 ( ) . collect :: < Vec < _ > > ( ) ) ;
776792 buffer. as_mut ( ) . guess_segment_properties ( ) ;
777793
778- let mut plan = ShapePlan :: new (
794+ let plan1 = ShapePlan :: new (
779795 face. as_ref ( ) ,
780796 & buffer. as_ref ( ) . get_segment_properties ( ) ,
781797 & [ ] ,
782798 None ,
783799 ) ;
784- assert_eq ! ( plan. as_ref( ) . get_shaper( ) , Some ( c"ot" ) ) ;
785-
786- assert ! ( plan. as_mut( ) . execute( font. as_ref( ) , buffer. as_mut( ) , & [ ] ) ) ;
787-
788- assert_eq ! (
789- buffer. as_ref( ) . get_script( ) . get_horizontal_direction( ) ,
790- Direction :: Ltr
800+ let plan2 = ShapePlan :: new_cached (
801+ face. as_ref ( ) ,
802+ & buffer. as_ref ( ) . get_segment_properties ( ) ,
803+ & [ ] ,
804+ None ,
791805 ) ;
792806
793- let glyph_info = buffer. as_ref ( ) . glyph_info ( ) . unwrap ( ) ;
794- assert_eq ! ( glyph_info. len( ) , 12 ) ;
795- assert_eq ! ( glyph_info[ 0 ] . cluster, 0 ) ;
796- assert_eq ! ( glyph_info[ 0 ] . codepoint, 62 ) ;
797-
798- assert_eq ! ( glyph_info[ 1 ] . cluster, 1 ) ;
799- assert_eq ! ( glyph_info[ 1 ] . codepoint, 50 ) ;
800-
801- let glyph_pos = buffer. as_ref ( ) . glyph_positions ( ) . unwrap ( ) ;
802- assert_eq ! ( glyph_pos. len( ) , 12 ) ;
803- assert_eq ! ( glyph_pos[ 0 ] . x_advance, 734 ) ;
804- assert_eq ! ( glyph_pos[ 0 ] . y_advance, 0 ) ;
805- assert_eq ! ( glyph_pos[ 0 ] . x_offset, 0 ) ;
806- assert_eq ! ( glyph_pos[ 0 ] . y_offset, 0 ) ;
807-
808- assert_eq ! ( glyph_pos[ 1 ] . x_advance, 435 ) ;
809- assert_eq ! ( glyph_pos[ 1 ] . y_advance, 0 ) ;
810- assert_eq ! ( glyph_pos[ 1 ] . x_offset, 0 ) ;
811- assert_eq ! ( glyph_pos[ 1 ] . y_offset, 0 ) ;
807+ for mut plan in [ plan1, plan2] {
808+ assert_eq ! ( plan. as_ref( ) . get_shaper( ) , Some ( c"ot" ) ) ;
809+
810+ assert ! ( plan. as_mut( ) . execute( font. as_ref( ) , buffer. as_mut( ) , & [ ] ) ) ;
811+
812+ assert_eq ! (
813+ buffer. as_ref( ) . get_script( ) . get_horizontal_direction( ) ,
814+ Direction :: Ltr
815+ ) ;
816+
817+ let glyph_info = buffer. as_ref ( ) . glyph_info ( ) . unwrap ( ) ;
818+ assert_eq ! ( glyph_info. len( ) , 12 ) ;
819+ assert_eq ! ( glyph_info[ 0 ] . cluster, 0 ) ;
820+ assert_eq ! ( glyph_info[ 0 ] . codepoint, 62 ) ;
821+
822+ assert_eq ! ( glyph_info[ 1 ] . cluster, 1 ) ;
823+ assert_eq ! ( glyph_info[ 1 ] . codepoint, 50 ) ;
824+
825+ let glyph_pos = buffer. as_ref ( ) . glyph_positions ( ) . unwrap ( ) ;
826+ assert_eq ! ( glyph_pos. len( ) , 12 ) ;
827+ assert_eq ! ( glyph_pos[ 0 ] . x_advance, 734 ) ;
828+ assert_eq ! ( glyph_pos[ 0 ] . y_advance, 0 ) ;
829+ assert_eq ! ( glyph_pos[ 0 ] . x_offset, 0 ) ;
830+ assert_eq ! ( glyph_pos[ 0 ] . y_offset, 0 ) ;
831+
832+ assert_eq ! ( glyph_pos[ 1 ] . x_advance, 435 ) ;
833+ assert_eq ! ( glyph_pos[ 1 ] . y_advance, 0 ) ;
834+ assert_eq ! ( glyph_pos[ 1 ] . x_offset, 0 ) ;
835+ assert_eq ! ( glyph_pos[ 1 ] . y_offset, 0 ) ;
836+
837+ buffer. as_mut ( ) . reset ( ) ;
838+ buffer
839+ . as_mut ( )
840+ . add_utf16 ( & "Hello World!" . encode_utf16 ( ) . collect :: < Vec < _ > > ( ) ) ;
841+ buffer. as_mut ( ) . guess_segment_properties ( ) ;
842+ }
812843 }
813844 }
814845}
0 commit comments