{"id":2920,"url":"https://patchwork.libcamera.org/api/1.1/patches/2920/?format=json","web_url":"https://patchwork.libcamera.org/patch/2920/","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":"<20200229164254.23604-3-laurent.pinchart@ideasonboard.com>","date":"2020-02-29T16:42:25","name":"[libcamera-devel,02/31] test: Add Span test","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"1d5bb785a733f63eb813fc45d92bd8c4df953d5c","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/2920/mbox/","series":[{"id":696,"url":"https://patchwork.libcamera.org/api/1.1/series/696/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=696","date":"2020-02-29T16:42:23","name":"libcamera: Add support for array controls","version":1,"mbox":"https://patchwork.libcamera.org/series/696/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/2920/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/2920/checks/","tags":{},"headers":{"Return-Path":"<laurent.pinchart@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 D06BE62689\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat, 29 Feb 2020 17:43:22 +0100 (CET)","from pendragon.bb.dnainternet.fi (81-175-216-236.bb.dnainternet.fi\n\t[81.175.216.236])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 7652933E\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat, 29 Feb 2020 17:43:22 +0100 (CET)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1582994602;\n\tbh=rTG5uiSgCf8ZncXT5gLvo4lI/pqVJpXttlHniz78ehs=;\n\th=From:To:Subject:Date:In-Reply-To:References:From;\n\tb=eSvLIPQzpuC9M6S6uSDoXhnoBIJZYq4GTNZs0XELKRloZLx2l7L10MILEIwH7WuY0\n\tWk/kZDYfidDNd/oTEUwm47xqou/lCDKwBoWXV2GV9ZnHVao7pRbhtdPLPLowiRg5iG\n\te1GsAcqHaZmdouD2Nezm/MmnDMGiK9MV/GAX8394=","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"libcamera-devel@lists.libcamera.org","Date":"Sat, 29 Feb 2020 18:42:25 +0200","Message-Id":"<20200229164254.23604-3-laurent.pinchart@ideasonboard.com>","X-Mailer":"git-send-email 2.24.1","In-Reply-To":"<20200229164254.23604-1-laurent.pinchart@ideasonboard.com>","References":"<20200229164254.23604-1-laurent.pinchart@ideasonboard.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH 02/31] test: Add Span 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":"Sat, 29 Feb 2020 16:43:23 -0000"},"content":"Add a compile-only test that exercises the whole Span API, as template\nfunctions are not fully compile-tested when the file is parsed.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n test/meson.build |   1 +\n test/span.cpp    | 177 +++++++++++++++++++++++++++++++++++++++++++++++\n 2 files changed, 178 insertions(+)\n create mode 100644 test/span.cpp","diff":"diff --git a/test/meson.build b/test/meson.build\nindex daaa1aac926d..92be382bfe41 100644\n--- a/test/meson.build\n+++ b/test/meson.build\n@@ -30,6 +30,7 @@ internal_tests = [\n     ['object',                          'object.cpp'],\n     ['object-invoke',                   'object-invoke.cpp'],\n     ['signal-threads',                  'signal-threads.cpp'],\n+    ['span',                            'span.cpp'],\n     ['threads',                         'threads.cpp'],\n     ['timer',                           'timer.cpp'],\n     ['timer-thread',                    'timer-thread.cpp'],\ndiff --git a/test/span.cpp b/test/span.cpp\nnew file mode 100644\nindex 000000000000..609749f51b86\n--- /dev/null\n+++ b/test/span.cpp\n@@ -0,0 +1,177 @@\n+/* SPDX-License-Identifier: GPL-2.0-or-later */\n+/*\n+ * Copyright (C) 2020, Google Inc.\n+ *\n+ * span.cpp - Span tests\n+ */\n+\n+#include <array>\n+#include <iostream>\n+#include <vector>\n+\n+#include <libcamera/span.h>\n+\n+#include \"test.h\"\n+\n+using namespace std;\n+using namespace libcamera;\n+\n+class SpanTest : public Test\n+{\n+protected:\n+\tint run()\n+\t{\n+\t\tint i[4]{ 1, 2, 3, 4 };\n+\t\tstd::array<int, 4> a{ 1, 2, 3, 4 };\n+\t\tconst std::array<int, 4> ca{ 1, 2, 3, 4 };\n+\t\tstd::vector<int> v{ 1, 2, 3, 4 };\n+\t\tconst std::vector<int> cv{ 1, 2, 3, 4 };\n+\n+\t\t/*\n+\t\t * Compile-test construction and usage of spans with static\n+\t\t * extent. Commented-out tests are expected not to compile, or\n+\t\t * to generate undefined behaviour.\n+\t\t */\n+\n+\t\tSpan<int, 0>{};\n+\t\t/* Span<int, 4>{}; */\n+\n+\t\tSpan<int, 4>{ &i[0], 4 };\n+\t\tSpan<int, 4>{ &i[0], &i[3] };\n+\n+\t\tSpan<int, 4>{ i };\n+\t\t/* Span<float, 4>{ i }; */\n+\t\t/* Span<int, 2>{ i }; */\n+\n+\t\tSpan<int, 4>{ a };\n+\t\tSpan<const int, 4>{ a };\n+\t\t/* Span<float, 4>{ a }; */\n+\t\t/* Span<int, 2>{ a }; */\n+\n+\t\tSpan<const int, 4>{ ca };\n+\t\t/* Span<const int, 2>{ ca }; */\n+\t\t/* Span<const float, 4>{ ca }; */\n+\t\t/* Span<int, 4>{ ca }; */\n+\n+\t\tSpan<int, 4>{ v };\n+\t\tSpan<const int, 4>{ v };\n+\t\t/* Span<float, 4>{ v }; */\n+\n+\t\tSpan<const int, 4>{ v };\n+\t\t/* Span<int, 4>{ v }; */\n+\t\t/* Span<const float, 4>{ v }; */\n+\n+\t\tSpan<int, 4> staticSpan{ i };\n+\t\tSpan<int, 4>{ staticSpan };\n+\t\tSpan<const int, 4>{ staticSpan };\n+\t\t/* Span<const int, 2>{ staticSpan }; */\n+\n+\t\tstaticSpan = Span<int, 4>{ v };\n+\n+\t\tstaticSpan.begin();\n+\t\tstaticSpan.cbegin();\n+\t\tstaticSpan.end();\n+\t\tstaticSpan.cend();\n+\t\tstaticSpan.rbegin();\n+\t\tstaticSpan.crbegin();\n+\t\tstaticSpan.rend();\n+\t\tstaticSpan.crend();\n+\n+\t\tstaticSpan.front();\n+\t\tstaticSpan.back();\n+\t\tstaticSpan[0];\n+\t\tstaticSpan.data();\n+\n+\t\tstaticSpan.size();\n+\t\tstaticSpan.size_bytes();\n+\n+\t\tstaticSpan.empty();\n+\n+\t\tstaticSpan.first<2>();\n+\t\tstaticSpan.first(2);\n+\t\t/* staticSpan.first<6>(); */\n+\t\t/* staticSpan.first(6); */\n+\t\tstaticSpan.last<2>();\n+\t\tstaticSpan.last(2);\n+\t\t/* staticSpan.last<6>(); */\n+\t\t/* staticSpan.last(6); */\n+\t\tstaticSpan.subspan<1>();\n+\t\tstaticSpan.subspan<1, 2>();\n+\t\tstaticSpan.subspan(1);\n+\t\tstaticSpan.subspan(1, 2);\n+\t\t/* staticSpan.subspan(2, 4); */\n+\n+\t\t/*\n+\t\t * Compile-test construction and usage of spans with static\n+\t\t * extent. Commented-out tests are expected not to compile, or\n+\t\t * to generate undefined behaviour.\n+\t\t */\n+\n+\t\tSpan<int>{};\n+\n+\t\tSpan<int>{ &i[0], 4 };\n+\t\tSpan<int>{ &i[0], &i[3] };\n+\n+\t\tSpan<int>{ i };\n+\t\t/* Span<float>{ i }; */\n+\n+\t\tSpan<int>{ a };\n+\t\tSpan<const int>{ a };\n+\t\t/* Span<float>{ a }; */\n+\n+\t\tSpan<const int>{ ca };\n+\t\t/* Span<const float>{ca}; */\n+\t\t/* Span<int>{ca}; */\n+\n+\t\tSpan<int>{ v };\n+\t\tSpan<const int>{ v };\n+\t\t/* Span<float>{ v }; */\n+\n+\t\tSpan<const int>{ v };\n+\t\t/* Span<int>{ v }; */\n+\t\t/* Span<const float>{ v }; */\n+\n+\t\tSpan<int> dynamicSpan{ i };\n+\t\tSpan<int>{ dynamicSpan };\n+\t\tSpan<const int>{ dynamicSpan };\n+\n+\t\tdynamicSpan = Span<int>{ a };\n+\n+\t\tdynamicSpan.begin();\n+\t\tdynamicSpan.cbegin();\n+\t\tdynamicSpan.end();\n+\t\tdynamicSpan.cend();\n+\t\tdynamicSpan.rbegin();\n+\t\tdynamicSpan.crbegin();\n+\t\tdynamicSpan.rend();\n+\t\tdynamicSpan.crend();\n+\n+\t\tdynamicSpan.front();\n+\t\tdynamicSpan.back();\n+\t\tdynamicSpan[0];\n+\t\tdynamicSpan.data();\n+\n+\t\tdynamicSpan.size();\n+\t\tdynamicSpan.size_bytes();\n+\n+\t\tdynamicSpan.empty();\n+\n+\t\tdynamicSpan.first<2>();\n+\t\tdynamicSpan.first(2);\n+\t\t/* dynamicSpan.first<6>(); */\n+\t\t/* dynamicSpan.first(6); */\n+\t\tdynamicSpan.last<2>();\n+\t\tdynamicSpan.last(2);\n+\t\t/* dynamicSpan.last<6>(); */\n+\t\t/* dynamicSpan.last(6); */\n+\t\tdynamicSpan.subspan<1>();\n+\t\tdynamicSpan.subspan<1, 2>();\n+\t\tdynamicSpan.subspan(1);\n+\t\tdynamicSpan.subspan(1, 2);\n+\t\t/* dynamicSpan.subspan(2, 4); */\n+\n+\t\treturn TestPass;\n+\t}\n+};\n+\n+TEST_REGISTER(SpanTest)\n","prefixes":["libcamera-devel","02/31"]}