Skip to content

Commit d3d611a

Browse files
committed
fix: bitrate test
1 parent 9f9ae98 commit d3d611a

File tree

4 files changed

+22
-10
lines changed

4 files changed

+22
-10
lines changed

Cargo.lock

Lines changed: 12 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ str0m = { git = "https://github.com/PulseBeamDev/str0m.git", branch = "patch/mai
3939
# str0m = { git = "https://github.com/algesten/str0m.git", rev = "fe599b7847779e9dfd822daea943fa9e272c71b0", default-features = false, features = ["openssl", "vendored"] }
4040
# str0m = { version = "0.11.1", default-features = false, features = ["openssl", "vendored", "sha1"] }
4141

42+
more-asserts = "0.3.1"
43+
4244
# [patch.crates-io]
4345
# str0m = { path = "../str0m" }
4446
# [patch."https://github.com/algesten/str0m.git"]

pulsebeam/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ aws-lc-rs = { version = "1.15.2" }
5050

5151
[dev-dependencies]
5252
turmoil = "0.6.6"
53+
more-asserts = { workspace = true }
5354

5455
[build-dependencies]
5556
prost-build = "0.14.1"

pulsebeam/src/bitrate.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,8 @@ impl BitrateController {
119119

120120
#[cfg(test)]
121121
mod tests {
122+
use more_asserts::{assert_gt, assert_lt};
123+
122124
use super::*;
123125

124126
#[test]
@@ -142,11 +144,11 @@ mod tests {
142144
}
143145
assert_eq!(ctrl.current().as_f64(), 1_000_000.0);
144146

145-
// One tick drop to 300 kbps (simulating bad estimate/jitter)
146-
// With decay 0.95, should only drop to ~950k, not 300k
147-
let res = ctrl.update(Bitrate::kbps(300));
148-
assert!(res.as_f64() > 900_000.0);
149-
assert!(res.as_f64() < 1_000_000.0);
147+
// One tick drop to 800 kbps (simulating bad estimate/jitter)
148+
// With decay 0.95, should only drop to ~950k, not 800k
149+
let res = ctrl.update(Bitrate::kbps(800));
150+
assert_gt!(res.as_f64(), 900_000.0);
151+
assert_lt!(res.as_f64(), 1_000_000.0);
150152

151153
// Input recovers immediately
152154
let res = ctrl.update(Bitrate::kbps(1000));

0 commit comments

Comments
 (0)