File tree Expand file tree Collapse file tree 2 files changed +31
-2
lines changed Expand file tree Collapse file tree 2 files changed +31
-2
lines changed Original file line number Diff line number Diff line change @@ -231,10 +231,11 @@ public ReadOnlySpan<byte> AsSpan(int start)
231231    { 
232232        // 引数の検証をスキップするために、手動でReadOnlySpanを作成する。 
233233#if NET6_0_OR_GREATER 
234+         var  length  =  _value . Length  -  start ; 
234235        ref  var  valueStart  =  ref  DangerousGetReferenceAt ( start ) ; 
235-         return  MemoryMarshal . CreateReadOnlySpan ( ref  valueStart ,  _value . Length ) ; 
236+         return  MemoryMarshal . CreateReadOnlySpan ( ref  valueStart ,  length ) ; 
236237#else
237-         var  span  =  new  ReadOnlySpan < byte > ( _value ,  start ,  _value . Length ) ; 
238+         var  span  =  new  ReadOnlySpan < byte > ( _value ,  start ,  _value . Length   -   start ) ; 
238239        return  span ; 
239240#endif
240241    } 
Original file line number Diff line number Diff line change 1+ using  System . Text ; 
2+ using  FluentAssertions ; 
3+ using  Xunit ; 
4+ 
5+ namespace  Utf8Utility . Tests ; 
6+ 
7+ public  sealed  class  Utf8ArrayAsSpanTest 
8+ { 
9+     [ Theory ] 
10+     [ InlineData ( "abc" ) ] 
11+     public  void  初期インデックス0 ( string  value ) 
12+     { 
13+         var  span  =  new  Utf8Array ( value ) . AsSpan ( ) ; 
14+         var  array  =  Encoding . UTF8 . GetBytes ( value ) ; 
15+ 
16+         span . SequenceEqual ( array ) . Should ( ) . BeTrue ( ) ; 
17+     } 
18+ 
19+     [ Theory ] 
20+     [ InlineData ( "abcdef" ) ] 
21+     public  void  初期インデックス3 ( string  value ) 
22+     { 
23+         var  span  =  new  Utf8Array ( value ) . AsSpan ( 3 ) ; 
24+         var  array  =  Encoding . UTF8 . GetBytes ( value ) . AsSpan ( 3 ) ; 
25+ 
26+         span . SequenceEqual ( array ) . Should ( ) . BeTrue ( ) ; 
27+     } 
28+ } 
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments