@@ -430,12 +430,42 @@ pub fn fmt_surfaces() -> bool {
430430 output. as_bytes ( ) == b"aGVsbG8="
431431}
432432
433+ pub fn native_interop_surfaces ( ) -> bool {
434+ let encoded = match EncodedBuffer :: < 8 > :: try_from ( b"hello" ) {
435+ Ok ( encoded) => encoded,
436+ Err ( _) => return false ,
437+ } ;
438+ if encoded. as_bytes ( ) != b"aGVsbG8=" {
439+ return false ;
440+ }
441+
442+ let decoded = match DecodedBuffer :: < 5 > :: try_from ( b"aGVsbG8=" ) {
443+ Ok ( decoded) => decoded,
444+ Err ( _) => return false ,
445+ } ;
446+ if decoded. as_bytes ( ) != b"hello" {
447+ return false ;
448+ }
449+
450+ let parsed = match "aGVsbG8=" . parse :: < DecodedBuffer < 5 > > ( ) {
451+ Ok ( decoded) => decoded,
452+ Err ( _) => return false ,
453+ } ;
454+ if parsed. as_bytes ( ) != b"hello" {
455+ return false ;
456+ }
457+
458+ DecodedBuffer :: < 5 > :: try_from ( b"aGVsbG8" ) . is_err ( )
459+ && "aGVsbG8" . parse :: < DecodedBuffer < 5 > > ( ) . is_err ( )
460+ }
461+
433462#[ cfg( test) ]
434463mod tests {
435464 use super :: {
436465 CONST_HELLO , clear_tail_surfaces, ct_stack_decode, custom_profile_surfaces, fmt_surfaces,
437- in_place_surfaces, legacy_stack_decode, length_and_stack_state_surfaces, stack_round_trip,
438- named_profile_surfaces, url_safe_round_trip, validate_only_surfaces, wrapped_round_trip,
466+ in_place_surfaces, legacy_stack_decode, length_and_stack_state_surfaces,
467+ named_profile_surfaces, native_interop_surfaces, stack_round_trip, url_safe_round_trip,
468+ validate_only_surfaces, wrapped_round_trip,
439469 } ;
440470
441471 #[ test]
@@ -461,5 +491,6 @@ mod tests {
461491 assert ! ( ct_stack_decode( ) ) ;
462492 assert ! ( length_and_stack_state_surfaces( ) ) ;
463493 assert ! ( fmt_surfaces( ) ) ;
494+ assert ! ( native_interop_surfaces( ) ) ;
464495 }
465496}
0 commit comments