From 5c2d615548dd27f23586e4fe5cfa8c6507635694 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20Kj=C3=A4ll?= Date: Mon, 27 Nov 2023 18:16:18 +0100 Subject: [PATCH 1/2] test size_of_sha1 reports wrong size on i386 --- gix-features/tests/hash.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/gix-features/tests/hash.rs b/gix-features/tests/hash.rs index c8e48da57e3..035e475ad47 100644 --- a/gix-features/tests/hash.rs +++ b/gix-features/tests/hash.rs @@ -6,7 +6,13 @@ fn size_of_sha1() { assert_eq!(std::mem::size_of::(), 96) } -#[cfg(feature = "fast-sha1")] +#[cfg(all(feature = "fast-sha1", target_arch = "x86"))] +#[test] +fn size_of_sha1() { + assert_eq!(std::mem::size_of::(), 96) +} + +#[cfg(all(feature = "fast-sha1", not(target_arch = "x86")))] #[test] fn size_of_sha1() { assert_eq!(std::mem::size_of::(), 104) From 1d45f056263ba9c69612abc81fdd3783f95de4ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20Kj=C3=A4ll?= Date: Mon, 27 Nov 2023 20:47:40 +0100 Subject: [PATCH 2/2] review feedback, use an 'if cfg' construct instead --- gix-features/tests/hash.rs | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/gix-features/tests/hash.rs b/gix-features/tests/hash.rs index 035e475ad47..ecc321bffa7 100644 --- a/gix-features/tests/hash.rs +++ b/gix-features/tests/hash.rs @@ -6,14 +6,8 @@ fn size_of_sha1() { assert_eq!(std::mem::size_of::(), 96) } -#[cfg(all(feature = "fast-sha1", target_arch = "x86"))] +#[cfg(feature = "fast-sha1")] #[test] fn size_of_sha1() { - assert_eq!(std::mem::size_of::(), 96) -} - -#[cfg(all(feature = "fast-sha1", not(target_arch = "x86")))] -#[test] -fn size_of_sha1() { - assert_eq!(std::mem::size_of::(), 104) + assert_eq!(std::mem::size_of::(), if cfg!(target_arch = "x86") { 96 } else { 104 }) }