From fcaf938e8cb69fddc904246981760549c7b40c56 Mon Sep 17 00:00:00 2001 From: Nicolas Dufresne Date: Fri, 16 Nov 2018 23:51:44 -0500 Subject: [PATCH] tests: video: Test video format enum stability It is really easy to break the API and insert a new video format in the middle of the enum instead of at the end. This minimal test should catch the most obvious errors. Ideally, this test should be updated after new format have been added, so that it won't allow further modification to the enumeration API. --- tests/check/libs/video.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tests/check/libs/video.c b/tests/check/libs/video.c index 9a1eb6d84b..81828a6adc 100644 --- a/tests/check/libs/video.c +++ b/tests/check/libs/video.c @@ -2942,6 +2942,16 @@ GST_START_TEST (test_overlay_composition_over_transparency) GST_END_TEST; +GST_START_TEST (test_video_format_enum_stability) +{ + /* When adding new formats, adding a format in the middle of the enum will + * break the API. This check picks the last known format and checks that + * it's value isn't changing. This test should ideall be updated when a new + * format is added, though will stay valid. */ + fail_unless_equals_int (GST_VIDEO_FORMAT_Y210, 82); +} + +GST_END_TEST; static Suite * video_suite (void) @@ -2982,6 +2992,7 @@ video_suite (void) tcase_add_test (tc_chain, test_overlay_blend); tcase_add_test (tc_chain, test_video_center_rect); tcase_add_test (tc_chain, test_overlay_composition_over_transparency); + tcase_add_test (tc_chain, test_video_format_enum_stability); return s; }