mirror of
https://github.com/edg-l/teeint.git
synced 2024-09-07 19:35:13 +00:00
more docs
This commit is contained in:
parent
a7b5ebb6b5
commit
59936990c8
20
src/lib.rs
20
src/lib.rs
|
@ -6,7 +6,9 @@
|
|||
//! use std::io::Cursor;
|
||||
//!
|
||||
//! let mut buff = Cursor::new([0; 2]);
|
||||
//! assert!(teeint::pack(&mut buff, 64).is_ok());
|
||||
//!
|
||||
//! teeint::pack(&mut buff, 64).unwrap();
|
||||
//!
|
||||
//! let buff = buff.into_inner();
|
||||
//! assert_eq!(buff[0], 0b1000_0000);
|
||||
//! assert_eq!(buff[1], 0b0000_0001);
|
||||
|
@ -18,11 +20,16 @@
|
|||
//! use teeint::PackTwInt;
|
||||
//!
|
||||
//! let mut buff = Cursor::new([0; 2]);
|
||||
//! assert!(64.pack(&mut buff).is_ok());
|
||||
//!
|
||||
//! 64.pack(&mut buff).unwrap();
|
||||
//!
|
||||
//! let buff = buff.into_inner();
|
||||
//! assert_eq!(buff[0], 0b1000_0000);
|
||||
//! assert_eq!(buff[1], 0b0000_0001);
|
||||
//! ```
|
||||
//!
|
||||
//! Thanks to [heinrich5991 libtw2 docs](https://github.com/heinrich5991/libtw2/blob/master/doc/int.md) for help.
|
||||
//!
|
||||
|
||||
use std::io::{Result, Write};
|
||||
|
||||
|
@ -141,4 +148,13 @@ mod tests {
|
|||
assert_eq!(buff[0], 0b1000_0000);
|
||||
assert_eq!(buff[1], 0b0000_0001);
|
||||
}
|
||||
|
||||
#[test]
|
||||
pub fn pack_64_trait() {
|
||||
let mut buff = Cursor::new([0; 2]);
|
||||
assert!(64.pack(&mut buff).is_ok());
|
||||
let buff = buff.into_inner();
|
||||
assert_eq!(buff[0], 0b1000_0000);
|
||||
assert_eq!(buff[1], 0b0000_0001);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue