use leveldb::database::Slice;
use leveldb::database::bytes::Bytes;

#[test]
fn test_slice_borrowed_as_bytes() {
    let data: &[u8] = b"12345";
    let slice = Slice::from(data);
    assert_eq!(slice.as_bytes(), data);
}

#[test]
fn test_slice_owned_as_bytes() {
    let vec_data = vec![1, 2, 3, 4, 5];
    let len = vec_data.len();
    let raw_ptr = vec_data.leak().as_mut_ptr();
    let bytes = unsafe { Bytes::from_raw_unchecked(raw_ptr, len) };
    let slice = Slice::from(bytes);
    assert_eq!(slice.as_bytes(), &[1, 2, 3, 4, 5]);
}
