diff --git a/src/common/error/tests/ext.rs b/src/common/error/tests/ext.rs index 82f2ee4440..d22ad96a43 100644 --- a/src/common/error/tests/ext.rs +++ b/src/common/error/tests/ext.rs @@ -84,29 +84,32 @@ fn test_to_string() { assert_eq!(result.unwrap_err().to_string(), ""); } +fn normalize_path(s: &str) -> String { + s.replace('\\', "/") +} + #[test] fn test_debug_format() { let result = normal_error(); let debug_output = format!("{:?}", result.unwrap_err()); - let normalized_output = debug_output.replace('\\', "/"); + assert_eq!( - normalized_output, + normalize_path(&debug_output), format!( r#"0: A normal error with "display" attribute, message "blabla", at {}:55:22 1: PlainError {{ msg: "", status_code: Unexpected }}"#, - file!() + normalize_path(file!()) ) ); let result = transparent_error(); let debug_output = format!("{:?}", result.unwrap_err()); - let normalized_output = debug_output.replace('\\', "/"); assert_eq!( - normalized_output, + normalize_path(&debug_output), format!( r#"0: , at {}:60:5 1: PlainError {{ msg: "", status_code: Unexpected }}"#, - file!() + normalize_path(file!()) ) ); }