#[macro_use] extern crate glsl_linalg; use glsl_linalg::{M2, M3, M4, V2, V3, V4}; #[test] fn vec2() { assert_eq!(V2([2.0, 2.0]), vec2!(2.0)); assert_eq!(V2([1.0, 2.0]), vec2!(1.0, 2.0)); assert_eq!(V2([3, 4]), vec2!(3, 4)); assert_eq!(V2([3, 4]), vec2!(V2([3, 4]))); assert_eq!(V2([3, 4]), vec2!(vec2!(3, 4))); } #[test] fn vec3() { assert_eq!(V3([2.0, 2.0, 2.0]), vec3!(2.0)); assert_eq!(V3([1.0, 2.0, 3.0]), vec3!(1.0, 2.0, 3.0)); assert_eq!(V3([3, 4, 5]), vec3!(3, 4, 5)); assert_eq!(V3([3, 4, 5]), vec3!(3, vec2!(4, 5))); assert_eq!(V3([3, 4, 5]), vec3!(vec2!(3, 4), 5)); assert_eq!(V3([3, 4, 5]), vec3!(vec2!(3, 4), 5)); } #[test] fn vec4() { assert_eq!(V4([2.0, 2.0, 2.0, 2.0]), vec4!(2.0)); assert_eq!(V4([1.0, 2.0, 3.0, 4.0]), vec4!(1.0, 2.0, 3.0, 4.0)); assert_eq!(V4([3, 4, 5, 6]), vec4!(3, 4, 5, 6)); assert_eq!(V4([3, 4, 5, 6]), vec4!(3, 4, vec2!(5, 6))); assert_eq!(V4([3, 4, 5, 6]), vec4!(3, vec2!(4, 5), 6)); assert_eq!(V4([3, 4, 5, 6]), vec4!(vec2!(3, 4), 5, 6)); assert_eq!(V4([3, 4, 5, 6]), vec4!(vec2!(3, 4), vec2!(5, 6))); assert_eq!(V4([3, 4, 5, 6]), vec4!(3, vec3!(4, vec2!(5, 6)))); assert_eq!(V4([3, 4, 5, 6]), vec4!(vec3!(3, 4, 5), 6)); } #[test] fn mat2() { assert_eq!(M2([[1.0, 1.0], [1.0, 1.0]]), mat2!(1.0)); assert_eq!(M2([[1.0, 2.0], [3.0, 4.0]]), mat2!(1.0, 2.0, 3.0, 4.0)); assert_eq!( M2([[1.0, 2.0], [3.0, 4.0]]), mat2!(vec2!(1.0, 2.0); vec2!(3.0, 4.0)) ); assert_eq!( M2([[1.0, 2.0], [3.0, 4.0]]), mat2!(1.0, 2.0; vec2!(3.0, 4.0)) ); assert_eq!( M2([[1.0, 2.0], [3.0, 4.0]]), mat2!(vec2!(1.0, 2.0); 3.0, 4.0) ); } #[test] fn mat3() { assert_eq!( M3([[1.0, 1.0, 1.0], [1.0, 1.0, 1.0], [1.0, 1.0, 1.0]]), mat3!(1.0) ); assert_eq!( M3([[1.0, 2.0, 3.0], [4.0, 5.0, 6.0], [7.0, 8.0, 9.0]]), mat3!(1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0) ); assert_eq!( M3([[1.0, 2.0, 3.0], [4.0, 5.0, 6.0], [7.0, 8.0, 9.0]]), mat3!(1.0, 2.0, 3.0; 4.0, 5.0, 6.0; 7.0, 8.0, 9.0) ); assert_eq!( M3([[1.0, 2.0, 3.0], [4.0, 5.0, 6.0], [7.0, 8.0, 9.0]]), mat3!(1.0, 2.0, 3.0; 4.0, 5.0, 6.0; 7.0, 8.0, 9.0) ); assert_eq!( M3([[1.0, 2.0, 3.0], [4.0, 5.0, 6.0], [7.0, 8.0, 9.0]]), mat3!(vec3!(1.0, 2.0, 3.0); 4.0, 5.0, 6.0; 7.0, 8.0, 9.0) ); assert_eq!( M3([[1.0, 2.0, 3.0], [4.0, 5.0, 6.0], [7.0, 8.0, 9.0]]), mat3!(1.0, 2.0, 3.0;vec3!(4.0, 5.0, 6.0); 7.0, 8.0, 9.0) ); assert_eq!( M3([[1.0, 2.0, 3.0], [4.0, 5.0, 6.0], [7.0, 8.0, 9.0]]), mat3!(1.0, 2.0, 3.0; 4.0, 5.0, 6.0; vec3!(7.0, 8.0, 9.0)) ); assert_eq!( M3([[1.0, 2.0, 3.0], [4.0, 5.0, 6.0], [7.0, 8.0, 9.0]]), mat3!(vec3!(1.0, 2.0, 3.0); 4.0, 5.0, 6.0; vec3!(7.0, 8.0, 9.0)) ); assert_eq!( M3([[1.0, 2.0, 3.0], [4.0, 5.0, 6.0], [7.0, 8.0, 9.0]]), mat3!(1.0, 2.0, 3.0; vec3!(4.0, 5.0, 6.0); vec3!(7.0, 8.0, 9.0)) ); assert_eq!( M3([[1.0, 2.0, 3.0], [4.0, 5.0, 6.0], [7.0, 8.0, 9.0]]), mat3!(vec3!(1.0, 2.0, 3.0); vec3!(4.0, 5.0, 6.0); 7.0, 8.0, 9.0) ); assert_eq!( M3([[1.0, 2.0, 3.0], [4.0, 5.0, 6.0], [7.0, 8.0, 9.0]]), mat3!(vec3!(1.0, 2.0, 3.0); vec3!(4.0, 5.0, 6.0); vec3!(7.0, 8.0, 9.0)) ); } #[test] fn mat4() { assert_eq!( M4([ [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0] ]), mat4!(1.0) ); assert_eq!( M4([ [1.0, 2.0, 3.0, 4.0], [5.0, 6.0, 7.0, 8.0], [9.0, 10.0, 11.0, 12.0], [13.0, 14.0, 15.0, 16.0] ]), mat4!( 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ) ); assert_eq!( M4([ [1.0, 2.0, 3.0, 4.0], [5.0, 6.0, 7.0, 8.0], [9.0, 10.0, 11.0, 12.0], [13.0, 14.0, 15.0, 16.0] ]), mat4!( 1.0, 2.0, 3.0, 4.0; 5.0, 6.0, 7.0, 8.0; 9.0, 10.0, 11.0, 12.0; 13.0, 14.0, 15.0, 16.0 ) ); assert_eq!( M4([ [1.0, 2.0, 3.0, 4.0], [5.0, 6.0, 7.0, 8.0], [9.0, 10.0, 11.0, 12.0], [13.0, 14.0, 15.0, 16.0] ]), mat4!(vec4!(1.0, 2.0, 3.0, 4.0); vec2!(5.0, 6.0), 7.0, 8.0; 9.0, vec3!(10.0, 11.0, 12.0); vec2!(13.0, 14.0), vec2!(15.0, 16.0)) ); }