Message ID | 20210824195636.1110845-15-nfraprado@collabora.com |
---|---|
State | Superseded |
Headers | show |
Series |
|
Related | show |
On Tue, Aug 24, 2021 at 04:56:33PM -0300, Nícolas F. R. A. Prado wrote: > The functions that generate the test name based on the parameters need > to convert a StreamRole to a string. Move this to a separate function to > avoid redundancy. > > Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com> > Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Paul Elder <paul.elder@ideasonboard.com> > > --- > > Changes in v8: > - Made roleToString()'s map const and changed usage from [] operator to at() > > Changes in v5: > - New > > src/lc-compliance/capture_test.cpp | 23 ++++++++++++++--------- > 1 file changed, 14 insertions(+), 9 deletions(-) > > diff --git a/src/lc-compliance/capture_test.cpp b/src/lc-compliance/capture_test.cpp > index 49012048729e..40242fbbc0ba 100644 > --- a/src/lc-compliance/capture_test.cpp > +++ b/src/lc-compliance/capture_test.cpp > @@ -18,6 +18,18 @@ using namespace libcamera; > const std::vector<int> NUMREQUESTS = { 1, 2, 3, 5, 8, 13, 21, 34, 55, 89 }; > const std::vector<StreamRole> ROLES = { Raw, StillCapture, VideoRecording, Viewfinder }; > > +static const std::string &roleToString(const StreamRole &role) > +{ > + static const std::map<StreamRole, std::string> rolesMap = { > + { Raw, "Raw" }, > + { StillCapture, "StillCapture" }, > + { VideoRecording, "VideoRecording" }, > + { Viewfinder, "Viewfinder" } > + }; > + > + return rolesMap.at(role); > +} > + > class SingleStream : public testing::TestWithParam<std::tuple<StreamRole, int>>, public CameraHolder > { > public: > @@ -44,15 +56,8 @@ void SingleStream::TearDown() > > std::string SingleStream::nameParameters(const testing::TestParamInfo<SingleStream::ParamType> &info) > { > - std::map<StreamRole, std::string> rolesMap = { { Raw, "Raw" }, > - { StillCapture, "StillCapture" }, > - { VideoRecording, "VideoRecording" }, > - { Viewfinder, "Viewfinder" } }; > - > - std::string roleName = rolesMap[std::get<0>(info.param)]; > - std::string numRequestsName = std::to_string(std::get<1>(info.param)); > - > - return roleName + "_" + numRequestsName; > + return roleToString(std::get<0>(info.param)) + "_" + > + std::to_string(std::get<1>(info.param)); > } > > /* > -- > 2.33.0 >
diff --git a/src/lc-compliance/capture_test.cpp b/src/lc-compliance/capture_test.cpp index 49012048729e..40242fbbc0ba 100644 --- a/src/lc-compliance/capture_test.cpp +++ b/src/lc-compliance/capture_test.cpp @@ -18,6 +18,18 @@ using namespace libcamera; const std::vector<int> NUMREQUESTS = { 1, 2, 3, 5, 8, 13, 21, 34, 55, 89 }; const std::vector<StreamRole> ROLES = { Raw, StillCapture, VideoRecording, Viewfinder }; +static const std::string &roleToString(const StreamRole &role) +{ + static const std::map<StreamRole, std::string> rolesMap = { + { Raw, "Raw" }, + { StillCapture, "StillCapture" }, + { VideoRecording, "VideoRecording" }, + { Viewfinder, "Viewfinder" } + }; + + return rolesMap.at(role); +} + class SingleStream : public testing::TestWithParam<std::tuple<StreamRole, int>>, public CameraHolder { public: @@ -44,15 +56,8 @@ void SingleStream::TearDown() std::string SingleStream::nameParameters(const testing::TestParamInfo<SingleStream::ParamType> &info) { - std::map<StreamRole, std::string> rolesMap = { { Raw, "Raw" }, - { StillCapture, "StillCapture" }, - { VideoRecording, "VideoRecording" }, - { Viewfinder, "Viewfinder" } }; - - std::string roleName = rolesMap[std::get<0>(info.param)]; - std::string numRequestsName = std::to_string(std::get<1>(info.param)); - - return roleName + "_" + numRequestsName; + return roleToString(std::get<0>(info.param)) + "_" + + std::to_string(std::get<1>(info.param)); } /*