style: apply cargo fmt across the crate (A20)
The repo never enforced rustfmt, so formatting had drifted broadly. This is a single mechanical `cargo fmt` pass over the whole crate (no behavioral change; lib suite green, 493 passed). Going forward fmt should be enforced (planned CI fmt --check step). Part of the 0.6.1 hygiene pass. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
+69
-15
@@ -123,7 +123,10 @@ mod tests {
|
||||
let out = lim.process(&loud, 1.0);
|
||||
let ceiling = lim.ceiling().ceil() as i16;
|
||||
for &s in &out {
|
||||
assert!(s > 0, "positive loud input stays positive (no wrap), got {s}");
|
||||
assert!(
|
||||
s > 0,
|
||||
"positive loud input stays positive (no wrap), got {s}"
|
||||
);
|
||||
assert!(s <= ceiling, "sample {s} exceeded ceiling {ceiling}");
|
||||
}
|
||||
}
|
||||
@@ -175,7 +178,10 @@ mod tests {
|
||||
let out_pos = lim.process(&pos_loud, 1.0);
|
||||
for &s in &out_pos {
|
||||
assert!(s > 0, "positive input stays positive, got {s}");
|
||||
assert!(s <= ceiling_ceil, "positive sample {s} exceeded ceiling {ceiling_ceil}");
|
||||
assert!(
|
||||
s <= ceiling_ceil,
|
||||
"positive sample {s} exceeded ceiling {ceiling_ceil}"
|
||||
);
|
||||
}
|
||||
|
||||
// Sustained negative loud sum
|
||||
@@ -185,7 +191,10 @@ mod tests {
|
||||
let neg_ceiling = -ceiling_ceil;
|
||||
for &s in &out_neg {
|
||||
assert!(s < 0, "negative input stays negative, got {s}");
|
||||
assert!(s >= neg_ceiling, "negative sample {s} exceeded negative ceiling {neg_ceiling}");
|
||||
assert!(
|
||||
s >= neg_ceiling,
|
||||
"negative sample {s} exceeded negative ceiling {neg_ceiling}"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -200,8 +209,14 @@ mod tests {
|
||||
let out = lim.process(&input, 8.0);
|
||||
for &s in &out {
|
||||
assert!(s > 0, "positive stays positive");
|
||||
assert!(s <= ceiling_ceil, "sample {s} must be limited to ceiling {ceiling_ceil}");
|
||||
assert!((s - ceiling_ceil).abs() <= 2, "sample {s} should ride the ceiling {ceiling_ceil}");
|
||||
assert!(
|
||||
s <= ceiling_ceil,
|
||||
"sample {s} must be limited to ceiling {ceiling_ceil}"
|
||||
);
|
||||
assert!(
|
||||
(s - ceiling_ceil).abs() <= 2,
|
||||
"sample {s} should ride the ceiling {ceiling_ceil}"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -213,7 +228,10 @@ mod tests {
|
||||
let out = lim.process(&input, 0.5);
|
||||
for (i, &s) in out.iter().enumerate() {
|
||||
let expected = (input[i] as f32 * 0.5).round() as i16;
|
||||
assert!((s - expected).abs() <= 1, "sample {s} should be close to expected {expected}");
|
||||
assert!(
|
||||
(s - expected).abs() <= 1,
|
||||
"sample {s} should be close to expected {expected}"
|
||||
);
|
||||
}
|
||||
|
||||
// Subsequently feed a new sample at unity gain. It must be transparent,
|
||||
@@ -230,7 +248,12 @@ mod tests {
|
||||
|
||||
let loud = vec![200_000i32; 10];
|
||||
let out = lim.process(&loud, 1.0);
|
||||
assert!(out[0] <= ceiling_ceil, "first sample {} must not overshoot ceiling {}", out[0], ceiling_ceil);
|
||||
assert!(
|
||||
out[0] <= ceiling_ceil,
|
||||
"first sample {} must not overshoot ceiling {}",
|
||||
out[0],
|
||||
ceiling_ceil
|
||||
);
|
||||
}
|
||||
|
||||
/// 5. Release direction & monotonicity.
|
||||
@@ -247,13 +270,23 @@ mod tests {
|
||||
|
||||
// Output should be monotonic (non-decreasing)
|
||||
for i in 1..out.len() {
|
||||
assert!(out[i] >= out[i - 1], "output must be monotonic; index {} was {}, index {} was {}", i - 1, out[i - 1], i, out[i]);
|
||||
assert!(
|
||||
out[i] >= out[i - 1],
|
||||
"output must be monotonic; index {} was {}, index {} was {}",
|
||||
i - 1,
|
||||
out[i - 1],
|
||||
i,
|
||||
out[i]
|
||||
);
|
||||
}
|
||||
|
||||
// The end sample should be closer to the original input than the start sample
|
||||
let start_diff = (mid_val as i16 - out[0]).abs();
|
||||
let end_diff = (mid_val as i16 - *out.last().unwrap()).abs();
|
||||
assert!(end_diff < start_diff, "end diff {end_diff} should be smaller than start diff {start_diff}");
|
||||
assert!(
|
||||
end_diff < start_diff,
|
||||
"end diff {end_diff} should be smaller than start diff {start_diff}"
|
||||
);
|
||||
}
|
||||
|
||||
/// 6. Release is gradual, not instantaneous.
|
||||
@@ -265,7 +298,11 @@ mod tests {
|
||||
|
||||
// Immediately follow with a sub-ceiling sample
|
||||
let out = lim.process(&[10_000i32], 1.0);
|
||||
assert!(out[0] < 10_000, "first quiet sample should still be attenuated (got {})", out[0]);
|
||||
assert!(
|
||||
out[0] < 10_000,
|
||||
"first quiet sample should still be attenuated (got {})",
|
||||
out[0]
|
||||
);
|
||||
}
|
||||
|
||||
/// 7. State carries across process calls.
|
||||
@@ -287,7 +324,10 @@ mod tests {
|
||||
let mut out_split = out_split1;
|
||||
out_split.extend(&out_split2);
|
||||
|
||||
assert_eq!(out_single, out_split, "splitting process calls must produce identical output to a single call");
|
||||
assert_eq!(
|
||||
out_single, out_split,
|
||||
"splitting process calls must produce identical output to a single call"
|
||||
);
|
||||
|
||||
// Test 2: Pre-loaded limiter vs fresh limiter on the same input
|
||||
let mut lim_preloaded = SoftLimiter::new(SR);
|
||||
@@ -299,8 +339,16 @@ mod tests {
|
||||
let out_preloaded = lim_preloaded.process(&test_input, 1.0);
|
||||
let out_fresh = lim_fresh.process(&test_input, 1.0);
|
||||
|
||||
assert_ne!(out_preloaded, out_fresh, "pre-loaded and fresh limiter outputs should differ");
|
||||
assert!(out_preloaded[0] < out_fresh[0], "pre-loaded limiter first sample {} should be smaller than fresh limiter first sample {}", out_preloaded[0], out_fresh[0]);
|
||||
assert_ne!(
|
||||
out_preloaded, out_fresh,
|
||||
"pre-loaded and fresh limiter outputs should differ"
|
||||
);
|
||||
assert!(
|
||||
out_preloaded[0] < out_fresh[0],
|
||||
"pre-loaded limiter first sample {} should be smaller than fresh limiter first sample {}",
|
||||
out_preloaded[0],
|
||||
out_fresh[0]
|
||||
);
|
||||
}
|
||||
|
||||
/// 8. Empty input.
|
||||
@@ -320,7 +368,10 @@ mod tests {
|
||||
// Gain 0.0
|
||||
let out_zero = lim.process(&input, 0.0);
|
||||
assert_eq!(out_zero.len(), input.len());
|
||||
assert!(out_zero.iter().all(|&s| s == 0), "0.0 gain should result in all zeros");
|
||||
assert!(
|
||||
out_zero.iter().all(|&s| s == 0),
|
||||
"0.0 gain should result in all zeros"
|
||||
);
|
||||
|
||||
// Gain 1.0
|
||||
let out_unity = lim.process(&input, 1.0);
|
||||
@@ -354,6 +405,9 @@ mod tests {
|
||||
|
||||
let out = lim.process(&input, 1.0);
|
||||
let expected: Vec<i16> = input.iter().map(|&s| s as i16).collect();
|
||||
assert_eq!(out, expected, "below ceiling input must be bit-exact at unity gain");
|
||||
assert_eq!(
|
||||
out, expected,
|
||||
"below ceiling input must be bit-exact at unity gain"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user