|
1 | | -#![allow(missing_docs, clippy::cast_possible_truncation, clippy::unwrap_used)] |
| 1 | +//! Integration tests. |
2 | 2 |
|
3 | | -use core::mem::MaybeUninit; |
| 3 | +#![allow(clippy::cast_possible_truncation, clippy::unwrap_used)] |
| 4 | + |
| 5 | +use core::{ |
| 6 | + borrow::{Borrow, BorrowMut}, |
| 7 | + mem::MaybeUninit, |
| 8 | +}; |
4 | 9 | use hybrid_array::{Array, ArrayN}; |
5 | 10 | use typenum::{U0, U2, U3, U4, U5, U6, U7}; |
6 | 11 |
|
@@ -67,6 +72,38 @@ fn as_mut_slice() { |
67 | 72 | assert_eq!(&[1, 2], slice); |
68 | 73 | } |
69 | 74 |
|
| 75 | +#[test] |
| 76 | +fn borrow_core_array() { |
| 77 | + type A = Array<u8, U2>; |
| 78 | + let array: A = Array([1, 2]); |
| 79 | + let array_ref: &[u8; 2] = array.borrow(); |
| 80 | + assert_eq!(&array, array_ref); |
| 81 | +} |
| 82 | + |
| 83 | +#[test] |
| 84 | +fn borrow_identity() { |
| 85 | + type A = Array<u8, U2>; |
| 86 | + let array: A = Array([1, 2]); |
| 87 | + let array_ref: &A = array.borrow(); |
| 88 | + assert_eq!(&array, array_ref); |
| 89 | +} |
| 90 | + |
| 91 | +#[test] |
| 92 | +fn borrow_mut_identity() { |
| 93 | + type A = Array<u8, U2>; |
| 94 | + let mut array: A = Array([1, 2]); |
| 95 | + let array_ref: &mut A = array.borrow_mut(); |
| 96 | + assert_eq!(&[1, 2], array_ref); |
| 97 | +} |
| 98 | + |
| 99 | +#[test] |
| 100 | +fn borrow_mut_core_array() { |
| 101 | + type A = Array<u8, U2>; |
| 102 | + let mut array: A = Array([1, 2]); |
| 103 | + let array_ref: &mut [u8; 2] = array.borrow_mut(); |
| 104 | + assert_eq!(&[1, 2], array_ref); |
| 105 | +} |
| 106 | + |
70 | 107 | #[test] |
71 | 108 | fn cast_slice_from_core() { |
72 | 109 | type A = Array<u8, U2>; |
|
0 commit comments