From 2fbab8b07748b790b5896c24a0aa09444ca48f97 Mon Sep 17 00:00:00 2001 From: Kaaira Gupta Date: Fri, 27 Mar 2020 01:44:00 +0530 Subject: libcamera: v4l2PixelFormat: Replace hex with fourCC Print fourCC characters instead of the hex value in toString() as they are more informative. Also, write the tests for this in formats.cpp Signed-off-by: Kaaira Gupta Reviewed-by: Kieran Bingham Reviewed-by: Laurent Pinchart Signed-off-by: Kieran Bingham --- test/v4l2_videodevice/formats.cpp | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'test/v4l2_videodevice') diff --git a/test/v4l2_videodevice/formats.cpp b/test/v4l2_videodevice/formats.cpp index d504d178..a7421421 100644 --- a/test/v4l2_videodevice/formats.cpp +++ b/test/v4l2_videodevice/formats.cpp @@ -8,6 +8,7 @@ #include #include +#include "utils.h" #include "v4l2_videodevice.h" #include "v4l2_videodevice_test.h" @@ -47,6 +48,28 @@ protected: return TestFail; } + std::vector> formats{ + { V4L2_PIX_FMT_YUYV, "YUYV" }, + { 0, "" }, + { v4l2_fourcc(0, 1, 2, 3), "...." }, + { V4L2_PIX_FMT_Y16_BE, "Y16 -BE" } + }; + + for (const auto &format : formats) { + if (V4L2PixelFormat(format.first).toString() != format.second) { + cerr << "Failed to convert V4L2PixelFormat" + << utils::hex(format.first) << "to string" + << endl; + return TestFail; + } + } + + if (V4L2PixelFormat().toString() != "") { + cerr << "Failed to convert default V4L2PixelFormat to string" + << endl; + return TestFail; + } + return TestPass; } }; -- cgit v1.2.1