Show a patch.

GET /api/1.1/patches/21292/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 21292,
    "url": "https://patchwork.libcamera.org/api/1.1/patches/21292/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/21292/",
    "project": {
        "id": 1,
        "url": "https://patchwork.libcamera.org/api/1.1/projects/1/?format=api",
        "name": "libcamera",
        "link_name": "libcamera",
        "list_id": "libcamera_core",
        "list_email": "libcamera-devel@lists.libcamera.org",
        "web_url": "",
        "scm_url": "",
        "webscm_url": ""
    },
    "msgid": "<20240920132823.88433-2-stefan.klug@ideasonboard.com>",
    "date": "2024-09-20T13:28:08",
    "name": "[v3,1/3] libcamera: yaml-parser: Add additional tests",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "cb60808745f7e20dd8f16bd434f713ffee187b43",
    "submitter": {
        "id": 184,
        "url": "https://patchwork.libcamera.org/api/1.1/people/184/?format=api",
        "name": "Stefan Klug",
        "email": "stefan.klug@ideasonboard.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/21292/mbox/",
    "series": [
        {
            "id": 4608,
            "url": "https://patchwork.libcamera.org/api/1.1/series/4608/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=4608",
            "date": "2024-09-20T13:28:07",
            "name": "libcamera: yaml-parser: Differentiate between empty and empty string",
            "version": 3,
            "mbox": "https://patchwork.libcamera.org/series/4608/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/21292/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/21292/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 B59CEC3261\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 20 Sep 2024 13:28:46 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 1707D63500;\n\tFri, 20 Sep 2024 15:28:46 +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 DCEE4634F5\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 20 Sep 2024 15:28:42 +0200 (CEST)",
            "from ideasonboard.com (unknown\n\t[IPv6:2a00:6020:448c:6c00:8ade:938d:48b1:cede])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 9FF944CE;\n\tFri, 20 Sep 2024 15:27:18 +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=\"eJ5foGW6\"; dkim-atps=neutral",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1726838838;\n\tbh=h2lcxPISNbay1MKWBI2eR/F203N3ahbcK6b0XGWIGLc=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=eJ5foGW6ykieKOXLJjgLTq2bF0G8r1X1UdWxDYghPg2BRZ1oxVXBqfRg6Kofx1GUx\n\tTUWSS7CLVhkR75AqMaXofzgH8eZHNTVUfDqDE8Nb47mg3QGP+mxF57x+BXLl6tZMho\n\tzHmTDg5yrFgyLzg/5/uIkxsZhsrXjqOkVwOvpYk4=",
        "From": "Stefan Klug <stefan.klug@ideasonboard.com>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Cc": "Stefan Klug <stefan.klug@ideasonboard.com>",
        "Subject": "[PATCH v3 1/3] libcamera: yaml-parser: Add additional tests",
        "Date": "Fri, 20 Sep 2024 15:28:08 +0200",
        "Message-ID": "<20240920132823.88433-2-stefan.klug@ideasonboard.com>",
        "X-Mailer": "git-send-email 2.43.0",
        "In-Reply-To": "<20240920132823.88433-1-stefan.klug@ideasonboard.com>",
        "References": "<20240920132823.88433-1-stefan.klug@ideasonboard.com>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "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>",
        "Errors-To": "libcamera-devel-bounces@lists.libcamera.org",
        "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"
    },
    "content": "Add additional tests in preparation for upcoming modifications on the\nyaml parser. These tests handle the case where the yaml file contains\nempty items in dictionaries or lists. E.g.:\n\ndict:\n  key_with_value: value\n  key_without_value:\n\nSigned-off-by: Stefan Klug <stefan.klug@ideasonboard.com>\n\n---\n\nIn the end it turned out that the changes on the YamlParser were never\nwrong, so these tests are somewhat superfluous. We could still merge\nthem to test specifically for that case or drop the patch.\n\nChanges in v3:\n- Added seperate patch for the working tests\n---\n test/yaml-parser.cpp | 28 +++++++++++++++++++++++++---\n 1 file changed, 25 insertions(+), 3 deletions(-)",
    "diff": "diff --git a/test/yaml-parser.cpp b/test/yaml-parser.cpp\nindex 81c829834667..347999831d61 100644\n--- a/test/yaml-parser.cpp\n+++ b/test/yaml-parser.cpp\n@@ -34,10 +34,12 @@ static const string testYaml =\n \t\"list:\\n\"\n \t\"  - James\\n\"\n \t\"  - Mary\\n\"\n+\t\"  - \\n\"\n \t\"dictionary:\\n\"\n \t\"  a: 1\\n\"\n \t\"  c: 3\\n\"\n \t\"  b: 2\\n\"\n+\t\"  empty:\\n\"\n \t\"level1:\\n\"\n \t\"  level2:\\n\"\n \t\"    - [1, 2]\\n\"\n@@ -430,9 +432,10 @@ protected:\n \t\tif (testObjectType(listObj, \"list\", Type::List) != TestPass)\n \t\t\treturn TestFail;\n \n-\t\tstatic constexpr std::array<const char *, 2> listValues{\n+\t\tstatic constexpr std::array<const char *, 3> listValues{\n \t\t\t\"James\",\n \t\t\t\"Mary\",\n+\t\t\t\"\",\n \t\t};\n \n \t\tif (listObj.size() != listValues.size()) {\n@@ -465,16 +468,23 @@ protected:\n \t\t\ti++;\n \t\t}\n \n+\t\t/* Ensure that empty objects get parsed as empty strings. */\n+\t\tif (!listObj[2].isValue()) {\n+\t\t\tcerr << \"Empty object is not a value\" << std::endl;\n+\t\t\treturn TestFail;\n+\t\t}\n+\n \t\t/* Test dictionary object */\n \t\tauto &dictObj = (*root)[\"dictionary\"];\n \n \t\tif (testObjectType(dictObj, \"dictionary\", Type::Dictionary) != TestPass)\n \t\t\treturn TestFail;\n \n-\t\tstatic constexpr std::array<std::pair<const char *, int>, 3> dictValues{ {\n+\t\tstatic constexpr std::array<std::pair<const char *, int>, 4> dictValues{ {\n \t\t\t{ \"a\", 1 },\n \t\t\t{ \"c\", 3 },\n \t\t\t{ \"b\", 2 },\n+\t\t\t{ \"empty\", -100 },\n \t\t} };\n \n \t\tsize_t dictSize = dictValues.size();\n@@ -505,7 +515,7 @@ protected:\n \t\t\t\treturn TestFail;\n \t\t\t}\n \n-\t\t\tif (elem.get<int32_t>(0) != item.second) {\n+\t\t\tif (elem.get<int32_t>(-100) != item.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@@ -514,6 +524,18 @@ protected:\n \t\t\ti++;\n \t\t}\n \n+\t\t/* Ensure that empty objects get parsed as empty strings. */\n+\t\tif (!dictObj[\"empty\"].isValue()) {\n+\t\t\tcerr << \"Empty object is not of type value\" << std::endl;\n+\t\t\treturn TestFail;\n+\t\t}\n+\n+\t\t/* Ensure that keys without values are added to a dict. */\n+\t\tif (!dictObj.contains(\"empty\")) {\n+\t\t\tcerr << \"Empty element is missing in dict\" << std::endl;\n+\t\t\treturn TestFail;\n+\t\t}\n+\n \t\t/* Make sure utils::map_keys() works on the adapter. */\n \t\t(void)utils::map_keys(dictObj.asDict());\n \n",
    "prefixes": [
        "v3",
        "1/3"
    ]
}