@@ -131,23 +131,8 @@ function test_utf8_rand_chr() {
131131
132132 $ out = unfc_utf8_rand_str ();
133133 $ this ->assertTrue ( ! isset ( $ out [ strspn ( $ out , $ ASCII ) ] ) );
134- }
135-
136- /**
137- * @ticket unfc_list_pluck
138- */
139- function test_list_pluck () {
140- $ obj1 = new stdclass ;
141- $ obj1 ->id = 1 ;
142- $ obj2 = new stdclass ;
143- $ obj2 ->id = 2 ;
144- $ obj3 = new stdclass ;
145- $ obj4 = new stdclass ;
146- $ obj4 ->id = 4 ;
147-
148- $ list = array ( $ obj1 , $ obj2 , $ obj3 , $ obj4 );
149- $ out = unfc_list_pluck ( $ list , 'id ' );
150- $ this ->assertSame ( array ( 0 => 1 , 1 => 2 , 3 => 4 ), $ out );
134+ $ out = unfc_utf8_rand_str ( 1000 , 0x10000 );
135+ $ this ->assertTrue ( unfc_is_valid_utf8 ( $ out ) );
151136 }
152137
153138 /**
@@ -171,4 +156,65 @@ function test_utf8_ranges() {
171156 $ this ->assertSame ( $ expected , $ actual );
172157 }
173158 }
159+
160+ /**
161+ * @ticket unfc_unicode_fmt
162+ */
163+ function test_unicode_fmt () {
164+ $ arr = array (
165+ /**/
166+ array ( 0 , '0x0 ' , '\x00 ' ),
167+ array ( 0xa , '0xa ' , '\x0a ' ),
168+ array ( 0x80 , '0x80 ' , '\x80 ' ),
169+ array ( 0xff , '0xff ' , '\xff ' ),
170+ array ( 0x800 , '0x800 ' , '\x{800} ' ),
171+ array ( 0x10000 , '0x10000 ' , '\x{10000} ' ),
172+ /**/
173+ );
174+
175+ foreach ( $ arr as $ item ) {
176+ list ( $ c , $ expected , $ expected_preg ) = $ item ;
177+ $ actual = unfc_unicode_fmt ( $ c );
178+ $ this ->assertSame ( $ expected , $ actual );
179+ $ actual_preg = unfc_unicode_preg_fmt ( $ c );
180+ $ this ->assertSame ( $ expected_preg , $ actual_preg );
181+ }
182+ }
183+
184+ /**
185+ * @ticket unfc_get_cb
186+ */
187+ function test_get_cb () {
188+ $ in = "\rasdfasdf \n\r" ;
189+ $ expected = "\rasdfasdf \n" ;
190+ $ out = unfc_get_cb ( $ in );
191+ $ this ->assertSame ( $ expected , $ out );
192+ }
193+
194+ /**
195+ * @ticket unfc_array_map_recursive
196+ */
197+ function test_array_map_recursive () {
198+ $ arr = array ( 'a ' => array ( 'b ' => array ( 'c ' => 'a ' , 'd ' => 'b ' ), 'e ' => 'c ' ), 'f ' => 'd ' , 'g ' => array ( 'h ' => 'e ' ) );
199+ $ expected = array ( 'a ' => array ( 'b ' => array ( 'c ' => 'A ' , 'd ' => 'B ' ), 'e ' => 'C ' ), 'f ' => 'D ' , 'g ' => array ( 'h ' => 'E ' ) );
200+ $ out = unfc_array_map_recursive ( 'strtoupper ' , $ arr );
201+ $ this ->assertSame ( $ expected , $ out );
202+ }
203+
204+ /**
205+ * @ticket unfc_list_pluck
206+ */
207+ function test_list_pluck () {
208+ $ obj1 = new stdclass ;
209+ $ obj1 ->id = 1 ;
210+ $ obj2 = new stdclass ;
211+ $ obj2 ->id = 2 ;
212+ $ obj3 = new stdclass ;
213+ $ obj4 = new stdclass ;
214+ $ obj4 ->id = 4 ;
215+
216+ $ list = array ( $ obj1 , $ obj2 , $ obj3 , $ obj4 );
217+ $ out = unfc_list_pluck ( $ list , 'id ' );
218+ $ this ->assertSame ( array ( 0 => 1 , 1 => 2 , 3 => 4 ), $ out );
219+ }
174220}
0 commit comments