diff --git a/bffhd/authorization/permissions.rs b/bffhd/authorization/permissions.rs index d898900..8360365 100644 --- a/bffhd/authorization/permissions.rs +++ b/bffhd/authorization/permissions.rs @@ -328,29 +328,6 @@ mod tests { assert!(rule.match_perm(&perm3)); } - #[test] - fn format_and_read_compatible() { - use std::convert::TryInto; - - let testdata = vec![("testrole", "testsource"), ("", "norole"), ("nosource", "")] - .into_iter() - .map(|(n, s)| (n.to_string(), s.to_string())); - - for (name, source) in testdata { - let role = RoleIdentifier { name, source }; - - let fmt_string = format!("{}", &role); - - println!("{:?} is formatted: {}", &role, &fmt_string); - - let parsed: RoleIdentifier = fmt_string.try_into().unwrap(); - - println!("Which parses into {:?}", &parsed); - - assert_eq!(role, parsed); - } - } - #[test] fn rules_from_string_test() { assert_eq!( diff --git a/bffhd/resources/state/db.rs b/bffhd/resources/state/db.rs index fcbb7ac..88d047a 100644 --- a/bffhd/resources/state/db.rs +++ b/bffhd/resources/state/db.rs @@ -80,34 +80,6 @@ impl StateDB { mod tests { use super::*; - use crate::resource::state::value::Vec3u8; - use crate::resource::state::value::{OID_COLOUR, OID_INTENSITY, OID_POWERED}; use std::ops::Deref; - #[test] - fn construct_state() { - let tmpdir = tempfile::tempdir().unwrap(); - let mut tmppath = tmpdir.path().to_owned(); - tmppath.push("db"); - let db = StateDB::create(tmppath).unwrap(); - let b = State::build() - .add(OID_COLOUR.clone(), Box::new(Vec3u8 { a: 1, b: 2, c: 3 })) - .add(OID_POWERED.clone(), Box::new(true)) - .add(OID_INTENSITY.clone(), Box::new(1023)) - .finish(); - println!("({}) {:?}", b.hash(), b); - - let c = State::build() - .add(OID_COLOUR.clone(), Box::new(Vec3u8 { a: 1, b: 2, c: 3 })) - .add(OID_POWERED.clone(), Box::new(true)) - .add(OID_INTENSITY.clone(), Box::new(1023)) - .finish(); - - let key = rand::random(); - db.update(key, &b, &c).unwrap(); - let d = db.get_input(key).unwrap().unwrap(); - let e = db.get_output(key).unwrap().unwrap(); - assert_eq!(&b, d.deref()); - assert_eq!(&c, e.deref()); - } } diff --git a/bffhd/resources/state/mod.rs b/bffhd/resources/state/mod.rs index 70fd1bc..305c61b 100644 --- a/bffhd/resources/state/mod.rs +++ b/bffhd/resources/state/mod.rs @@ -84,69 +84,4 @@ pub mod tests { use super::value::*; use super::*; - pub(crate) fn gen_random() -> State { - let amt: u8 = rand::random::() % 20; - - let mut sb = State::build(); - for _ in 0..amt { - let oid = crate::utils::oid::tests::gen_random(); - sb = match rand::random::() % 12 { - 0 => sb.add(oid, Box::new(rand::random::())), - 1 => sb.add(oid, Box::new(rand::random::())), - 2 => sb.add(oid, Box::new(rand::random::())), - 3 => sb.add(oid, Box::new(rand::random::())), - 4 => sb.add(oid, Box::new(rand::random::())), - 5 => sb.add(oid, Box::new(rand::random::())), - 6 => sb.add(oid, Box::new(rand::random::())), - 7 => sb.add(oid, Box::new(rand::random::())), - 8 => sb.add(oid, Box::new(rand::random::())), - 9 => sb.add(oid, Box::new(rand::random::())), - 10 => sb.add(oid, Box::new(rand::random::())), - 11 => sb.add(oid, Box::new(rand::random::())), - _ => unreachable!(), - } - } - sb.finish() - } - - #[test] - fn test_equal_state_is_eq() { - let stateA = State::build() - .add(OID_POWERED.clone(), Box::new(false)) - .add(OID_INTENSITY.clone(), Box::new(1024)) - .finish(); - - let stateB = State::build() - .add(OID_POWERED.clone(), Box::new(false)) - .add(OID_INTENSITY.clone(), Box::new(1024)) - .finish(); - - assert_eq!(stateA, stateB); - } - - #[test] - fn test_unequal_state_is_ne() { - let stateA = State::build() - .add(OID_POWERED.clone(), Box::new(true)) - .add(OID_INTENSITY.clone(), Box::new(512)) - .finish(); - - let stateB = State::build() - .add(OID_POWERED.clone(), Box::new(false)) - .add(OID_INTENSITY.clone(), Box::new(1024)) - .finish(); - - assert_ne!(stateA, stateB); - } - - #[test] - fn test_state_is_clone() { - let stateA = gen_random(); - - let stateB = stateA.clone(); - let stateC = stateB.clone(); - drop(stateA); - - assert_eq!(stateC, stateB); - } } diff --git a/bffhd/utils/oid.rs b/bffhd/utils/oid.rs index 5301b5f..a20afbb 100644 --- a/bffhd/utils/oid.rs +++ b/bffhd/utils/oid.rs @@ -509,19 +509,6 @@ pub(crate) mod tests { ObjectIdentifier::build(ObjectIdentifierRoot::JointIsoItuT, 25, children).unwrap() } - #[test] - fn bincode_serde_roundtrip() { - let expected = ObjectIdentifier::build( - ObjectIdentifierRoot::ItuT, - 0x01, - vec![1, 2, 3, 5, 8, 13, 21], - ) - .unwrap(); - let buffer: Vec = bincode::serialize(&expected).unwrap(); - let actual = bincode::deserialize(&buffer).unwrap(); - assert_eq!(expected, actual); - } - #[test] fn encode_binary_root_node_0() { let expected: Vec = vec![0];