Keyframe: Unit tests for new constructors

This commit is contained in:
FeRD (Frank Dana)
2020-12-04 11:24:01 -05:00
parent c9112bb08f
commit d0a625c9f2

View File

@@ -36,7 +36,9 @@
using namespace std;
using namespace openshot;
TEST(Keyframe_GetPoint_With_No_Points)
SUITE(Keyframe) {
TEST(GetPoint_With_No_Points)
{
// Create an empty keyframe
Keyframe k1;
@@ -44,7 +46,7 @@ TEST(Keyframe_GetPoint_With_No_Points)
CHECK_THROW(k1.GetPoint(0), OutOfBoundsPoint);
}
TEST(Keyframe_GetPoint_With_1_Points)
TEST(GetPoint_With_1_Points)
{
// Create an empty keyframe
Keyframe k1;
@@ -58,7 +60,7 @@ TEST(Keyframe_GetPoint_With_1_Points)
}
TEST(Keyframe_AddPoint_With_1_Point)
TEST(AddPoint_With_1_Point)
{
// Create an empty keyframe
Keyframe k1;
@@ -69,7 +71,7 @@ TEST(Keyframe_AddPoint_With_1_Point)
CHECK_THROW(k1.GetPoint(1), OutOfBoundsPoint);
}
TEST(Keyframe_AddPoint_With_2_Points)
TEST(AddPoint_With_2_Points)
{
// Create an empty keyframe
Keyframe k1;
@@ -82,7 +84,7 @@ TEST(Keyframe_AddPoint_With_2_Points)
CHECK_THROW(k1.GetPoint(2), OutOfBoundsPoint);
}
TEST(Keyframe_GetValue_For_Bezier_Curve_2_Points)
TEST(GetValue_For_Bezier_Curve_2_Points)
{
// Create a keyframe curve with 2 points
Keyframe kf;
@@ -101,7 +103,7 @@ TEST(Keyframe_GetValue_For_Bezier_Curve_2_Points)
CHECK_EQUAL(51, kf.GetLength());
}
TEST(Keyframe_GetValue_For_Bezier_Curve_5_Points_40_Percent_Handle)
TEST(GetValue_For_Bezier_Curve_5_Points_40_Percent_Handle)
{
// Create a keyframe curve with 2 points
Keyframe kf;
@@ -124,7 +126,7 @@ TEST(Keyframe_GetValue_For_Bezier_Curve_5_Points_40_Percent_Handle)
CHECK_EQUAL(201, kf.GetLength());
}
TEST(Keyframe_GetValue_For_Bezier_Curve_5_Points_25_Percent_Handle)
TEST(GetValue_For_Bezier_Curve_5_Points_25_Percent_Handle)
{
// Create a keyframe curve with 2 points
Keyframe kf;
@@ -147,7 +149,7 @@ TEST(Keyframe_GetValue_For_Bezier_Curve_5_Points_25_Percent_Handle)
CHECK_EQUAL(201, kf.GetLength());
}
TEST(Keyframe_GetValue_For_Linear_Curve_3_Points)
TEST(GetValue_For_Linear_Curve_3_Points)
{
// Create a keyframe curve with 2 points
Keyframe kf;
@@ -167,7 +169,7 @@ TEST(Keyframe_GetValue_For_Linear_Curve_3_Points)
CHECK_EQUAL(51, kf.GetLength());
}
TEST(Keyframe_GetValue_For_Constant_Curve_3_Points)
TEST(GetValue_For_Constant_Curve_3_Points)
{
// Create a keyframe curve with 2 points
Keyframe kf;
@@ -188,7 +190,7 @@ TEST(Keyframe_GetValue_For_Constant_Curve_3_Points)
CHECK_EQUAL(51, kf.GetLength());
}
TEST(Keyframe_Check_Direction_and_Repeat_Fractions)
TEST(Check_Direction_and_Repeat_Fractions)
{
// Create a keyframe curve with 2 points
Keyframe kf;
@@ -223,7 +225,7 @@ TEST(Keyframe_Check_Direction_and_Repeat_Fractions)
}
TEST(Keyframe_Get_Closest_Point)
TEST(Get_Closest_Point)
{
// Create a keyframe curve with 2 points
Keyframe kf;
@@ -251,7 +253,7 @@ TEST(Keyframe_Get_Closest_Point)
}
TEST(Keyframe_Get_Previous_Point)
TEST(Get_Previous_Point)
{
// Create a keyframe curve with 2 points
Keyframe kf;
@@ -270,7 +272,7 @@ TEST(Keyframe_Get_Previous_Point)
}
TEST(Keyframe_Get_Max_Point)
TEST(Get_Max_Point)
{
// Create a keyframe curve
Keyframe kf;
@@ -295,7 +297,7 @@ TEST(Keyframe_Get_Max_Point)
CHECK_EQUAL(2.0, kf.GetMaxPoint().co.Y);
}
TEST(Keyframe_Scale_Keyframe)
TEST(Scale_Keyframe)
{
// Create a keyframe curve with 2 points
Keyframe kf;
@@ -337,7 +339,7 @@ TEST(Keyframe_Scale_Keyframe)
}
TEST(Keyframe_Flip_Keyframe)
TEST(Flip_Keyframe)
{
// Create a keyframe curve with 2 points
Keyframe kf;
@@ -371,7 +373,7 @@ TEST(Keyframe_Flip_Keyframe)
CHECK_CLOSE(10.0f, kf.GetValue(100), 0.01);
}
TEST(Keyframe_Remove_Duplicate_Point)
TEST(Remove_Duplicate_Point)
{
// Create a keyframe curve with 2 points
Keyframe kf;
@@ -384,7 +386,7 @@ TEST(Keyframe_Remove_Duplicate_Point)
CHECK_CLOSE(2.0, kf.GetPoint(0).co.Y, 0.01);
}
TEST(Keyframe_Large_Number_Values)
TEST(Large_Number_Values)
{
// Large value
int64_t const large_value = 30 * 60 * 90;
@@ -400,7 +402,7 @@ TEST(Keyframe_Large_Number_Values)
CHECK_CLOSE(100.0, kf.GetPoint(1).co.Y, 0.01);
}
TEST(Keyframe_Remove_Point)
TEST(Remove_Point)
{
Keyframe kf;
kf.AddPoint(openshot::Point(Coordinate(1, 1), CONSTANT));
@@ -413,7 +415,7 @@ TEST(Keyframe_Remove_Point)
CHECK_THROW(kf.RemovePoint(100), OutOfBoundsPoint);
}
TEST(Keyframe_Constant_Interpolation_First_Segment)
TEST(Constant_Interpolation_First_Segment)
{
Keyframe kf;
kf.AddPoint(Point(Coordinate(1, 1), CONSTANT));
@@ -426,7 +428,7 @@ TEST(Keyframe_Constant_Interpolation_First_Segment)
CHECK_EQUAL(100, kf.GetInt(4));
}
TEST(Keyframe_isIncreasing)
TEST(isIncreasing)
{
// Which cases need to be tested to keep same behaviour as
// previously?
@@ -457,7 +459,7 @@ TEST(Keyframe_isIncreasing)
CHECK_EQUAL(true, kf.IsIncreasing(2));
}
TEST(Keyframe_GetLength)
TEST(GetLength)
{
Keyframe f;
CHECK_EQUAL(0, f.GetLength());
@@ -475,7 +477,7 @@ TEST(Keyframe_GetLength)
CHECK_EQUAL(201, g.GetLength());
}
TEST(Keyframe_Use_Interpolation_of_Segment_End_Point)
TEST(Use_Interpolation_of_Segment_End_Point)
{
Keyframe f;
f.AddPoint(1,0, CONSTANT);
@@ -483,7 +485,7 @@ TEST(Keyframe_Use_Interpolation_of_Segment_End_Point)
CHECK_CLOSE(75.9, f.GetValue(50), 0.1);
}
TEST(Keyframe_Handle_Large_Segment)
TEST(Handle_Large_Segment)
{
Keyframe kf;
kf.AddPoint(1, 0, CONSTANT);
@@ -494,3 +496,28 @@ TEST(Keyframe_Handle_Large_Segment)
Fraction fr = kf.GetRepeatFraction(250000);
CHECK_CLOSE(0.5, (double)fr.num / fr.den, 0.01);
}
TEST(Point_Vector_Constructor)
{
std::vector<Point> points{Point(1, 10), Point(5, 20), Point(10, 30)};
Keyframe k1(points);
CHECK_EQUAL(11, k1.GetLength());
CHECK_CLOSE(30.0f, k1.GetValue(10), 0.0001);
}
TEST(Pair_Vector_Constructor)
{
std::vector<std::pair<double,double>> coordinates{
{1, 100}, {10, 500}, {1000, 80000}
};
Keyframe k1(coordinates);
CHECK_EQUAL(1001, k1.GetLength());
auto p1 = k1.GetPoint(2);
CHECK_CLOSE(80000.0f, p1.co.Y, 0.00001);
}
}; // SUITE