@@ -182,6 +182,15 @@ struct fluid_parse_test fluid_parse_tests [] = {
182182 { 65535 , "0.0.0.ffff" },
183183 { 4294967295 , "0000.0000.ffff.ffff" },
184184 { 18446744073709551615UL , "ffff.ffff.ffff.ffff" },
185+ { 0 , "😃" },
186+ { 1 , "😄" },
187+ { 57 , "🙊" },
188+ { 1234 , "😁👌" },
189+ { 1888 , "😆🐻" },
190+ { 4369 , "😊🌀" },
191+ { 65535 , "💁📚" },
192+ { 4294967295 , "😳🏪🍖🍸" },
193+ { 18446744073709551615UL , "🚹💗💧👗😷📷📚" },
185194 { 0 , NULL },
186195};
187196
@@ -245,6 +254,12 @@ void test_basic (void)
245254 "fluid_decode type=MNEMONIC works" );
246255 diag ("%s" , buf );
247256
257+ ok (fluid_encode (buf , sizeof (buf ), id , FLUID_STRING_EMOJI ) == 0 ,
258+ "fluid_encode type=EMOJI works" );
259+ ok (fluid_decode (buf , & id2 , FLUID_STRING_EMOJI ) == 0 && id == id2 ,
260+ "fluid_decode type=EMOJI works" );
261+ diag ("%s" , buf );
262+
248263 /* With artificially tweaked generator state
249264 */
250265 const uint64_t time_34y = 1000ULL * 60 * 60 * 24 * 365 * 34 ;
@@ -266,6 +281,13 @@ void test_basic (void)
266281 "fluid_decode type=MNEMONIC works" );
267282 diag ("%s" , buf );
268283
284+ ok (fluid_encode (buf , sizeof (buf ), id , FLUID_STRING_EMOJI ) == 0 ,
285+ "fluid_encode type=EMOJI works" );
286+ ok (fluid_decode (buf , & id2 , FLUID_STRING_EMOJI ) == 0 && id == id2 ,
287+ "fluid_decode type=EMOJI works" );
288+ diag ("%s" , buf );
289+
290+
269291 /* Generate 64K id's as rapidly as possible.
270292 * Probably will cover running out of seq bits.
271293 */
@@ -307,6 +329,27 @@ void test_basic (void)
307329 ok (decode_errors == 0 ,
308330 "fluid_decode type=MNEMONIC worked 4K times" );
309331
332+ /* Continue for another 4K with EMOJI encoding (slower).
333+ */
334+ generate_errors = 0 ;
335+ encode_errors = 0 ;
336+ decode_errors = 0 ;
337+ for (i = 0 ; i < 4096 ; i ++ ) {
338+ if (fluid_generate (& gen , & id ) < 0 )
339+ generate_errors ++ ;
340+ if (fluid_encode (buf , sizeof (buf ), id , FLUID_STRING_EMOJI ) < 0 )
341+ encode_errors ++ ;
342+ if (fluid_decode (buf , & id2 , FLUID_STRING_EMOJI ) < 0 || id != id2 )
343+ decode_errors ++ ;
344+ }
345+ ok (generate_errors == 0 ,
346+ "fluid_generate worked 4K times" );
347+ ok (encode_errors == 0 ,
348+ "fluid_encode type=EMOJI worked 4K times" );
349+ ok (decode_errors == 0 ,
350+ "fluid_decode type=EMOJI worked 4K times" );
351+
352+
310353 /* Generate 64K FLUIDs, restarting generator each time from timestamp
311354 * extracted from generated FLUID + 1. Verify number always increases.
312355 */
@@ -339,6 +382,8 @@ void test_basic (void)
339382 "fluid_decode type=MNEMONIC fails on input=bogus" );
340383 ok (fluid_decode ("a-a-a--a-a-a" , & id , FLUID_STRING_MNEMONIC ) < 0 ,
341384 "fluid_decode type=MNEMONIC fails on unknown words xx-xx-xx--xx-xx-xx" );
385+ ok (fluid_decode ("bogus" , & id , FLUID_STRING_EMOJI ) < 0 ,
386+ "fluid_decode type=EMOJI fails on ascii string" );
342387}
343388
344389int main (int argc , char * argv [])
0 commit comments