/*
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at https://mozilla.org/MPL/2.0/.
 */

#include <catch2/catch_all.hpp>

#include "Math/DenseVector3i.hpp"

using namespace OpenVulkano::Math;

TEST_CASE("Constructor and Accessors", "[DenseVector3i]")
{
	Vector3i vec3 { 10, 20, 30 };
	DenseVector3i<int32_t> denseVec(vec3);

	REQUIRE(denseVec.X() == 10);
	REQUIRE(denseVec.Y() == 20);
	REQUIRE(denseVec.Z() == 30);

	auto data = denseVec.Data();
	REQUIRE(data != 0);
}

TEST_CASE("Setters", "[DenseVector3i]")
{
	DenseVector3i<int32_t> denseVec(10, 20, 30);

	denseVec.SetX(40);
	REQUIRE(denseVec.X() == 40);

	denseVec.SetY(50);
	REQUIRE(denseVec.Y() == 50);

	denseVec.SetZ(60);
	REQUIRE(denseVec.Z() == 60);
}

TEST_CASE("Comparison Operators", "[DenseVector3i]")
{
	DenseVector3i<int32_t> denseVec1(10, 20, 30);
	DenseVector3i<int32_t> denseVec2(10, 20, 30);
	DenseVector3i<int32_t> denseVec3(40, 50, 60);

	REQUIRE(denseVec1 == denseVec2);
	REQUIRE(denseVec1 != denseVec3);

	REQUIRE(denseVec1 < denseVec3);

	REQUIRE(denseVec3 > denseVec1);

	REQUIRE(denseVec1 <= denseVec2);
	REQUIRE(denseVec1 <= denseVec3);

	REQUIRE(denseVec1 >= denseVec2);
	REQUIRE(denseVec3 >= denseVec1);
}

TEST_CASE("ToString method", "[DenseVector3i]")
{
	DenseVector3i<int32_t> denseVec(10, 20, 30);
	REQUIRE(denseVec.ToString() == fmt::format("{},{},{}", 10, 20, 30));
	REQUIRE(denseVec.ToString(" ") == "10 20 30");
}

TEST_CASE("Type Conversion", "[DenseVector3i]")
{
	DenseVector3i<int32_t> denseVec(10, 20, 30);

	Vector3i vec3 = static_cast<Vector3i>(denseVec);
	REQUIRE(vec3.x == 10);
	REQUIRE(vec3.y == 20);
	REQUIRE(vec3.z == 30);

	Vector3i_SIMD vec3_simd = static_cast<Vector3i_SIMD>(denseVec);
	REQUIRE(vec3_simd.x == 10);
	REQUIRE(vec3_simd.y == 20);
	REQUIRE(vec3_simd.z == 30);
}