File size: 2,340 Bytes
985c397 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 | #include <gtest/gtest.h>
#include <Base/Axis.h>
#include <Base/Placement.h>
#include <Base/Rotation.h>
#include <src/App/InitApplication.h>
class Axis: public ::testing::Test
{
protected:
static void SetUpTestSuite()
{
tests::initApplication();
}
};
TEST_F(Axis, TestDefault)
{
Base::Axis axis;
EXPECT_EQ(axis.getBase(), Base::Vector3d());
EXPECT_EQ(axis.getDirection(), Base::Vector3d());
}
TEST_F(Axis, TestCustom)
{
Base::Axis axis(Base::Vector3d(0, 0, 1), Base::Vector3d(1, 1, 1));
EXPECT_EQ(axis.getBase(), Base::Vector3d(0, 0, 1));
EXPECT_EQ(axis.getDirection(), Base::Vector3d(1, 1, 1));
}
TEST_F(Axis, TestSetter)
{
Base::Axis axis;
axis.setBase(Base::Vector3d(0, 0, 1));
axis.setDirection(Base::Vector3d(1, 1, 1));
EXPECT_EQ(axis.getBase(), Base::Vector3d(0, 0, 1));
EXPECT_EQ(axis.getDirection(), Base::Vector3d(1, 1, 1));
}
TEST_F(Axis, TestAssign)
{
Base::Axis axis;
Base::Axis move;
axis.setBase(Base::Vector3d(0, 0, 1));
axis.setDirection(Base::Vector3d(1, 1, 1));
move = std::move(axis); // NOLINT
EXPECT_EQ(move.getBase(), Base::Vector3d(0, 0, 1));
EXPECT_EQ(move.getDirection(), Base::Vector3d(1, 1, 1));
}
TEST_F(Axis, TestReverse)
{
Base::Axis axis(Base::Vector3d(0, 0, 1), Base::Vector3d(1, 1, 1));
axis.reverse();
EXPECT_EQ(axis.getBase(), Base::Vector3d(0, 0, 1));
EXPECT_EQ(axis.getDirection(), Base::Vector3d(-1, -1, -1));
}
TEST_F(Axis, TestReversed)
{
Base::Axis axis(Base::Vector3d(0, 0, 1), Base::Vector3d(1, 1, 1));
Base::Axis rev(axis.reversed());
EXPECT_EQ(axis.getDirection(), Base::Vector3d(1, 1, 1));
EXPECT_EQ(rev.getBase(), Base::Vector3d(0, 0, 1));
EXPECT_EQ(rev.getDirection(), Base::Vector3d(-1, -1, -1));
}
TEST_F(Axis, TestMove)
{
Base::Axis axis(Base::Vector3d(0, 0, 1), Base::Vector3d(1, 1, 1));
axis.move(Base::Vector3d(1, 2, 3));
EXPECT_EQ(axis.getBase(), Base::Vector3d(1, 2, 4));
EXPECT_EQ(axis.getDirection(), Base::Vector3d(1, 1, 1));
}
TEST_F(Axis, TestMult)
{
Base::Axis axis(Base::Vector3d(0, 0, 1), Base::Vector3d(0, 0, 1));
axis *= Base::Placement(Base::Vector3d(1, 1, 1), Base::Rotation(1, 0, 0, 0));
EXPECT_EQ(axis.getBase(), Base::Vector3d(1, 1, 0));
EXPECT_EQ(axis.getDirection(), Base::Vector3d(0, 0, -1));
}
|