#pragma region CPL License /* Nuclex Native Framework Copyright (C) 2002-2015 Nuclex Development Labs This library is free software; you can redistribute it and/or modify it under the terms of the IBM Common Public License as published by the IBM Corporation; either version 1.0 of the License, or (at your option) any later version. This library 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 IBM Common Public License for more details. You should have received a copy of the IBM Common Public License along with this library */ #pragma endregion // CPL License // If the library is compiled as a DLL, this ensures symbols are exported #define NUCLEX_GEOMETRY_SOURCE 1 #include "Nuclex/Geometry/Point2.h" #include namespace Nuclex { namespace Geometry { // ------------------------------------------------------------------------------------------- // TEST(MathTest, PiConstantIsProvided) { EXPECT_FLOAT_EQ(3.1415926535897932384626433832795f, Math::Pi); } // ------------------------------------------------------------------------------------------- // TEST(MathTest, PerigonConstantIsProvided) { EXPECT_FLOAT_EQ(Math::Pi * 2.0f, Math::Perigon); } // ------------------------------------------------------------------------------------------- // TEST(MathTest, SquareRootCanBeCalculated) { EXPECT_FLOAT_EQ(3.0f, Math::SquareRoot(9.0f)); } // ------------------------------------------------------------------------------------------- // TEST(MathTest, CanObtainMinimumOfTriad) { EXPECT_FLOAT_EQ(1.0f, Math::Min(1.0f, 2.0f, 3.0f)); EXPECT_FLOAT_EQ(1.0f, Math::Min(3.0f, 1.0f, 2.0f)); EXPECT_FLOAT_EQ(1.0f, Math::Min(2.0f, 3.0f, 1.0f)); } // ------------------------------------------------------------------------------------------- // TEST(MathTest, CanObtainMaximumOfTriad) { EXPECT_FLOAT_EQ(3.0f, Math::Max(1.0f, 2.0f, 3.0f)); EXPECT_FLOAT_EQ(3.0f, Math::Max(3.0f, 1.0f, 2.0f)); EXPECT_FLOAT_EQ(3.0f, Math::Max(2.0f, 3.0f, 1.0f)); } // ------------------------------------------------------------------------------------------- // TEST(MathTest, CanFindExtremesOfTriad) { std::pair expected = std::make_pair(1.0f, 3.0f); EXPECT_EQ(expected, Math::Extremes(1.0f, 2.0f, 3.0f)); EXPECT_EQ(expected, Math::Extremes(1.0f, 3.0f, 2.0f)); EXPECT_EQ(expected, Math::Extremes(2.0f, 1.0f, 3.0f)); EXPECT_EQ(expected, Math::Extremes(2.0f, 3.0f, 1.0f)); EXPECT_EQ(expected, Math::Extremes(3.0f, 1.0f, 2.0f)); EXPECT_EQ(expected, Math::Extremes(3.0f, 2.0f, 1.0f)); } // ------------------------------------------------------------------------------------------- // TEST(MathTest, CanUnwind) { EXPECT_FLOAT_EQ(-90.0f, Math::Unwind(270.0f, -180.0f, 180.0f)); EXPECT_FLOAT_EQ(90.0f, Math::Unwind(-270.0f, -180.0f, 180.0f)); EXPECT_FLOAT_EQ(0.0f, Math::Unwind(360.0f, -180.0f, 180.0f)); EXPECT_FLOAT_EQ(0.0f, Math::Unwind(-360.0f, -180.0f, 180.0f)); EXPECT_FLOAT_EQ(0.0f, Math::Unwind(0.0f, 0.0f, 360.0f)); EXPECT_FLOAT_EQ(0.0f, Math::Unwind(360.0f, 0.0f, 360.0f)); EXPECT_FLOAT_EQ(350.0f, Math::Unwind(-10.0f, 0.0f, 360.0f)); EXPECT_FLOAT_EQ(350.0f, Math::Unwind(-370.0f, 0.0f, 360.0f)); EXPECT_FLOAT_EQ(-350.0f, Math::Unwind(10.0f, -360.0f, 0.0f)); EXPECT_FLOAT_EQ(-350.0f, Math::Unwind(370.0f, -360.0f, 0.0f)); } // ------------------------------------------------------------------------------------------- // }} // namespace Nuclex::Geometry