# This is a combination of 2 commits.

# This is the 1st commit message:

Coordinate: Add std::pair constructor

# This is the commit message #2:

Fix std::pair member types
This commit is contained in:
FeRD (Frank Dana)
2020-12-04 11:27:18 -05:00
parent d6892dd3af
commit de9fb417da
3 changed files with 10 additions and 3 deletions

View File

@@ -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<int, int>& co)
Coordinate::Coordinate(const std::pair<double, double>& co)
: X(co.first), Y(co.second) {};
// Generate JSON string of this object

View File

@@ -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<int, int> tuple containing (X, Y)
Coordinate(const std::pair<int, int>& co);
/// @param co A std::pair<double, double> tuple containing (X, Y)
Coordinate(const std::pair<double, double>& co);
/// Get and Set JSON methods
std::string Json() const; ///< Generate JSON string of this object

View File

@@ -57,6 +57,13 @@ TEST(X_Y_Constructor)
CHECK_CLOSE(8.0f, c1.Y, 0.00001);
}
TEST(Pair_Constructor)
{
Coordinate c1(std::pair<double,double>(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);