diff --git a/src/Coordinate.cpp b/src/Coordinate.cpp index f8bc06069..6a4abb21f 100644 --- a/src/Coordinate.cpp +++ b/src/Coordinate.cpp @@ -40,7 +40,7 @@ Coordinate::Coordinate() : Coordinate::Coordinate(0, 0) {}; Coordinate::Coordinate(double x, double y) : X(x), Y(y) {}; // Constructor which accepts a std::pair for (X, Y) -Coordinate::Coordinate(const std::pair& co) +Coordinate::Coordinate(const std::pair& co) : X(co.first), Y(co.second) {}; // Generate JSON string of this object diff --git a/src/Coordinate.h b/src/Coordinate.h index 2417720b2..8a3ce97c2 100644 --- a/src/Coordinate.h +++ b/src/Coordinate.h @@ -64,8 +64,8 @@ namespace openshot { Coordinate(double x, double y); /// @brief Constructor which accepts a std::pair tuple for {X, Y} - /// @param co A std::pair tuple containing (X, Y) - Coordinate(const std::pair& co); + /// @param co A std::pair tuple containing (X, Y) + Coordinate(const std::pair& co); /// Get and Set JSON methods std::string Json() const; ///< Generate JSON string of this object diff --git a/tests/Coordinate_Tests.cpp b/tests/Coordinate_Tests.cpp index 731850de8..b0f8e6b96 100644 --- a/tests/Coordinate_Tests.cpp +++ b/tests/Coordinate_Tests.cpp @@ -57,6 +57,13 @@ TEST(X_Y_Constructor) CHECK_CLOSE(8.0f, c1.Y, 0.00001); } +TEST(Pair_Constructor) +{ + Coordinate c1(std::pair(12, 10)); + CHECK_CLOSE(12.0f, c1.X, 0.00001); + CHECK_CLOSE(10.0f, c1.Y, 0.00001); +} + TEST(Json) { openshot::Coordinate c(100, 200);