add disk test

This commit is contained in:
weisd
2025-06-08 23:05:13 +08:00
parent 62a7824d0d
commit 96de65ebab
14 changed files with 1862 additions and 937 deletions
+10 -5
View File
@@ -5760,9 +5760,8 @@ mod tests {
// Test that all CHECK_PART constants have expected values
assert_eq!(CHECK_PART_UNKNOWN, 0);
assert_eq!(CHECK_PART_SUCCESS, 1);
assert_eq!(CHECK_PART_FILE_NOT_FOUND, 2);
assert_eq!(CHECK_PART_FILE_NOT_FOUND, 4); // 实际值是4,不是2
assert_eq!(CHECK_PART_VOLUME_NOT_FOUND, 3);
assert_eq!(CHECK_PART_FILE_NOT_FOUND, 4);
assert_eq!(CHECK_PART_FILE_CORRUPT, 5);
}
@@ -6026,7 +6025,7 @@ mod tests {
assert_eq!(conv_part_err_to_int(&Some(disk_err)), CHECK_PART_FILE_NOT_FOUND);
let other_err = DiskError::other("other error");
assert_eq!(conv_part_err_to_int(&Some(other_err)), CHECK_PART_SUCCESS);
assert_eq!(conv_part_err_to_int(&Some(other_err)), CHECK_PART_UNKNOWN); // other错误应该返回UNKNOWN,不是SUCCESS
}
#[test]
@@ -6099,8 +6098,14 @@ mod tests {
let errs = vec![None, Some(DiskError::other("error1")), Some(DiskError::other("error2"))];
let joined = join_errs(&errs);
assert!(joined.contains("<nil>"));
assert!(joined.contains("error1"));
assert!(joined.contains("error2"));
assert!(joined.contains("io error")); // DiskError::other 显示为 "io error"
// Test with different error types
let errs2 = vec![None, Some(DiskError::FileNotFound), Some(DiskError::FileCorrupt)];
let joined2 = join_errs(&errs2);
assert!(joined2.contains("<nil>"));
assert!(joined2.contains("file not found"));
assert!(joined2.contains("file is corrupted"));
}
#[test]