[{"id":18455,"web_url":"https://patchwork.libcamera.org/comment/18455/","msgid":"<YQcLeqc7Jg01pxmu@pendragon.ideasonboard.com>","date":"2021-08-01T21:00:42","subject":"Re: [libcamera-devel] [PATCH v7 06/11] lc-compliance: Move role to\n\tstring conversion to its own function","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Nícolas,\n\nThank you for the patch.\n\nOn Thu, Jul 22, 2021 at 08:28:46PM -0300, Nícolas F. R. A. Prado wrote:\n> The functions that generate the test name based on the parameters need\n> to convert a StreamRole to a string. Move this to a separate function to\n> avoid redundancy.\n> \n> Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>\n> ---\n> \n> No changes in v7\n> \n> No changes in v6\n> \n> Added in v5\n> \n>  src/lc-compliance/capture_test.cpp | 21 ++++++++++++---------\n>  1 file changed, 12 insertions(+), 9 deletions(-)\n> \n> diff --git a/src/lc-compliance/capture_test.cpp b/src/lc-compliance/capture_test.cpp\n> index 949407d3191e..b4807486ee07 100644\n> --- a/src/lc-compliance/capture_test.cpp\n> +++ b/src/lc-compliance/capture_test.cpp\n> @@ -18,6 +18,16 @@ using namespace libcamera;\n>  const std::vector<int> NUMREQUESTS = { 1, 2, 3, 5, 8, 13, 21, 34, 55, 89 };\n>  const std::vector<StreamRole> ROLES = { Raw, StillCapture, VideoRecording, Viewfinder };\n>  \n> +static const std::string &roleToString(const StreamRole &role)\n> +{\n> +\tstatic std::map<StreamRole, std::string> rolesMap = { { Raw, \"Raw\" },\n> +\t\t\t\t\t\t\t      { StillCapture, \"StillCapture\" },\n> +\t\t\t\t\t\t\t      { VideoRecording, \"VideoRecording\" },\n> +\t\t\t\t\t\t\t      { Viewfinder, \"Viewfinder\" } };\n\nThis should be const. I'd write it as\n\n\tstatic const std::map<StreamRole, std::string> rolesMap = {\n\t\t{ Raw, \"Raw\" },\n\t\t{ StillCapture, \"StillCapture\" },\n\t\t{ VideoRecording, \"VideoRecording\" },\n\t\t{ Viewfinder, \"Viewfinder\" },\n\t};\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\n> +\n> +\treturn rolesMap[role];\n> +}\n> +\n>  class CameraHolder\n>  {\n>  protected:\n> @@ -71,15 +81,8 @@ void SingleStream::TearDown()\n>  \n>  std::string SingleStream::nameParameters(const testing::TestParamInfo<SingleStream::ParamType> &info)\n>  {\n> -\tstd::map<StreamRole, std::string> rolesMap = { { Raw, \"Raw\" },\n> -\t\t\t\t\t\t       { StillCapture, \"StillCapture\" },\n> -\t\t\t\t\t\t       { VideoRecording, \"VideoRecording\" },\n> -\t\t\t\t\t\t       { Viewfinder, \"Viewfinder\" } };\n> -\n> -\tstd::string roleName = rolesMap[std::get<0>(info.param)];\n> -\tstd::string numRequestsName = std::to_string(std::get<1>(info.param));\n> -\n> -\treturn roleName + \"_\" + numRequestsName;\n> +\treturn roleToString(std::get<0>(info.param)) + \"_\" +\n> +\t       std::to_string(std::get<1>(info.param));\n>  }\n>  \n>  /*","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 76103C3232\n\tfor <parsemail@patchwork.libcamera.org>;\n\tSun,  1 Aug 2021 21:00:54 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 962F2687BF;\n\tSun,  1 Aug 2021 23:00:53 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 398D5687B6\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSun,  1 Aug 2021 23:00:52 +0200 (CEST)","from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi\n\t[62.78.145.57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id AC21C87C;\n\tSun,  1 Aug 2021 23:00:51 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"K6H/hYP3\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1627851651;\n\tbh=wm3Zucr5QLOIPx5Q7XVRaW2OdZIZJAi6NjBiMmgVnYE=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=K6H/hYP3EHlPfZlsUbYwytXdgRV8xfUSClcOlsFc2yoHofklb/0MfjtQVMqaM5mME\n\t0bBfvlR+oQ3SZ9RhA6+HzJcdZNHNPExbGU1+lJ4eK8Ups4IIKsHw6Rc+rmn+sASeAD\n\tWijxhozQeHWY2TWjIAz5HKVtzVLIPu+jUKnTRpKI=","Date":"Mon, 2 Aug 2021 00:00:42 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"=?utf-8?b?TsOtY29sYXMgRi4gUi4gQS4=?= Prado <nfraprado@collabora.com>","Message-ID":"<YQcLeqc7Jg01pxmu@pendragon.ideasonboard.com>","References":"<20210722232851.747614-1-nfraprado@collabora.com>\n\t<20210722232851.747614-7-nfraprado@collabora.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","Content-Transfer-Encoding":"8bit","In-Reply-To":"<20210722232851.747614-7-nfraprado@collabora.com>","Subject":"Re: [libcamera-devel] [PATCH v7 06/11] lc-compliance: Move role to\n\tstring conversion to its own function","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Cc":"libcamera-devel@lists.libcamera.org, kernel@collabora.com, =?utf-8?q?A?=\n\t=?utf-8?b?bmRyw6k=?= Almeida <andrealmeid@collabora.com>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]