{"id":2810,"url":"https://patchwork.libcamera.org/api/1.1/patches/2810/?format=json","web_url":"https://patchwork.libcamera.org/patch/2810/","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":"<20200213130908.23638-3-kieran.bingham@ideasonboard.com>","date":"2020-02-13T13:09:07","name":"[libcamera-devel,2/3] test: Add a utils::split() test","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"b34189e87a13915bb910e186fab3f607b396c5a6","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/1.1/people/4/?format=json","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/2810/mbox/","series":[{"id":670,"url":"https://patchwork.libcamera.org/api/1.1/series/670/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=670","date":"2020-02-13T13:09:05","name":"utils: Provide string splitting","version":1,"mbox":"https://patchwork.libcamera.org/series/670/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/2810/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/2810/checks/","tags":{},"headers":{"Return-Path":"<kieran.bingham@ideasonboard.com>","Received":["from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 5578061958\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 13 Feb 2020 14:09:13 +0100 (CET)","from localhost.localdomain\n\t(cpc89242-aztw30-2-0-cust488.18-1.cable.virginm.net [86.31.129.233])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id ED81C504;\n\tThu, 13 Feb 2020 14:09:12 +0100 (CET)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1581599353;\n\tbh=xhgeLtquKj+d/2LPChJ3bUCfAhA8plkueBEKBN0yHl8=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=TAK+zfqTBg8IpZiMwivyt1/r6vOzLvebGlkvB+rwiVgP7F16G7t4Y1m6ys3wcF20c\n\tZmBLRHtAlxXeeJFvlO7G344R/YHoK1L1rpXyw+d6TFk45RwjfvEvtwG8YsOGZOnOEI\n\tSJzqc8lMvJUFRQoeuFh0D5IBBEauMujSPctchlcQ=","From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","To":"libcamera devel <libcamera-devel@lists.libcamera.org>","Date":"Thu, 13 Feb 2020 13:09:07 +0000","Message-Id":"<20200213130908.23638-3-kieran.bingham@ideasonboard.com>","X-Mailer":"git-send-email 2.20.1","In-Reply-To":"<20200213130908.23638-1-kieran.bingham@ideasonboard.com>","References":"<20200213130908.23638-1-kieran.bingham@ideasonboard.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH 2/3] test: Add a utils::split() test","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>","X-List-Received-Date":"Thu, 13 Feb 2020 13:09:13 -0000"},"content":"From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\nThe test constructs a string by joining substrings, splits it, and\nverifies that the original and resulting substrings match.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n test/utils.cpp | 25 +++++++++++++++++++++++++\n 1 file changed, 25 insertions(+)","diff":"diff --git a/test/utils.cpp b/test/utils.cpp\nindex 9fe0d4775b73..db1fbdde847d 100644\n--- a/test/utils.cpp\n+++ b/test/utils.cpp\n@@ -7,6 +7,8 @@\n \n #include <iostream>\n #include <sstream>\n+#include <string>\n+#include <vector>\n \n #include \"test.h\"\n #include \"utils.h\"\n@@ -19,6 +21,7 @@ class UtilsTest : public Test\n protected:\n \tint run()\n \t{\n+\t\t/* utils::hex() test. */\n \t\tstd::ostringstream os;\n \t\tstd::string ref;\n \n@@ -46,6 +49,28 @@ protected:\n \t\t\treturn TestFail;\n \t\t}\n \n+\t\t/* utils::split() test. */\n+\t\tstd::vector<std::string> elements = {\n+\t\t\t\"/bin\",\n+\t\t\t\"/usr/bin\",\n+\t\t\t\"\",\n+\t\t\t\"\",\n+\t\t};\n+\n+\t\tstd::string path;\n+\t\tfor (const auto &element : elements)\n+\t\t\tpath += (path.empty() ? \"\" : \":\") + element;\n+\n+\t\tstd::vector<std::string> dirs;\n+\n+\t\tfor (const auto &dir : utils::split(path, \":\"))\n+\t\t\tdirs.push_back(dir);\n+\n+\t\tif (dirs != elements) {\n+\t\t\tcerr << \"utils::split() test failed\" << endl;\n+\t\t\treturn TestFail;\n+\t\t}\n+\n \t\treturn TestPass;\n \t}\n };\n","prefixes":["libcamera-devel","2/3"]}