@@ -732,3 +732,178 @@ fn iconv_UTF32BE_to_UTF16BE_conversion_with_c_flag() {
732732 Vec :: new ( ) ,
733733 ) ;
734734}
735+
736+ #[ test]
737+ fn iconv_UTF16LE_to_UTF16BE_conversion_with_c_flag ( ) {
738+ let cargo_manifest_dir = PathBuf :: from ( env:: var ( "CARGO_MANIFEST_DIR" ) . unwrap ( ) ) ;
739+
740+ let input_file = cargo_manifest_dir. join ( "tests/iconv/test_data_utf16le" ) ;
741+ let mut input: Vec < u8 > = Vec :: new ( ) ;
742+ File :: open ( & input_file)
743+ . unwrap ( )
744+ . read_to_end ( & mut input)
745+ . unwrap ( ) ;
746+
747+ let expected_output_file =
748+ cargo_manifest_dir. join ( "tests/iconv/test_data_utf16le_to_utf16be_without_c_flag" ) ;
749+
750+ let mut expected_output: Vec < u8 > = Vec :: new ( ) ;
751+ File :: open ( & expected_output_file)
752+ . unwrap ( )
753+ . read_to_end ( & mut expected_output)
754+ . unwrap ( ) ;
755+
756+ iconv_test (
757+ & [ "-f" , "UTF-16LE" , "-t" , "UTF-16BE" ] ,
758+ input. clone ( ) ,
759+ expected_output. clone ( ) ,
760+ Vec :: new ( ) ,
761+ ) ;
762+
763+ iconv_test (
764+ & [ "-f" , "UTF-16LE" , "-t" , "UTF-16BE" , "-" ] ,
765+ input,
766+ expected_output,
767+ Vec :: new ( ) ,
768+ ) ;
769+ }
770+
771+ #[ test]
772+ fn iconv_UTF16LE_to_ASCII_conversion_with_c_flag ( ) {
773+ let cargo_manifest_dir = PathBuf :: from ( env:: var ( "CARGO_MANIFEST_DIR" ) . unwrap ( ) ) ;
774+
775+ let input_file = cargo_manifest_dir. join ( "tests/iconv/test_data_utf16le" ) ;
776+ let mut input: Vec < u8 > = Vec :: new ( ) ;
777+ File :: open ( & input_file)
778+ . unwrap ( )
779+ . read_to_end ( & mut input)
780+ . unwrap ( ) ;
781+
782+ let expected_output_file =
783+ cargo_manifest_dir. join ( "tests/iconv/test_data_utf16le_to_ascii_with_c_flag" ) ;
784+
785+ let mut expected_output: Vec < u8 > = Vec :: new ( ) ;
786+ File :: open ( & expected_output_file)
787+ . unwrap ( )
788+ . read_to_end ( & mut expected_output)
789+ . unwrap ( ) ;
790+
791+ iconv_test (
792+ & [ "-c" , "-f" , "UTF-16LE" , "-t" , "ASCII" ] ,
793+ input. clone ( ) ,
794+ expected_output. clone ( ) ,
795+ Vec :: new ( ) ,
796+ ) ;
797+
798+ iconv_test (
799+ & [ "-c" , "-f" , "UTF-16LE" , "-t" , "ASCII" , "-" ] ,
800+ input,
801+ expected_output,
802+ Vec :: new ( ) ,
803+ ) ;
804+ }
805+
806+ #[ test]
807+ fn iconv_UTF16LE_to_UTF32BE_conversion_without_c_flag ( ) {
808+ let cargo_manifest_dir = PathBuf :: from ( env:: var ( "CARGO_MANIFEST_DIR" ) . unwrap ( ) ) ;
809+
810+ let input_file = cargo_manifest_dir. join ( "tests/iconv/test_data_utf16le" ) ;
811+ let mut input: Vec < u8 > = Vec :: new ( ) ;
812+ File :: open ( & input_file)
813+ . unwrap ( )
814+ . read_to_end ( & mut input)
815+ . unwrap ( ) ;
816+
817+ let expected_output_file =
818+ cargo_manifest_dir. join ( "tests/iconv/test_data_utf16le_to_utf32be_without_c_flag" ) ;
819+
820+ let mut expected_output: Vec < u8 > = Vec :: new ( ) ;
821+ File :: open ( & expected_output_file)
822+ . unwrap ( )
823+ . read_to_end ( & mut expected_output)
824+ . unwrap ( ) ;
825+
826+ iconv_test (
827+ & [ "-f" , "UTF-16LE" , "-t" , "UTF-32BE" ] ,
828+ input. clone ( ) ,
829+ expected_output. clone ( ) ,
830+ Vec :: new ( ) ,
831+ ) ;
832+
833+ iconv_test (
834+ & [ "-f" , "UTF-16LE" , "-t" , "UTF-32BE" , "-" ] ,
835+ input,
836+ expected_output,
837+ Vec :: new ( ) ,
838+ ) ;
839+ }
840+
841+ #[ test]
842+ fn iconv_UTF16LE_to_UTF32LE_conversion_without_c_flag ( ) {
843+ let cargo_manifest_dir = PathBuf :: from ( env:: var ( "CARGO_MANIFEST_DIR" ) . unwrap ( ) ) ;
844+
845+ let input_file = cargo_manifest_dir. join ( "tests/iconv/test_data_utf16le" ) ;
846+ let mut input: Vec < u8 > = Vec :: new ( ) ;
847+ File :: open ( & input_file)
848+ . unwrap ( )
849+ . read_to_end ( & mut input)
850+ . unwrap ( ) ;
851+
852+ let expected_output_file =
853+ cargo_manifest_dir. join ( "tests/iconv/test_data_utf16le_to_utf32le_without_c_flag" ) ;
854+
855+ let mut expected_output: Vec < u8 > = Vec :: new ( ) ;
856+ File :: open ( & expected_output_file)
857+ . unwrap ( )
858+ . read_to_end ( & mut expected_output)
859+ . unwrap ( ) ;
860+
861+ iconv_test (
862+ & [ "-f" , "UTF-16LE" , "-t" , "UTF-32LE" ] ,
863+ input. clone ( ) ,
864+ expected_output. clone ( ) ,
865+ Vec :: new ( ) ,
866+ ) ;
867+
868+ iconv_test (
869+ & [ "-f" , "UTF-16LE" , "-t" , "UTF-32LE" , "-" ] ,
870+ input,
871+ expected_output,
872+ Vec :: new ( ) ,
873+ ) ;
874+ }
875+
876+ #[ test]
877+ fn iconv_UTF16LE_to_UTF8_conversion_with_c_flag ( ) {
878+ let cargo_manifest_dir = PathBuf :: from ( env:: var ( "CARGO_MANIFEST_DIR" ) . unwrap ( ) ) ;
879+
880+ let input_file = cargo_manifest_dir. join ( "tests/iconv/test_data_utf16le" ) ;
881+ let mut input: Vec < u8 > = Vec :: new ( ) ;
882+ File :: open ( & input_file)
883+ . unwrap ( )
884+ . read_to_end ( & mut input)
885+ . unwrap ( ) ;
886+
887+ let expected_output_file =
888+ cargo_manifest_dir. join ( "tests/iconv/test_data_utf16le_to_utf8_without_c_flag" ) ;
889+
890+ let mut expected_output: Vec < u8 > = Vec :: new ( ) ;
891+ File :: open ( & expected_output_file)
892+ . unwrap ( )
893+ . read_to_end ( & mut expected_output)
894+ . unwrap ( ) ;
895+
896+ iconv_test (
897+ & [ "-f" , "UTF-16LE" , "-t" , "UTF-8" ] ,
898+ input. clone ( ) ,
899+ expected_output. clone ( ) ,
900+ Vec :: new ( ) ,
901+ ) ;
902+
903+ iconv_test (
904+ & [ "-f" , "UTF-16LE" , "-t" , "UTF-8" , "-" ] ,
905+ input,
906+ expected_output,
907+ Vec :: new ( ) ,
908+ ) ;
909+ }
0 commit comments