File tree Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Original file line number Diff line number Diff line change 8
8
// option. This file may not be copied, modified, or distributed
9
9
// except according to those terms.
10
10
use core:: array:: FixedSizeArray ;
11
+ use core:: convert:: TryFrom ;
11
12
12
13
#[ test]
13
14
fn fixed_size_array ( ) {
@@ -26,3 +27,25 @@ fn fixed_size_array() {
26
27
assert_eq ! ( FixedSizeArray :: as_mut_slice( & mut empty_array) . len( ) , 0 ) ;
27
28
assert_eq ! ( FixedSizeArray :: as_mut_slice( & mut empty_zero_sized) . len( ) , 0 ) ;
28
29
}
30
+
31
+ #[ test]
32
+ fn array_try_from ( ) {
33
+ macro_rules! test {
34
+ ( $( $N: expr) +) => {
35
+ $( {
36
+ type Array = [ u8 ; $N] ;
37
+ let array: Array = [ 0 ; $N] ;
38
+ let slice: & [ u8 ] = & array[ ..] ;
39
+
40
+ let result = <& Array >:: try_from( slice) ;
41
+ assert_eq!( Ok ( & array) , result) ;
42
+ } ) +
43
+ }
44
+ }
45
+ test ! {
46
+ 0 1 2 3 4 5 6 7 8 9
47
+ 10 11 12 13 14 15 16 17 18 19
48
+ 20 21 22 23 24 25 26 27 28 29
49
+ 30 31 32
50
+ }
51
+ }
You can’t perform that action at this time.
0 commit comments