77// SPDX-License-Identifier: MIT
88//
99
10+ #![ allow( non_snake_case) ]
1011use plib:: { run_test_u8, TestPlanU8 } ;
1112use std:: env;
1213use std:: path:: PathBuf ;
@@ -31,7 +32,7 @@ fn iconv_no_flag_data_input() {
3132}
3233
3334#[ test]
34- fn iconv_utf8_to_ascii_conversion_with_c_flag ( ) {
35+ fn iconv_UTF8_to_ASCII_conversion_with_c_flag ( ) {
3536 let cargo_manifest_dir = PathBuf :: from ( env:: var ( "CARGO_MANIFEST_DIR" ) . unwrap ( ) ) ;
3637
3738 let input_file = cargo_manifest_dir. join ( "tests/iconv/test_data_utf8" ) ;
@@ -64,3 +65,146 @@ fn iconv_utf8_to_ascii_conversion_with_c_flag() {
6465 Vec :: new ( ) ,
6566 ) ;
6667}
68+
69+ #[ test]
70+ fn iconv_UTF8_to_UTF16LE_conversion_without_c_flag ( ) {
71+ let cargo_manifest_dir = PathBuf :: from ( env:: var ( "CARGO_MANIFEST_DIR" ) . unwrap ( ) ) ;
72+
73+ let input_file = cargo_manifest_dir. join ( "tests/iconv/test_data_utf8" ) ;
74+ let mut input: Vec < u8 > = Vec :: new ( ) ;
75+ File :: open ( & input_file)
76+ . unwrap ( )
77+ . read_to_end ( & mut input)
78+ . unwrap ( ) ;
79+
80+ let expected_output_file =
81+ cargo_manifest_dir. join ( "tests/iconv/test_data_utf8_to_utf16le_without_c_flag" ) ;
82+
83+ let mut expected_output: Vec < u8 > = Vec :: new ( ) ;
84+ File :: open ( & expected_output_file)
85+ . unwrap ( )
86+ . read_to_end ( & mut expected_output)
87+ . unwrap ( ) ;
88+
89+ iconv_test (
90+ & [ "-f" , "UTF-8" , "-t" , "UTF-16LE" , "-" ] ,
91+ input. clone ( ) ,
92+ expected_output. clone ( ) ,
93+ Vec :: new ( ) ,
94+ ) ;
95+
96+ iconv_test (
97+ & [ "-f" , "UTF-8" , "-t" , "UTF-16LE" ] ,
98+ input,
99+ expected_output,
100+ Vec :: new ( ) ,
101+ ) ;
102+ }
103+
104+ #[ test]
105+ #[ allow( non_snake_case) ]
106+ fn iconv_UTF8_to_UTF16BE_conversion_without_c_flag ( ) {
107+ let cargo_manifest_dir = PathBuf :: from ( env:: var ( "CARGO_MANIFEST_DIR" ) . unwrap ( ) ) ;
108+
109+ let input_file = cargo_manifest_dir. join ( "tests/iconv/test_data_utf8" ) ;
110+ let mut input: Vec < u8 > = Vec :: new ( ) ;
111+ File :: open ( & input_file)
112+ . unwrap ( )
113+ . read_to_end ( & mut input)
114+ . unwrap ( ) ;
115+
116+ let expected_output_file =
117+ cargo_manifest_dir. join ( "tests/iconv/test_data_utf8_to_utf16be_without_c_flag" ) ;
118+
119+ let mut expected_output: Vec < u8 > = Vec :: new ( ) ;
120+ File :: open ( & expected_output_file)
121+ . unwrap ( )
122+ . read_to_end ( & mut expected_output)
123+ . unwrap ( ) ;
124+
125+ iconv_test (
126+ & [ "-f" , "UTF-8" , "-t" , "UTF-16BE" , "-" ] ,
127+ input. clone ( ) ,
128+ expected_output. clone ( ) ,
129+ Vec :: new ( ) ,
130+ ) ;
131+
132+ iconv_test (
133+ & [ "-f" , "UTF-8" , "-t" , "UTF-16BE" ] ,
134+ input,
135+ expected_output,
136+ Vec :: new ( ) ,
137+ ) ;
138+ }
139+
140+ #[ test]
141+ #[ allow( non_snake_case) ]
142+ fn iconv_UTF8_to_UTF32BE_conversion_without_c_flag ( ) {
143+ let cargo_manifest_dir = PathBuf :: from ( env:: var ( "CARGO_MANIFEST_DIR" ) . unwrap ( ) ) ;
144+
145+ let input_file = cargo_manifest_dir. join ( "tests/iconv/test_data_utf8" ) ;
146+ let mut input: Vec < u8 > = Vec :: new ( ) ;
147+ File :: open ( & input_file)
148+ . unwrap ( )
149+ . read_to_end ( & mut input)
150+ . unwrap ( ) ;
151+
152+ let expected_output_file =
153+ cargo_manifest_dir. join ( "tests/iconv/test_data_utf8_to_utf32be_without_c_flag" ) ;
154+
155+ let mut expected_output: Vec < u8 > = Vec :: new ( ) ;
156+ File :: open ( & expected_output_file)
157+ . unwrap ( )
158+ . read_to_end ( & mut expected_output)
159+ . unwrap ( ) ;
160+
161+ iconv_test (
162+ & [ "-f" , "UTF-8" , "-t" , "UTF-32BE" , "-" ] ,
163+ input. clone ( ) ,
164+ expected_output. clone ( ) ,
165+ Vec :: new ( ) ,
166+ ) ;
167+
168+ iconv_test (
169+ & [ "-f" , "UTF-8" , "-t" , "UTF-32BE" ] ,
170+ input,
171+ expected_output,
172+ Vec :: new ( ) ,
173+ ) ;
174+ }
175+
176+ #[ test]
177+ #[ allow( non_snake_case) ]
178+ fn iconv_UTF8_to_UTF32LE_conversion_without_c_flag ( ) {
179+ let cargo_manifest_dir = PathBuf :: from ( env:: var ( "CARGO_MANIFEST_DIR" ) . unwrap ( ) ) ;
180+
181+ let input_file = cargo_manifest_dir. join ( "tests/iconv/test_data_utf8" ) ;
182+ let mut input: Vec < u8 > = Vec :: new ( ) ;
183+ File :: open ( & input_file)
184+ . unwrap ( )
185+ . read_to_end ( & mut input)
186+ . unwrap ( ) ;
187+
188+ let expected_output_file =
189+ cargo_manifest_dir. join ( "tests/iconv/test_data_utf8_to_utf32le_without_c_flag" ) ;
190+
191+ let mut expected_output: Vec < u8 > = Vec :: new ( ) ;
192+ File :: open ( & expected_output_file)
193+ . unwrap ( )
194+ . read_to_end ( & mut expected_output)
195+ . unwrap ( ) ;
196+
197+ iconv_test (
198+ & [ "-f" , "UTF-8" , "-t" , "UTF-32LE" , "-" ] ,
199+ input. clone ( ) ,
200+ expected_output. clone ( ) ,
201+ Vec :: new ( ) ,
202+ ) ;
203+
204+ iconv_test (
205+ & [ "-f" , "UTF-8" , "-t" , "UTF-32LE" ] ,
206+ input,
207+ expected_output,
208+ Vec :: new ( ) ,
209+ ) ;
210+ }
0 commit comments