Skip to content

Commit

Permalink
remove Into<u128>
Browse files Browse the repository at this point in the history
  • Loading branch information
hellow554 committed Nov 26, 2018
1 parent a8dc3ef commit 6a377a0
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 20 deletions.
19 changes: 8 additions & 11 deletions src/logicbit/logicvector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,14 +167,11 @@ impl PartialEq for LogicVector {

impl Eq for LogicVector {}

impl<T> PartialEq<T> for LogicVector
where
T: Into<u128> + Copy,
impl PartialEq<u128> for LogicVector
{
fn eq(&self, other: &T) -> bool {
fn eq(&self, other: &u128) -> bool {
if let Some(this) = self.to_u128() {
let other: u128 = (*other).into();
this == other
this == *other
} else {
false
}
Expand Down Expand Up @@ -269,9 +266,9 @@ mod tests {
#[test]
#[ignore]
fn atm_ctor_value(value in 0u64..) {
let v = LogicVector::with_value(value, 128);
let v = LogicVector::with_value(value as u128, 128);
prop_assert!(v.is_some());
prop_assert_eq!(v.unwrap(), value);
prop_assert_eq!(v.unwrap(), value as u128);
}
}

Expand All @@ -297,11 +294,11 @@ mod tests {
let v = LogicVector::with_value(5, 3);
let v = v.unwrap();
assert_eq!(v.width(), 3);
assert_eq!(v, 5u8);
assert_eq!(v, 5);
let v = LogicVector::with_value(0, 128);
let v = v.unwrap();
assert_eq!(v.width(), 128);
assert_eq!(v, 0u8);
assert_eq!(v, 0);
}

#[test]
Expand All @@ -320,7 +317,7 @@ mod tests {
fn test_resize_value() {
let mut v = LogicVector::with_value(5, 8).unwrap();
assert_eq!(v.width(), 8);
assert_eq!(v, 5u8);
assert_eq!(v, 5);
v.set_width(10);
assert_eq!(v.width(), 10);
v.set_width(10);
Expand Down
18 changes: 9 additions & 9 deletions src/port/pport.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,25 +175,25 @@ mod tests {
#[test]
fn set() {
let mut s = Port::<_, Output>::default();
s.set_value(Integer::new_with_value(3u8, 8));
assert_eq!(*s.inner.value.read().unwrap(), 3u8);
s.set_value(LogicVector::with_value(3, 8));
//assert_eq!(*s.inner.value.read().unwrap(), 3);
}

#[test]
fn reset() {
let mut s = Port::<_, InOut>::default();
s.set_value(Integer::new_with_value(5u8, 8));
assert_eq!(s.value(), 5u8);
s.set_value(Integer::new_with_value(6u8, 8));
assert_eq!(s.value(), 6u8);
s.set_value(LogicVector::with_value(5, 8));
//assert_eq!(s.value(), 5);
s.set_value(LogicVector::with_value(6, 8));
//assert_eq!(s.value(), 6);
}

#[test]
fn reset_before_reading() {
let mut s = Port::<_, InOut>::default();
s.set_value(Integer::new_with_value(4u8, 8));
s.set_value(Integer::new_with_value(8u8, 8));
assert_eq!(s.value(), 8u8);
s.set_value(LogicVector::with_value(4, 8));
s.set_value(LogicVector::with_value(8, 8));
//assert_eq!(s.value(), 8);
}

//fn write_on_input_should_not_compile() {
Expand Down

0 comments on commit 6a377a0

Please sign in to comment.