From patchwork Wed Jul 27 02:38:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 16814 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 72EC2BE173 for ; Wed, 27 Jul 2022 02:38:23 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 37DAA6331B; Wed, 27 Jul 2022 04:38:23 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1658889503; bh=MQkQfVXMW4E5zqC4m/MSSc5M0uv0lRmko8CSTsQgS8o=; 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=3gf56X+50duFgpEeRGZB05ktj+6Dgls0ERvfdi2cv/m99kehrV1cRLsUs+kZELQ0s yJiGqR3Ny5cM/Wcp52Tw8XOy3S6APla63Gbc0S6M+fSRwAQC4zhnPbA40sJJoz9hkp fWvkYrGSy9k7pOjw9Gyfx8fAU+TAKJ61DSzTunHuMHb6l5aRNGuWJbvjQk1IL8uXUn WPAfB8XwQWKwtmUlt3ieGa31+jcqQiaYfc5jn6T+GOpVXgm83XA1H8jTi5CHMDruIb u3toHEHKhcty5SeBQRLZfFholRq0KkufkUvhGXWcV8eS8K19S5NTeYanE/+LBOTrWg +55tNgM5EQUkA== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 5A979603E8 for ; Wed, 27 Jul 2022 04:38:20 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="VeabkQSs"; dkim-atps=neutral Received: from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id E344C56D; Wed, 27 Jul 2022 04:38:19 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1658889500; bh=MQkQfVXMW4E5zqC4m/MSSc5M0uv0lRmko8CSTsQgS8o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VeabkQSsN1pn6hvTX7e0Rdw86HuEesquh3efRTu4vAf6QNJZtcCBM7kxdmi3aIiKd g/Ab/rFP5+DoHcaoJM6JnjTGjHXYy073vThsmUfdH/duaLs6RLGqbr42WTTCBTOZDH Zlh/Hi7O7c5arqglxs5/iAbnJX5ml6Um2vSATilU= To: libcamera-devel@lists.libcamera.org Date: Wed, 27 Jul 2022 05:38:04 +0300 Message-Id: <20220727023816.30008-3-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220727023816.30008-1-laurent.pinchart@ideasonboard.com> References: <20220727023816.30008-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v7 02/14] 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 Reviewed-by: Naushir Patuck Tested-by: Naushir Patuck --- 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 ebb654f2ef9c..782331764346 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" @@ -448,10 +448,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(); @@ -469,8 +469,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; @@ -482,17 +482,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++; }