/*
 * Copyright 2015-2020 Michele "King_DuckZ" Santullo
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#include "vectorwrapper/vectorops.hpp"
#include "sample_vectors.hpp"
#include <gtest/gtest.h>

TEST(vwr, min) {
	using namespace vwr;

	{
		ivec3 a(1, 2, 3);
		ivec3 b(0, 4, 3);
		ivec3 c = min(a, b);
		EXPECT_EQ(0, c.x());
		EXPECT_EQ(2, c.y());
		EXPECT_EQ(3, c.z());
	}

	{
		ivec3 a(-2, -3, -4);
		ivec3 b(100);
		ivec3 c = min(a, b);
		EXPECT_EQ(-2, c.x());
		EXPECT_EQ(-3, c.y());
		EXPECT_EQ(-4, c.z());
	}

	{
		ivec3 a(100);
		ivec3 b(-1000, -1100, -1200);
		ivec3 c = min(a, b);
		EXPECT_EQ(-1000, c.x());
		EXPECT_EQ(-1100, c.y());
		EXPECT_EQ(-1200, c.z());
	}

	{
		ivec3 a(-20, 30, -40);
		ivec3 b(a);
		ivec3 c = min(a, b);
		EXPECT_EQ(-20, c.x());
		EXPECT_EQ(30, c.y());
		EXPECT_EQ(-40, c.z());
	}
}

TEST(vwr, max) {
	using namespace vwr;
	{
		ivec2 a(1, 2);
		ivec2 b(0, 4);
		ivec2 c = max(a, b);
		EXPECT_EQ(1, c.x());
		EXPECT_EQ(4, c.y());
	}

	{
		ivec3 a(2, 3, 4);
		ivec3 b(-100);
		ivec3 c = max(a, b);
		EXPECT_EQ(2, c.x());
		EXPECT_EQ(3, c.y());
		EXPECT_EQ(4, c.z());
	}

	{
		ivec3 a(-100);
		ivec3 b(1000, 1100, 1200);
		ivec3 c = max(a, b);
		EXPECT_EQ(1000, c.x());
		EXPECT_EQ(1100, c.y());
		EXPECT_EQ(1200, c.z());
	}

	{
		ivec3 a(20, -30, 40);
		ivec3 b(a);
		ivec3 c = max(a, b);
		EXPECT_EQ(20, c.x());
		EXPECT_EQ(-30, c.y());
		EXPECT_EQ(40, c.z());
	}
}
