{"id":16032,"url":"https://patchwork.libcamera.org/api/1.1/patches/16032/?format=json","web_url":"https://patchwork.libcamera.org/patch/16032/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/1.1/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20220524225816.6830-7-laurent.pinchart@ideasonboard.com>","date":"2022-05-24T22:58:10","name":"[libcamera-devel,RFC,06/12] test: yaml_parser: Extend tests to cover the iterator API","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"815161e74d27feecd9267543c6b26572970b0493","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/1.1/people/2/?format=json","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/16032/mbox/","series":[{"id":3135,"url":"https://patchwork.libcamera.org/api/1.1/series/3135/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=3135","date":"2022-05-24T22:58:04","name":"Replace boost JSON parser with libyaml in Raspberry Pi IPA","version":1,"mbox":"https://patchwork.libcamera.org/series/3135/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/16032/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/16032/checks/","tags":{},"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 14737BD161\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 24 May 2022 22:58:35 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id AAE3665672;\n\tWed, 25 May 2022 00:58:33 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 27C9B65663\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 25 May 2022 00:58:28 +0200 (CEST)","from pendragon.ideasonboard.com (ip-109-40-241-133.web.vodafone.de\n\t[109.40.241.133])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 865DB1224;\n\tWed, 25 May 2022 00:58:27 +0200 (CEST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1653433113;\n\tbh=yuzPcW09xN5jnjxLp9B1c60Gpp/d/NIaVzr7xlwAIT8=;\n\th=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:\n\tFrom;\n\tb=UYhFUdKiQGGXeEeO7xXKBeuyldzDPCpMrCYccGH0ArCPwV7SXtAVK/1ppsu1O2QcR\n\tB4fjjKsvRAYqG59UiWOT/9d+2a56VFAU21g5NMN0J4SXrzQa+N0ouPvpiS96wtdV9q\n\t//vi5AGi7pZ5CB+0jnshCnMZkVicpCBMhNP7K6QS9luKIpNVzPBEMSCglfjXMgK4ym\n\t2tWfzmY3jqOHVYQ75zm7j5x3zVa346F+xu3mNCWmC9xlqcwVz3J/Q2y4zobpBGjqjt\n\tN2yGGAgearMx86VdvfhMtvVQRrtZGgrd9ipQWLKUVUnZLuHM7xUYQFfXgKfyuoXnyh\n\tOJbHr+BUyDFyQ==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1653433107;\n\tbh=yuzPcW09xN5jnjxLp9B1c60Gpp/d/NIaVzr7xlwAIT8=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=jSk9RUyFQNjozcwhesKnzxVaETbxx5h6iNdlcSw3cpVQDdTwD1kNS0LSHxSlh93gv\n\t4x99X2f5kw6YcnYOeN+ogihohA0Km/O/OF1sm+JR2Ti5396Avwv6t3p+0geskbPF6L\n\toVtcSqj54YiicMOCWY4g/NyvkRg+LKkdY/wHFMOc="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"jSk9RUyF\"; dkim-atps=neutral","To":"libcamera-devel@lists.libcamera.org","Date":"Wed, 25 May 2022 01:58:10 +0300","Message-Id":"<20220524225816.6830-7-laurent.pinchart@ideasonboard.com>","X-Mailer":"git-send-email 2.35.1","In-Reply-To":"<20220524225816.6830-1-laurent.pinchart@ideasonboard.com>","References":"<20220524225816.6830-1-laurent.pinchart@ideasonboard.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [RFC PATCH 06/12] test: yaml_parser: Extend tests\n\tto cover the iterator API","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>","From":"Laurent Pinchart via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>","Reply-To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"Test iteration over lists and dictionaries to test the YamlObject\niterator API.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n test/yaml-parser.cpp | 88 ++++++++++++++++++++++++++++++++++----------\n 1 file changed, 69 insertions(+), 19 deletions(-)","diff":"diff --git a/test/yaml-parser.cpp b/test/yaml-parser.cpp\nindex 944b564bbe22..7ad9936bb82b 100644\n--- a/test/yaml-parser.cpp\n+++ b/test/yaml-parser.cpp\n@@ -5,6 +5,7 @@\n  * yaml-parser.cpp - YAML parser operations tests\n  */\n \n+#include <array>\n #include <iostream>\n #include <string>\n #include <unistd.h>\n@@ -372,15 +373,39 @@ protected:\n \t\t\treturn TestFail;\n \t\t}\n \n-\t\tif (listObj.size() > 2) {\n+\t\tstatic constexpr std::array<const char *, 2> listValues{\n+\t\t\t\"James\",\n+\t\t\t\"Mary\",\n+\t\t};\n+\n+\t\tif (listObj.size() != listValues.size()) {\n \t\t\tcerr << \"List object parse with wrong size\" << std::endl;\n \t\t\treturn TestFail;\n \t\t}\n \n-\t\tif (listObj[0].get<string>(\"\") != \"James\" ||\n-\t\t    listObj[1].get<string>(\"\") != \"Mary\") {\n-\t\t\tcerr << \"List object parse as wrong value\" << std::endl;\n-\t\t\treturn TestFail;\n+\t\tunsigned int i = 0;\n+\t\tfor (auto &elem : listObj.asList()) {\n+\t\t\tif (i >= listValues.size()) {\n+\t\t\t\tstd::cerr << \"Too many elements in list during iteration\"\n+\t\t\t\t\t  << std::endl;\n+\t\t\t\treturn TestFail;\n+\t\t\t}\n+\n+\t\t\tstd::string value = listValues[i];\n+\n+\t\t\tif (&elem != &listObj[i]) {\n+\t\t\t\tstd::cerr << \"List element \" << i << \" has wrong address\"\n+\t\t\t\t\t  << std::endl;\n+\t\t\t\treturn TestFail;\n+\t\t\t}\n+\n+\t\t\tif (elem.get<std::string>(\"\") != value) {\n+\t\t\t\tstd::cerr << \"List element \" << i << \" has wrong value\"\n+\t\t\t\t\t  << std::endl;\n+\t\t\t\treturn TestFail;\n+\t\t\t}\n+\n+\t\t\ti++;\n \t\t}\n \n \t\t/* Test dictionary object */\n@@ -421,19 +446,51 @@ protected:\n \t\t\treturn TestFail;\n \t\t}\n \n-\t\tif (dictObj.size() != 3) {\n-\t\t\tcerr << \"Dictionary object parse with wrong size\" << std::endl;\n+\t\tstatic constexpr std::array<std::pair<const char *, int>, 3> dictValues{ {\n+\t\t\t{ \"a\", 1 },\n+\t\t\t{ \"b\", 2 },\n+\t\t\t{ \"c\", 3 },\n+\t\t} };\n+\n+\t\tif (dictObj.size() != dictValues.size()) {\n+\t\t\tcerr << \"Dictionary object has wrong size\" << std::endl;\n \t\t\treturn TestFail;\n \t\t}\n \n+\t\ti = 0;\n+\t\tfor (const auto &[key, elem] : dictObj.asDict()) {\n+\t\t\tif (i >= dictValues.size()) {\n+\t\t\t\tstd::cerr << \"Too many elements in dictionary during iteration\"\n+\t\t\t\t\t  << std::endl;\n+\t\t\t\treturn TestFail;\n+\t\t\t}\n+\n+\t\t\tconst std::pair<const char *, int> &value = dictValues[i];\n+\n+\t\t\tif (key != value.first) {\n+\t\t\t\tstd::cerr << \"Dictionary key \" << i << \" has wrong value\"\n+\t\t\t\t\t  << std::endl;\n+\t\t\t\treturn TestFail;\n+\t\t\t}\n+\n+\t\t\tif (&elem != &dictObj[key]) {\n+\t\t\t\tstd::cerr << \"Dictionary element \" << i << \" has wrong address\"\n+\t\t\t\t\t  << std::endl;\n+\t\t\t\treturn TestFail;\n+\t\t\t}\n+\n+\t\t\tif (elem.get<int32_t>(0) != value.second) {\n+\t\t\t\tstd::cerr << \"Dictionary element \" << i << \" has wrong value\"\n+\t\t\t\t\t  << std::endl;\n+\t\t\t\treturn TestFail;\n+\t\t\t}\n+\n+\t\t\ti++;\n+\t\t}\n+\n \t\tauto memeberNames = dictObj.memberNames();\n \t\tsort(memeberNames.begin(), memeberNames.end());\n \n-\t\tif (memeberNames.size() != 3) {\n-\t\t\tcerr << \"Dictionary object fail to extra member names\" << std::endl;\n-\t\t\treturn TestFail;\n-\t\t}\n-\n \t\tif (memeberNames[0] != \"a\" ||\n \t\t    memeberNames[1] != \"b\" ||\n \t\t    memeberNames[2] != \"c\") {\n@@ -441,13 +498,6 @@ protected:\n \t\t\treturn TestFail;\n \t\t}\n \n-\t\tif (dictObj[\"a\"].get<int32_t>(0) != 1 ||\n-\t\t    dictObj[\"b\"].get<int32_t>(0) != 2 ||\n-\t\t    dictObj[\"c\"].get<int32_t>(0) != 3) {\n-\t\t\tcerr << \"Dictionary object fail to parse member value\" << std::endl;\n-\t\t\treturn TestFail;\n-\t\t}\n-\n \t\t/* Test leveled objects */\n \t\tauto &level1Obj = (*root)[\"level1\"];\n \n","prefixes":["libcamera-devel","RFC","06/12"]}