From patchwork Thu Jun 16 15:05:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 16245 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 12632C3273 for ; Thu, 16 Jun 2022 15:05:53 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id E8B5165638; Thu, 16 Jun 2022 17:05:51 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1655391951; bh=g9RCsvd/j89k9yRTVP8zmBiokpMe5cM4JFkmkynKt1M=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=Fp3/5xt4Fypob7lqKtjgcmlZ0MAvpIx8nHJ/3O0fPEy7ZKGFn83mpPGw8UokdmtlU gdiLD7Per3X2Y0LTU6FPSXGfZ6GwyvEomhkusNbCUg4rl/AXFgpsjX8jTR+i+tOxBs 8YFTr4TPBLp5cd5b7Cjl/BRypU3AXy07RIQNo8AhsPoTbvc/aejrbUNUfuX/lwIH7T lRWslRPvMeN1/8c6fh85YJwgV6AWzxxPnvyOLKj/6Igs1ZE2FOcOUR6njfFIPmesVt VWBQLwMw+//YJyUggsZTW4MreJ8IF4HzBSWZbWvjuHB8BtL7l3wLR69t0uq4FXFFvK jU26BVOHje4IQ== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id B87F8600F0 for ; Thu, 16 Jun 2022 17:05:49 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="KzbcyI0W"; dkim-atps=neutral Received: from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 2C9B7898; Thu, 16 Jun 2022 17:05:49 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1655391949; bh=g9RCsvd/j89k9yRTVP8zmBiokpMe5cM4JFkmkynKt1M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KzbcyI0W5UrL157oUXUcKInHn1p764jOiYyD5i0rPTeMMWleJCUIU0uc47CMSIM26 8W6WKm5gsDJGDt+2XT8X2n7LJdjPLUzv6t3n5J8yYQE1NHwtSadEAtXPRMH0SujQP0 wqbbJY0C4otcF4X3jp3Pl26H8IZNKpPNZrnhNX/k= To: libcamera-devel@lists.libcamera.org Date: Thu, 16 Jun 2022 18:05:32 +0300 Message-Id: <20220616150535.21742-2-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220616150535.21742-1-laurent.pinchart@ideasonboard.com> References: <20220616150535.21742-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [RFC PATCH v3 1/4] test: yaml-parser: Test dictionary items ordering X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Laurent Pinchart via libcamera-devel From: Laurent Pinchart Reply-To: Laurent Pinchart Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" While YAML specifies that mappings are unordered, the Raspberry Pi IPA relies on elements being ordered as in the YAML data. To replace the dependency on boost with the YamlParser class, we thus need to guarantee that the order is preserved. Update the corresponding unit test to ensure this. The test currently fails at the YamlParser doesn't correctly preserve the order, this will be fixed by the next commit. This commit should be reverted when the Raspberry Pi IPA updates to a new tuning data format and drops support for the old format. Signed-off-by: Laurent Pinchart --- test/yaml-parser.cpp | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/test/yaml-parser.cpp b/test/yaml-parser.cpp index 38f848232fa6..157ecea256cd 100644 --- a/test/yaml-parser.cpp +++ b/test/yaml-parser.cpp @@ -32,8 +32,8 @@ static const string testYaml = " - Mary\n" "dictionary:\n" " a: 1\n" - " b: 2\n" " c: 3\n" + " b: 2\n" "level1:\n" " level2:\n" " - [1, 2]\n" @@ -449,10 +449,10 @@ protected: return TestFail; } - std::map dictValues{ { + static constexpr std::array, 3> dictValues{ { { "a", 1 }, - { "b", 2 }, { "c", 3 }, + { "b", 2 }, } }; size_t dictSize = dictValues.size(); @@ -470,8 +470,8 @@ protected: return TestFail; } - const auto item = dictValues.find(key); - if (item == dictValues.end()) { + const auto &item = dictValues[i]; + if (item.first != key) { std::cerr << "Dictionary key " << i << " has wrong value" << std::endl; return TestFail; @@ -483,17 +483,12 @@ protected: return TestFail; } - if (elem.get(0) != item->second) { + if (elem.get(0) != item.second) { std::cerr << "Dictionary element " << i << " has wrong value" << std::endl; return TestFail; } - /* - * Erase the item to make sure that each iteration - * produces a different value. - */ - dictValues.erase(item); i++; }