Move test to tests directory

This commit is contained in:
zypeh
2022-08-25 17:56:15 +08:00
committed by Lucas
parent f997a6250c
commit 9ded4d79d5
4 changed files with 85 additions and 21 deletions

View File

@@ -13,3 +13,6 @@ authors = ["Lucas Rosa <x@rvcas.dev>", "Kasey White <kwhitemsg@gmail.com>"]
[dependencies]
anyhow = "1.0.57"
thiserror = "1.0.31"
[dev-dependencies]
quickcheck = "1"

View File

@@ -45,24 +45,3 @@ where
Ok(value)
}
#[cfg(test)]
mod test {
#[test]
fn encode_bool() {
let bytes = super::encode(&true).unwrap();
assert_eq!(bytes, vec![0b10000001]);
let bytes = super::encode(&false).unwrap();
assert_eq!(bytes, vec![0b00000001]);
}
#[test]
fn encode_u8() {
let bytes = super::encode(&3_u8).unwrap();
assert_eq!(bytes, vec![0b00000011, 0b00000001]);
}
}

View File

@@ -0,0 +1,34 @@
use flat_rs::{decode, encode};
#[cfg(test)]
mod test {
#[test]
fn encode_bool() {
let bytes = crate::encode(&true).unwrap();
assert_eq!(bytes, vec![0b10000001]);
let decoded: bool = crate::decode(bytes.as_slice()).unwrap();
assert_eq!(decoded, true);
let bytes = crate::encode(&false).unwrap();
assert_eq!(bytes, vec![0b00000001]);
let decoded: bool = crate::decode(bytes.as_slice()).unwrap();
assert_eq!(decoded, false);
}
#[test]
fn encode_u8() {
let bytes = crate::encode(&3_u8).unwrap();
assert_eq!(bytes, vec![0b00000011, 0b00000001]);
let decoded: u8 = crate::decode(bytes.as_slice()).unwrap();
assert_eq!(decoded, 3_u8);
}
}