// =====================================================================================================================
//  fennec-test, a program to execute unit tests for fennec
//  Copyright © 2025 - 2026  Medusa Slockbower
//
//  This program is free software: you can redistribute it and/or modify
//  it under the terms of the GNU General Public License as published by
//  the Free Software Foundation, either version 3 of the License, or
//  (at your option) any later version.
//
//  This program is distributed in the hope that it will be useful,
//  but WITHOUT ANY WARRANTY; without even the implied warranty of
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//  GNU General Public License for more details.
//
//  You should have received a copy of the GNU General Public License
//  along with this program.  If not, see <https://www.gnu.org/licenses/>.
// =====================================================================================================================


#ifndef FENNEC_TEST_GEOMETRIC_H
#define FENNEC_TEST_GEOMETRIC_H

#include <fennec/math/geometric.h>
#include <fennec/math/trigonometric.h>

#include "../../test.h"

namespace fennec::test
{

	inline void fennec_test_math_geometric()
	{

		fennec_test_run(fennec::dot(vec2(1, 2),       vec2(1, 2)),       5.0f);
		fennec_test_run(fennec::dot(vec3(1, 2, 3),    vec3(1, 2, 3)),    14.0f);
		fennec_test_run(fennec::dot(vec4(1, 2, 3, 4), vec4(1, 2, 3, 4)), 30.0f);

		fennec_test_spacer(1);

		fennec_test_run(fennec::length2(vec2(1, 2)      ), 5.0f);
		fennec_test_run(fennec::length2(vec3(1, 2, 3)   ), 14.0f);
		fennec_test_run(fennec::length2(vec4(1, 2, 3, 4)), 30.0f);

		fennec_test_spacer(1);

		fennec_test_run(fennec::length(vec2(1, 2)      ), sqrt(5.0f));
		fennec_test_run(fennec::length(vec3(1, 2, 3)   ), sqrt(14.0f));
		fennec_test_run(fennec::length(vec4(1, 2, 3, 4)), sqrt(30.0f));

		fennec_test_spacer(1);

		fennec_test_run(fennec::distance(vec2(1, 2),       vec2(2, 1)),       sqrt(2.0f));
		fennec_test_run(fennec::distance(vec3(1, 2, 3),    vec3(3, 2, 1)),    sqrt(8.0f));
		fennec_test_run(fennec::distance(vec4(1, 2, 3, 4), vec4(4, 3, 2, 1)), sqrt(20.0f));

		fennec_test_spacer(1);

		fennec_test_run(fennec::cross(vec3(1, 0, 0), vec3(0, 1, 0)), vec3(0, 0, 1));
		fennec_test_run(fennec::cross(vec3(0, 1, 0), vec3(0, 0, 1)), vec3(1, 0, 0));
		fennec_test_run(fennec::cross(vec3(0, 0, 1), vec3(1, 0, 0)), vec3(0, 1, 0));

		fennec_test_spacer(1);

		fennec_test_run(fennec::normalize(vec2(1, 1)),       vec2(sqrt(2.0f) / 2.0f, sqrt(2.0f) / 2.0f));
		fennec_test_run(fennec::normalize(vec3(1, 1, 1)),    vec3(sqrt(3.0f) / 3.0f, sqrt(3.0f) / 3.0f, sqrt(3.0f) / 3.0f));
		fennec_test_run(fennec::normalize(vec4(1, 1, 1, 1)), vec4(0.5f, 0.5f, 0.5f, 0.5f));

		fennec_test_spacer(1);

		fennec_test_run(fennec::faceforward(vec3(1, 0, 0), vec3(-1, 0, 0), vec3(1, 0, 0)),  vec3(-1, 0, 0));
		fennec_test_run(fennec::faceforward(vec3(1, 0, 0), vec3(-1, 0, 0), vec3(-1, 0, 0)), vec3( 1, 0, 0));

		fennec_test_spacer(1);

		fennec_test_run(fennec::reflect(vec2(1, -1), vec2(0, 1)), vec2(1, 1));
		fennec_test_run(fennec::refract(vec2(1, -1), vec2(0, 1), 1/1.33f), vec2(0.7518797, -1));
	}

}


#endif // FENNEC_TEST_GEOMETRIC_H
