mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-05-01 22:40:13 +02:00
38.54% coverage
This commit is contained in:
parent
f71118613b
commit
77d617f9a0
2
Cargo.lock
generated
2
Cargo.lock
generated
|
@ -1482,6 +1482,8 @@ dependencies = [
|
|||
"backtrace",
|
||||
"clap",
|
||||
"palette",
|
||||
"proptest",
|
||||
"proptest-derive",
|
||||
"rand",
|
||||
"tek_jack",
|
||||
"tek_midi",
|
||||
|
|
|
@ -43,13 +43,6 @@ impl<E: Output> std::fmt::Debug for Measure<E> {
|
|||
}
|
||||
}
|
||||
impl<E: Output> Measure<E> {
|
||||
pub fn w (&self) -> usize { self.x.load(Relaxed) }
|
||||
pub fn h (&self) -> usize { self.y.load(Relaxed) }
|
||||
pub fn wh (&self) -> [usize;2] { [self.w(), self.h()] }
|
||||
pub fn set_w (&self, w: impl Into<usize>) { self.x.store(w.into(), Relaxed) }
|
||||
pub fn set_h (&self, h: impl Into<usize>) { self.y.store(h.into(), Relaxed) }
|
||||
pub fn set_wh (&self, w: impl Into<usize>, h: impl Into<usize>) { self.set_w(w); self.set_h(h); }
|
||||
pub fn format (&self) -> Arc<str> { format!("{}x{}", self.w(), self.h()).into() }
|
||||
pub fn new () -> Self {
|
||||
Self {
|
||||
_engine: PhantomData::default(),
|
||||
|
@ -57,10 +50,45 @@ impl<E: Output> Measure<E> {
|
|||
y: Arc::new(0.into()),
|
||||
}
|
||||
}
|
||||
pub fn set_w (&self, w: impl Into<usize>) -> &Self {
|
||||
self.x.store(w.into(), Relaxed);
|
||||
self
|
||||
}
|
||||
pub fn set_h (&self, h: impl Into<usize>) -> &Self {
|
||||
self.y.store(h.into(), Relaxed);
|
||||
self
|
||||
}
|
||||
pub fn set_wh (&self, w: impl Into<usize>, h: impl Into<usize>) -> &Self {
|
||||
self.set_w(w);
|
||||
self.set_h(h);
|
||||
self
|
||||
}
|
||||
pub fn w (&self) -> usize {
|
||||
self.x.load(Relaxed)
|
||||
}
|
||||
pub fn h (&self) -> usize {
|
||||
self.y.load(Relaxed)
|
||||
}
|
||||
pub fn wh (&self) -> [usize;2] {
|
||||
[self.w(), self.h()]
|
||||
}
|
||||
pub fn format (&self) -> Arc<str> {
|
||||
format!("{}x{}", self.w(), self.h()).into()
|
||||
}
|
||||
pub fn of <T: Content<E>> (&self, item: T) -> Bsp<Fill<&Self>, T> {
|
||||
Bsp::b(Fill::xy(self), item)
|
||||
}
|
||||
}
|
||||
//#[cfg(test)] #[test] fn test_measure () {
|
||||
//use tek_tui::*;
|
||||
//let size: Measure<TuiOut> = Measure::default().set_w(1usize).set_h(1usize).clone();
|
||||
//let size: Measure<TuiOut> = (&Measure::new().set_wh(2usize, 1usize)).clone();
|
||||
//let _ = format!("{:?}", &size);
|
||||
//let _ = size.wh();
|
||||
//let _ = size.format();
|
||||
//let _ = size.of(());
|
||||
//}
|
||||
|
||||
///// A scrollable area.
|
||||
//pub struct Scroll<E, F>(pub F, pub Direction, pub u64, PhantomData<E>)
|
||||
//where
|
||||
|
|
|
@ -17,6 +17,10 @@ rand = "0.8.5"
|
|||
toml = "0.8.12"
|
||||
clap = { optional = true, version = "4.5.4", features = [ "derive" ] }
|
||||
|
||||
[dev-dependencies]
|
||||
proptest = "^1"
|
||||
proptest-derive = "^0.5.1"
|
||||
|
||||
[features]
|
||||
default = ["cli"]
|
||||
cli = ["clap"]
|
||||
|
|
|
@ -200,7 +200,13 @@ impl Tek {
|
|||
Ok(tek)
|
||||
}
|
||||
}
|
||||
#[cfg(test)] fn test_tek_cli () {
|
||||
#[cfg(test)] #[test] fn test_tek_cli () {
|
||||
use clap::CommandFactory;
|
||||
TekCli::command().debug_assert();
|
||||
let jack = Jack::default();
|
||||
//TODO:
|
||||
//let _ = Tek::new_clock(&jack, None, false, false, &[], &[]);
|
||||
//let _ = Tek::new_sequencer(&jack, None, false, false, &[], &[]);
|
||||
//let _ = Tek::new_groovebox(&jack, None, false, false, &[], &[], &[&[], &[]], &[&[], &[]]);
|
||||
//let _ = Tek::new_arranger(&jack, None, false, false, &[], &[], &[&[], &[]], &[&[], &[]], 0, 0, 0);
|
||||
}
|
||||
|
|
|
@ -25,7 +25,24 @@ fn view_meters (values: &[f32;2]) -> impl Content<TuiOut> + use<'_> {
|
|||
format!("R/{:>+9.3}", values[1]),
|
||||
)
|
||||
}
|
||||
#[cfg(test)] #[test] fn test_view_meter () {
|
||||
let _ = view_meter("", 0.0);
|
||||
let _ = view_meters(&[0.0, 0.0]);
|
||||
#[cfg(test)] mod test_view_meter {
|
||||
use super::*;
|
||||
use proptest::prelude::*;
|
||||
#[test] fn test_view_meter () {
|
||||
let _ = view_meter("", 0.0);
|
||||
let _ = view_meters(&[0.0, 0.0]);
|
||||
}
|
||||
proptest! {
|
||||
#[test] fn proptest_view_meter (
|
||||
label in "\\PC*", value in f32::MIN..f32::MAX
|
||||
) {
|
||||
let _ = view_meter(&label, value);
|
||||
}
|
||||
#[test] fn proptest_view_meters (
|
||||
value1 in f32::MIN..f32::MAX,
|
||||
value2 in f32::MIN..f32::MAX
|
||||
) {
|
||||
let _ = view_meters(&[value1, value2]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue