2013-09-12 23:41:49 -05:00
|
|
|
/**
|
|
|
|
|
* @file
|
|
|
|
|
* @brief Unit tests for openshot::Coordinate
|
|
|
|
|
* @author Jonathan Thomas <jonathan@openshot.org>
|
|
|
|
|
*
|
2019-06-09 08:31:04 -04:00
|
|
|
* @ref License
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/* LICENSE
|
2013-09-12 23:41:49 -05:00
|
|
|
*
|
2019-06-11 06:48:32 -04:00
|
|
|
* Copyright (c) 2008-2019 OpenShot Studios, LLC
|
2014-03-29 18:49:22 -05:00
|
|
|
* <http://www.openshotstudios.com/>. This file is part of
|
|
|
|
|
* OpenShot Library (libopenshot), an open-source project dedicated to
|
|
|
|
|
* delivering high quality video editing and animation solutions to the
|
|
|
|
|
* world. For more information visit <http://www.openshot.org/>.
|
2013-09-12 23:41:49 -05:00
|
|
|
*
|
2014-03-29 18:49:22 -05:00
|
|
|
* OpenShot Library (libopenshot) is free software: you can redistribute it
|
2014-07-11 16:52:14 -05:00
|
|
|
* and/or modify it under the terms of the GNU Lesser General Public License
|
2014-03-29 18:49:22 -05:00
|
|
|
* as published by the Free Software Foundation, either version 3 of the
|
|
|
|
|
* License, or (at your option) any later version.
|
2013-09-12 23:41:49 -05:00
|
|
|
*
|
2014-03-29 18:49:22 -05:00
|
|
|
* OpenShot Library (libopenshot) 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
|
2014-07-11 16:52:14 -05:00
|
|
|
* GNU Lesser General Public License for more details.
|
2013-09-12 23:41:49 -05:00
|
|
|
*
|
2014-07-11 16:52:14 -05:00
|
|
|
* You should have received a copy of the GNU Lesser General Public License
|
2014-03-29 18:49:22 -05:00
|
|
|
* along with OpenShot Library. If not, see <http://www.gnu.org/licenses/>.
|
2013-09-12 23:41:49 -05:00
|
|
|
*/
|
|
|
|
|
|
2011-10-11 08:44:27 -05:00
|
|
|
#include "UnitTest++.h"
|
2019-10-27 03:54:36 -04:00
|
|
|
// Prevent name clashes with juce::UnitTest
|
|
|
|
|
#define DONT_SET_USING_JUCE_NAMESPACE 1
|
2020-12-26 21:51:24 -05:00
|
|
|
#include "Coordinate.h"
|
2021-01-27 05:48:53 -05:00
|
|
|
#include "Exceptions.h"
|
2011-10-11 08:44:27 -05:00
|
|
|
|
|
|
|
|
using namespace openshot;
|
|
|
|
|
|
2020-11-21 16:07:27 -05:00
|
|
|
SUITE(Coordinate)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
TEST(Default_Constructor)
|
2011-10-11 08:44:27 -05:00
|
|
|
{
|
|
|
|
|
// Create an empty coordinate
|
|
|
|
|
Coordinate c1;
|
|
|
|
|
|
|
|
|
|
CHECK_CLOSE(0.0f, c1.X, 0.00001);
|
|
|
|
|
CHECK_CLOSE(0.0f, c1.Y, 0.00001);
|
|
|
|
|
}
|
|
|
|
|
|
2020-11-21 16:07:27 -05:00
|
|
|
TEST(X_Y_Constructor)
|
2011-10-11 08:44:27 -05:00
|
|
|
{
|
|
|
|
|
// Create an empty coordinate
|
|
|
|
|
Coordinate c1(2,8);
|
|
|
|
|
|
|
|
|
|
CHECK_CLOSE(2.0f, c1.X, 0.00001);
|
|
|
|
|
CHECK_CLOSE(8.0f, c1.Y, 0.00001);
|
|
|
|
|
}
|
2020-11-21 16:07:27 -05:00
|
|
|
|
2020-12-04 11:27:18 -05:00
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
|
2020-11-21 16:07:27 -05:00
|
|
|
TEST(Json)
|
|
|
|
|
{
|
|
|
|
|
openshot::Coordinate c(100, 200);
|
|
|
|
|
openshot::Coordinate c1;
|
|
|
|
|
c1.X = 100;
|
|
|
|
|
c1.Y = 200;
|
|
|
|
|
// Check that JSON produced is identical
|
|
|
|
|
auto j = c.Json();
|
|
|
|
|
auto j1 = c1.Json();
|
|
|
|
|
CHECK_EQUAL(j, j1);
|
|
|
|
|
// Check Json::Value representation
|
|
|
|
|
auto jv = c.JsonValue();
|
|
|
|
|
auto jv_string = jv.toStyledString();
|
|
|
|
|
CHECK_EQUAL(jv_string, j1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST(SetJson) {
|
|
|
|
|
// Construct our input Json representation
|
|
|
|
|
const std::string json_input = R"json(
|
|
|
|
|
{
|
|
|
|
|
"X": 100.0,
|
|
|
|
|
"Y": 50.0
|
|
|
|
|
}
|
|
|
|
|
)json";
|
|
|
|
|
openshot::Coordinate c;
|
|
|
|
|
CHECK_THROW(c.SetJson("}{"), openshot::InvalidJSON);
|
|
|
|
|
// Check that values set via SetJson() are correct
|
|
|
|
|
c.SetJson(json_input);
|
|
|
|
|
CHECK_CLOSE(100.0, c.X, 0.01);
|
|
|
|
|
CHECK_CLOSE(50.0, c.Y, 0.01);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // SUITE
|