mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-10-30 10:42:09 +08:00
test: trim redundant test coverage
This commit is contained in:
@@ -103,19 +103,3 @@ pub async fn notify_event<'a>(event: NotificationEvent<'a>) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::needs_system_notification;
|
||||
use crate::utils::window_manager::WindowState;
|
||||
|
||||
#[test]
|
||||
fn a_system_notification_is_sent_exactly_where_the_window_cannot_speak() {
|
||||
assert!(needs_system_notification(WindowState::Hidden));
|
||||
assert!(needs_system_notification(WindowState::Minimized));
|
||||
assert!(needs_system_notification(WindowState::NotExist));
|
||||
|
||||
assert!(!needs_system_notification(WindowState::VisibleFocused));
|
||||
assert!(!needs_system_notification(WindowState::VisibleUnfocused));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -184,26 +184,3 @@ pub fn reload_main_window_if_needed() {
|
||||
logging!(warn, Type::Window, "重载页面失败: {e}");
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::restored_window_size_is_too_small;
|
||||
|
||||
#[test]
|
||||
fn restored_window_size_rejects_zero_dimensions() {
|
||||
assert!(restored_window_size_is_too_small(0, 700));
|
||||
assert!(restored_window_size_is_too_small(940, 0));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn restored_window_size_rejects_dimensions_below_minimum() {
|
||||
assert!(restored_window_size_is_too_small(519, 700));
|
||||
assert!(restored_window_size_is_too_small(940, 519));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn restored_window_size_accepts_minimum_or_larger_dimensions() {
|
||||
assert!(!restored_window_size_is_too_small(520, 520));
|
||||
assert!(!restored_window_size_is_too_small(940, 700));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,28 +21,3 @@ macro_rules! singleton {
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
struct TestStruct {
|
||||
value: i32,
|
||||
}
|
||||
|
||||
impl TestStruct {
|
||||
fn new() -> Self {
|
||||
Self { value: 42 }
|
||||
}
|
||||
}
|
||||
|
||||
singleton!(TestStruct, TEST_INSTANCE);
|
||||
|
||||
#[test]
|
||||
fn test_singleton_macro() {
|
||||
let instance1 = TestStruct::global();
|
||||
let instance2 = TestStruct::global();
|
||||
|
||||
assert_eq!(instance1.value, 42);
|
||||
assert_eq!(instance2.value, 42);
|
||||
assert!(std::ptr::eq(instance1, instance2));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,31 +30,3 @@ pub fn format_bytes_per_second(bytes_per_sec: u64) -> String {
|
||||
format!("{:.0}{}", value.round(), SPEED_UNITS[unit_index])
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::format_bytes_per_second;
|
||||
|
||||
#[test]
|
||||
fn format_handles_byte_boundaries() {
|
||||
assert_eq!(format_bytes_per_second(0), "0B/s");
|
||||
assert_eq!(format_bytes_per_second(999), "999B/s");
|
||||
assert_eq!(format_bytes_per_second(1000), "1.0K/s");
|
||||
assert_eq!(format_bytes_per_second(1024), "1.0K/s");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn format_handles_decimal_and_integer_rules() {
|
||||
assert_eq!(format_bytes_per_second(9 * 1024), "9.0K/s");
|
||||
assert_eq!(format_bytes_per_second(10 * 1024 - 1), "10K/s");
|
||||
assert_eq!(format_bytes_per_second(10 * 1024), "10K/s");
|
||||
assert_eq!(format_bytes_per_second(123 * 1024), "123K/s");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn format_handles_unit_promotion_after_rounding() {
|
||||
assert_eq!(format_bytes_per_second(999 * 1024 + 512), "1.0M/s");
|
||||
assert_eq!(format_bytes_per_second(1024 * 1024), "1.0M/s");
|
||||
assert_eq!(format_bytes_per_second(1536 * 1024), "1.5M/s");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,23 +63,3 @@ fn append_error(path: &Path, detail: &str) -> Result<()> {
|
||||
file.flush().context("failed to flush startup log")?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::append_error;
|
||||
|
||||
#[test]
|
||||
fn startup_log_is_created_and_appended() -> anyhow::Result<()> {
|
||||
let root = std::env::temp_dir().join(format!("startup-error-log-{}", std::process::id()));
|
||||
let path = root.join("nested/startup.log");
|
||||
|
||||
append_error(&path, "first failure")?;
|
||||
append_error(&path, "second failure")?;
|
||||
|
||||
let content = std::fs::read_to_string(&path)?;
|
||||
assert!(content.contains("ERROR [Startup] first failure"));
|
||||
assert!(content.contains("ERROR [Startup] second failure"));
|
||||
std::fs::remove_dir_all(root)?;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user