mirror of
https://github.com/FliegendeWurst/cursive.git
synced 2024-11-23 17:35:00 +00:00
Fix StackView tests
This commit is contained in:
parent
927afafe88
commit
88fb6e7c54
@ -45,7 +45,11 @@ fn make_percentage(value: usize, (min, max): (usize, usize)) -> String {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let (percentage, extra) = ratio(value - min, max - min, 100);
|
let (percentage, extra) = ratio(value - min, max - min, 100);
|
||||||
let percentage = if extra > 4 { percentage + 1 } else { percentage };
|
let percentage = if extra > 4 {
|
||||||
|
percentage + 1
|
||||||
|
} else {
|
||||||
|
percentage
|
||||||
|
};
|
||||||
format!("{} %", percentage)
|
format!("{} %", percentage)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -677,40 +677,28 @@ mod tests {
|
|||||||
.get(LayerPosition::FromFront(0))
|
.get(LayerPosition::FromFront(0))
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.as_any()
|
.as_any()
|
||||||
.downcast_ref::<ViewBox>()
|
.is::<TextView>()
|
||||||
.unwrap()
|
|
||||||
.with_view(|v| v.as_any().is::<TextView>())
|
|
||||||
.unwrap()
|
|
||||||
);
|
);
|
||||||
assert!(
|
assert!(
|
||||||
stack
|
stack
|
||||||
.get(LayerPosition::FromBack(0))
|
.get(LayerPosition::FromBack(0))
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.as_any()
|
.as_any()
|
||||||
.downcast_ref::<ViewBox>()
|
.is::<TextView>()
|
||||||
.unwrap()
|
|
||||||
.with_view(|v| v.as_any().is::<TextView>())
|
|
||||||
.unwrap()
|
|
||||||
);
|
);
|
||||||
assert!(
|
assert!(
|
||||||
stack
|
stack
|
||||||
.get_mut(LayerPosition::FromFront(0))
|
.get_mut(LayerPosition::FromFront(0))
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.as_any_mut()
|
.as_any_mut()
|
||||||
.downcast_mut::<ViewBox>()
|
.is::<TextView>()
|
||||||
.unwrap()
|
|
||||||
.with_view_mut(|v| v.as_any_mut().is::<TextView>())
|
|
||||||
.unwrap()
|
|
||||||
);
|
);
|
||||||
assert!(
|
assert!(
|
||||||
stack
|
stack
|
||||||
.get_mut(LayerPosition::FromBack(0))
|
.get_mut(LayerPosition::FromBack(0))
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.as_any_mut()
|
.as_any_mut()
|
||||||
.downcast_mut::<ViewBox>()
|
.is::<TextView>()
|
||||||
.unwrap()
|
|
||||||
.with_view_mut(|v| v.as_any_mut().is::<TextView>())
|
|
||||||
.unwrap()
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user