From 0163bfec4be74c263e4491f9c5c358432139998e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Miku=C5=82a?= Date: Wed, 12 Aug 2020 14:56:22 +0200 Subject: [PATCH] Make openssl-errors tests work on Windows --- openssl-errors/tests/test.rs | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/openssl-errors/tests/test.rs b/openssl-errors/tests/test.rs index 86dfc3b1..cb44cf92 100644 --- a/openssl-errors/tests/test.rs +++ b/openssl-errors/tests/test.rs @@ -22,7 +22,11 @@ fn basic() { assert_eq!(error.library().unwrap(), "test library"); assert_eq!(error.function().unwrap(), "function foo"); assert_eq!(error.reason().unwrap(), "out of milk"); - assert_eq!(error.file(), "openssl-errors/tests/test.rs"); + // Replace Windows `\` separators with `/` + assert_eq!( + error.file().replace(r"\", "/"), + "openssl-errors/tests/test.rs" + ); assert_eq!(error.line(), 19); assert_eq!(error.data(), None); } @@ -35,8 +39,12 @@ fn static_data() { assert_eq!(error.library().unwrap(), "test library"); assert_eq!(error.function().unwrap(), "function bar"); assert_eq!(error.reason().unwrap(), "out of bacon"); - assert_eq!(error.file(), "openssl-errors/tests/test.rs"); - assert_eq!(error.line(), 32); + // Replace Windows `\` separators with `/` + assert_eq!( + error.file().replace(r"\", "/"), + "openssl-errors/tests/test.rs" + ); + assert_eq!(error.line(), 36); assert_eq!(error.data(), Some("foobar")); } @@ -48,7 +56,11 @@ fn dynamic_data() { assert_eq!(error.library().unwrap(), "test library"); assert_eq!(error.function().unwrap(), "function bar"); assert_eq!(error.reason().unwrap(), "out of milk"); - assert_eq!(error.file(), "openssl-errors/tests/test.rs"); - assert_eq!(error.line(), 45); + // Replace Windows `\` separators with `/` + assert_eq!( + error.file().replace(r"\", "/"), + "openssl-errors/tests/test.rs" + ); + assert_eq!(error.line(), 53); assert_eq!(error.data(), Some("hello world")); }