use std::{io, ops::Deref}; use preserves2::*; static TEST_DATA: &'static [u8] = &[0xb5, 0xb0, 1, 1, 0xb0, 1, 2, 0xb0, 1, 3, 0x84]; static TEST_VIEW: View = unsafe { View::static_unchecked(TEST_DATA) }; static TEST_VALUE: &'static ValueObject = &TEST_VIEW; #[test] fn static_view_data() -> io::Result<()> { let v = packed::view::View::new::(TEST_DATA, None)?; let v = IOValue::new(v); assert!(v.is_sequence()); assert_eq!(v.len(), 3); assert_eq!(v.index(0), Value::new(1)); assert_eq!(v.index(1), Value::new(2)); assert_eq!(v.index(2), Value::new(3)); println!("{:#?}", IOValue::new(v)); Ok(()) } #[test] fn static_view() -> io::Result<()> { let v: Value = TreeReader::from_bytes(TEST_DATA, false)?; assert_eq!(v.deref(), TEST_VIEW.deref()); Ok(()) } #[test] fn static_value() -> io::Result<()> { let v: Value = TreeReader::from_bytes(TEST_DATA, false)?; assert_eq!(v.deref(), TEST_VALUE); Ok(()) }