Skip to content

Commit

Permalink
Fix an issue where features were not working
Browse files Browse the repository at this point in the history
  • Loading branch information
HK416 committed Jul 17, 2024
1 parent 6edf9b4 commit ad8d619
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "gmm"
version = "0.2.0"
version = "0.2.1"
edition = "2021"
rust-version = "1.76"
authors = ["HK416 <powerspirit127@gmail.com>"]
Expand Down
43 changes: 43 additions & 0 deletions src/features/impl_bytemuck.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,46 @@ unsafe impl Pod for UInteger4 {}
unsafe impl Zeroable for UInteger4 {}

// TODO: Add test function...
#[cfg(test)]
mod tests {
use core::mem;
use crate::{
Boolean2, Boolean3, Boolean4,
Float2, Float3, Float3x3, Float4, Float4x4,
Integer2, Integer3, Integer4, UInteger2, UInteger3, UInteger4
};

macro_rules! test_pod_impl {
($name:ident, $t:ty) => {
#[test]
fn $name() {
let t = <$t>::default();
let bytes = bytemuck::bytes_of(&t);
for byte in bytes {
assert_eq!(byte, byte);
}

assert_eq!(&t as *const _ as usize, bytes.as_ptr() as usize);
assert_eq!(bytes.len(), mem::size_of_val(&t));
}
}
}

test_pod_impl!(impl_bytemuck_boolean2, Boolean2);
test_pod_impl!(impl_bytemuck_boolean3, Boolean3);
test_pod_impl!(impl_bytemuck_boolean4, Boolean4);

test_pod_impl!(impl_bytemuck_float2, Float2);
test_pod_impl!(impl_bytemuck_float3, Float3);
test_pod_impl!(impl_bytemuck_float4, Float4);
test_pod_impl!(impl_bytemuck_float3x3, Float3x3);
test_pod_impl!(impl_bytemuck_float4x4, Float4x4);

test_pod_impl!(impl_bytemuck_integer2, Integer2);
test_pod_impl!(impl_bytemuck_integer3, Integer3);
test_pod_impl!(impl_bytemuck_integer4, Integer4);

test_pod_impl!(impl_bytemuck_uinteger2, UInteger2);
test_pod_impl!(impl_bytemuck_uinteger3, UInteger3);
test_pod_impl!(impl_bytemuck_uinteger4, UInteger4);
}
4 changes: 2 additions & 2 deletions src/features/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#[cfg(features = "bytemuck")]
#[cfg(feature = "bytemuck")]
pub mod impl_bytemuck;

#[cfg(features = "mint")]
#[cfg(feature = "mint")]
pub mod impl_mint;

0 comments on commit ad8d619

Please sign in to comment.