-
-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
52 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
[profile.default] | ||
test-threads = 1 | ||
fail-fast = false | ||
slow-timeout = { period = "30s", terminate-after = 4 } | ||
retries = { backoff = "fixed", count = 2, delay = "500ms" } | ||
slow-timeout = { period = "5s", terminate-after = 4 } | ||
retries = { backoff = "fixed", count = 2, delay = "100ms" } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#[test] | ||
fn can_set_logger() { | ||
crate::set_logger(crate::LoggerType::Custom { | ||
info: test_info_callback, | ||
error: test_error_callback, | ||
}); | ||
assert!(unsafe { crate::jack_sys::jack_info_callback } == Some(test_info_callback),); | ||
assert!(unsafe { crate::jack_sys::jack_error_callback } == Some(test_error_callback),); | ||
super::log_to_stdio(); // Revert to enable debugging in other tests. | ||
} | ||
|
||
unsafe extern "C" fn test_info_callback(_msg: *const libc::c_char) {} | ||
unsafe extern "C" fn test_error_callback(_msg: *const libc::c_char) {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,8 @@ | ||
mod client; | ||
mod log; | ||
mod time; | ||
|
||
#[cfg(test)] | ||
#[ctor::ctor] | ||
fn init() { | ||
fn log_to_stdio() { | ||
crate::set_logger(crate::LoggerType::Stdio); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
use approx::assert_abs_diff_eq; | ||
|
||
#[test] | ||
fn frame_and_time_are_convertable() { | ||
let (client, _) = crate::Client::new("", crate::ClientOptions::empty()).unwrap(); | ||
assert_eq!(client.time_to_frames(client.frames_to_time(0)), 0); | ||
} | ||
|
||
#[test] | ||
fn one_frame_duration_is_inverse_of_sample_rate() { | ||
let (client, _) = crate::Client::new("", crate::ClientOptions::empty()).unwrap(); | ||
let sample_rate = client.sample_rate(); | ||
assert_abs_diff_eq!( | ||
(client.frames_to_time(sample_rate as _) - client.frames_to_time(0)) as f64, | ||
1_000_000.0, | ||
epsilon = 1_000_000.0 * 1e-4, | ||
); | ||
} | ||
|
||
#[test] | ||
fn one_second_is_sample_rate_frames() { | ||
let (client, _) = crate::Client::new("", crate::ClientOptions::empty()).unwrap(); | ||
let t0 = client.time_to_frames(0); | ||
let t1 = client.time_to_frames(1_000_000); | ||
assert_abs_diff_eq!( | ||
(t1 - t0) as f64, | ||
client.sample_rate() as f64, | ||
epsilon = client.sample_rate() as f64 * 1e-7 | ||
); | ||
} |