Implement binary operators.

This also has the benefical side effect of ridding me of that
stupid VWR_STATIC_CAST_RESULTS macro.
This commit is contained in:
King_DuckZ 2016-11-08 02:24:21 +01:00
parent 6bf3278631
commit 2f4d319675
5 changed files with 87 additions and 58 deletions

View file

@ -1,7 +1,7 @@
#include "sample_vectors.hpp"
#include <gtest/gtest.h>
TEST(vwr, operators) {
TEST(vwr, cmp_operators) {
using namespace vwr;
{
@ -42,3 +42,43 @@ TEST(vwr, operators) {
EXPECT_GE(b, a);
}
}
TEST(vwr, bin_operators) {
using namespace vwr;
{
ivec3 a(0xFF, 0xAB, 0x10CE);
ivec3 b(0x45, 0xEE, 0x8);
ivec3 res(0xFF + 0x45, 0xAB + 0xEE, 0x10CE + 0x8);
EXPECT_EQ(res, a + b);
}
{
ivec3 a(0xFF, 0xAB, 0x10CE);
ivec3 b(0xC0, 0x0, 0xA);
ivec3 res(0xFF - 0xC0, 0xAB - 0x0, 0x10CE - 0xA);
EXPECT_EQ(res, a - b);
}
{
ivec3 a(0xFF, 0xAB, 0x10CE);
ivec3 b(0x3, 0x2, 0x1);
ivec3 res(0xFF * 0x3, 0xAB * 0x2, 0x10CE * 0x1);
EXPECT_EQ(res, a * b);
}
{
ivec3 a(0xFF, 0xAB, 0x10CE);
ivec3 b(0x3, 0x2, 0x1);
ivec3 res(0xFF / 0x3, 0xAB / 0x2, 0x10CE / 0x1);
EXPECT_EQ(res, a / b);
}
{
ivec3 a(0xE9, 0x104A, 0x28FF);
ivec3 b(0x15, 0x20, 0x1000);
ivec3 res(0xE9 % 0x15, 0x104A % 0x20, 0x28FF % 0x1000);
EXPECT_EQ(res, a % b);
}
}