@@ -334,119 +334,3 @@ impl BaseCodec for Base64UrlPad {
334
334
Ok ( encoding:: BASE64URL_PAD . decode ( input. as_ref ( ) . as_bytes ( ) ) ?)
335
335
}
336
336
}
337
-
338
- #[ cfg( test) ]
339
- mod tests {
340
- use super :: * ;
341
-
342
- #[ test]
343
- fn test_identity ( ) {
344
- assert_eq ! ( Identity :: encode( b"foo" ) , "foo" ) ;
345
- assert_eq ! ( Identity :: decode( "foo" ) . unwrap( ) , b"foo" . to_vec( ) ) ;
346
- }
347
-
348
- #[ test]
349
- fn test_base2 ( ) {
350
- assert_eq ! ( Base2 :: encode( b"foo" ) , "011001100110111101101111" ) ;
351
- assert_eq ! (
352
- Base2 :: decode( "011001100110111101101111" ) . unwrap( ) ,
353
- b"foo" . to_vec( )
354
- ) ;
355
- }
356
-
357
- #[ test]
358
- fn test_base8 ( ) {
359
- assert_eq ! ( Base8 :: encode( b"foo" ) , "31467557" ) ;
360
- assert_eq ! ( Base8 :: decode( "31467557" ) . unwrap( ) , b"foo" . to_vec( ) ) ;
361
- }
362
-
363
- #[ test]
364
- fn test_base10 ( ) {
365
- assert_eq ! ( Base10 :: encode( b"foo" ) , "6713199" ) ;
366
- assert_eq ! ( Base10 :: decode( "6713199" ) . unwrap( ) , b"foo" . to_vec( ) ) ;
367
- }
368
-
369
- #[ test]
370
- fn test_base16 ( ) {
371
- assert_eq ! ( Base16Lower :: encode( b"foo" ) , "666f6f" ) ;
372
- assert_eq ! ( Base16Lower :: decode( "666f6f" ) . unwrap( ) , b"foo" . to_vec( ) ) ;
373
-
374
- assert_eq ! ( Base16Upper :: encode( b"foo" ) , "666F6F" ) ;
375
- assert_eq ! ( Base16Upper :: decode( "666F6F" ) . unwrap( ) , b"foo" . to_vec( ) ) ;
376
- }
377
-
378
- #[ test]
379
- fn test_base32 ( ) {
380
- assert_eq ! ( Base32Lower :: encode( b"foo" ) , "mzxw6" ) ;
381
- assert_eq ! ( Base32Lower :: decode( "mzxw6" ) . unwrap( ) , b"foo" . to_vec( ) ) ;
382
-
383
- assert_eq ! ( Base32Upper :: encode( b"foo" ) , "MZXW6" ) ;
384
- assert_eq ! ( Base32Upper :: decode( "MZXW6" ) . unwrap( ) , b"foo" . to_vec( ) ) ;
385
-
386
- assert_eq ! ( Base32HexLower :: encode( b"foo" ) , "cpnmu" ) ;
387
- assert_eq ! ( Base32HexLower :: decode( "cpnmu" ) . unwrap( ) , b"foo" . to_vec( ) ) ;
388
-
389
- assert_eq ! ( Base32HexUpper :: encode( b"foo" ) , "CPNMU" ) ;
390
- assert_eq ! ( Base32HexUpper :: decode( "CPNMU" ) . unwrap( ) , b"foo" . to_vec( ) ) ;
391
- }
392
-
393
- #[ test]
394
- fn test_base32_padding ( ) {
395
- assert_eq ! ( Base32PadLower :: encode( b"foo" ) , "mzxw6===" ) ;
396
- assert_eq ! ( Base32PadLower :: decode( "mzxw6===" ) . unwrap( ) , b"foo" . to_vec( ) ) ;
397
-
398
- assert_eq ! ( Base32PadUpper :: encode( b"foo" ) , "MZXW6===" ) ;
399
- assert_eq ! ( Base32PadUpper :: decode( "MZXW6===" ) . unwrap( ) , b"foo" . to_vec( ) ) ;
400
-
401
- assert_eq ! ( Base32HexPadLower :: encode( b"foo" ) , "cpnmu===" ) ;
402
- assert_eq ! (
403
- Base32HexPadLower :: decode( "cpnmu===" ) . unwrap( ) ,
404
- b"foo" . to_vec( )
405
- ) ;
406
-
407
- assert_eq ! ( Base32HexPadUpper :: encode( b"foo" ) , "CPNMU===" ) ;
408
- assert_eq ! (
409
- Base32HexPadUpper :: decode( "CPNMU===" ) . unwrap( ) ,
410
- b"foo" . to_vec( )
411
- ) ;
412
- }
413
-
414
- #[ test]
415
- fn test_base32z ( ) {
416
- assert_eq ! ( Base32Z :: encode( b"foo" ) , "c3zs6" ) ;
417
- assert_eq ! ( Base32Z :: decode( "c3zs6" ) . unwrap( ) , b"foo" . to_vec( ) ) ;
418
- }
419
-
420
- #[ test]
421
- fn test_base58 ( ) {
422
- assert_eq ! ( Base58Flickr :: encode( b"foo" ) , "ApAP" ) ;
423
- assert_eq ! ( Base58Flickr :: decode( "ApAP" ) . unwrap( ) , b"foo" . to_vec( ) ) ;
424
-
425
- assert_eq ! ( Base58Btc :: encode( b"foo" ) , "bQbp" ) ;
426
- assert_eq ! ( Base58Btc :: decode( "bQbp" ) . unwrap( ) , b"foo" . to_vec( ) ) ;
427
- }
428
-
429
- #[ test]
430
- fn test_base64 ( ) {
431
- assert_eq ! ( Base64 :: encode( b"foo" ) , "Zm9v" ) ;
432
- assert_eq ! ( Base64 :: decode( "Zm9v" ) . unwrap( ) , b"foo" . to_vec( ) ) ;
433
-
434
- assert_eq ! ( Base64Url :: encode( b"foo" ) , "Zm9v" ) ;
435
- assert_eq ! ( Base64Url :: decode( "Zm9v" ) . unwrap( ) , b"foo" . to_vec( ) ) ;
436
- }
437
-
438
- #[ test]
439
- fn test_base64_padding ( ) {
440
- assert_eq ! ( Base64Pad :: encode( b"foopadding" ) , "Zm9vcGFkZGluZw==" ) ;
441
- assert_eq ! (
442
- Base64Pad :: decode( "Zm9vcGFkZGluZw==" ) . unwrap( ) ,
443
- b"foopadding" . to_vec( )
444
- ) ;
445
-
446
- assert_eq ! ( Base64UrlPad :: encode( b"foopadding" ) , "Zm9vcGFkZGluZw==" ) ;
447
- assert_eq ! (
448
- Base64UrlPad :: decode( "Zm9vcGFkZGluZw==" ) . unwrap( ) ,
449
- b"foopadding" . to_vec( )
450
- ) ;
451
- }
452
- }
0 commit comments