use crate::types::{Vector2,Vector3,Matrix3x4,Matrix4x2,Matrix3x2,Matrix2x3};

#[test]
fn test_bool(){
	assert_eq!(Vector3::new([false,false,false]).any(),false);
	assert_eq!(Vector3::new([false,false,true]).any(),true);
	assert_eq!(Vector3::new([false,false,true]).all(),false);
	assert_eq!(Vector3::new([true,true,true]).all(),true);
}

#[test]
fn test_length_squared(){
	assert_eq!(Vector3::new([1,2,3]).length_squared(),14);
}

#[test]
fn test_arithmetic(){
	let a=Vector3::new([1,2,3]);
	assert_eq!((a+a*2).array,Vector3::new([1*3,2*3,3*3]).array);
}

#[test]
fn matrix_transform_vector(){
	let m=Matrix2x3::new([
		[1,2,3],
		[4,5,6],
	]).transpose();
	let v=Vector3::new([1,2,3]);
	let transformed=m*v;
	assert_eq!(transformed.array,Vector2::new([14,32]).array);
}

#[test]
fn matrix_dot(){
	// All this code was written row major and I converted the lib to colum major
	let rhs=Matrix4x2::new([
								[  1.0,  2.0],
								[  3.0,  4.0],
								[  5.0,  6.0],
								[  7.0,  8.0],
	]).transpose();						 // |	  |		|
	let lhs=Matrix3x4::new([ // |	  |		|
		[1.0, 2.0, 3.0, 4.0],//	[ 50.0, 60.0],
		[5.0, 6.0, 7.0, 8.0],//	[114.0,140.0],
		[9.0,10.0,11.0,12.0],//	[178.0,220.0],
	]).transpose();
	// Mat3<Vec4>.dot(Mat4<Vec2>) -> Mat3<Vec2>
	let m_dot=lhs*rhs;
	//In[1]:= {{1, 2, 3, 4}, {5, 6, 7, 8}, {9, 10, 11, 12}} . {{1, 2}, {3, 4}, {5, 6}, {7, 8}}
	//Out[1]= {{50, 60}, {114, 140}, {178, 220}}
	assert_eq!(
		m_dot.array,
		Matrix3x2::new([
			[50.0,60.0],
			[114.0,140.0],
			[178.0,220.0],
		]).transpose().array
	);
}
