{"id":1054,"url":"https://patchwork.libcamera.org/api/patches/1054/?format=json","web_url":"https://patchwork.libcamera.org/patch/1054/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/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":"<20190418141437.14014-8-laurent.pinchart@ideasonboard.com>","date":"2019-04-18T14:14:31","name":"[libcamera-devel,v3,07/13] test: geometry: Add tests for Size class comparison operators","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"af3d310118667c5c6138762a8ef1ac28efdc11dc","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/?format=json","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/1054/mbox/","series":[{"id":256,"url":"https://patchwork.libcamera.org/api/series/256/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=256","date":"2019-04-18T14:14:24","name":"Rockchip ISP pipeline handler","version":3,"mbox":"https://patchwork.libcamera.org/series/256/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/1054/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/1054/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 508CB60DC6\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 18 Apr 2019 16:14:57 +0200 (CEST)","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 E60A09A7\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 18 Apr 2019 16:14:56 +0200 (CEST)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1555596897;\n\tbh=cFvDd/CCqAepMcjnOcsvoqbRzt6gHKhXQuEPicQH/eA=;\n\th=From:To:Subject:Date:In-Reply-To:References:From;\n\tb=KTVUPCGsO8AMamXwsxGIxPQ8Rpopx4tUSwpPSItoGkgIuGXQZ6Zf/vODaO1KPqdSi\n\tz91zSICEopaK9qqK/8uog6j1MB8aFMVvTjGDTcO69lBLBsoy3FktgVS22tA/n3/PL7\n\tgG28J5L0GLGG9PBD3Q3BywOKcM4WNzqNWX/nGHlg=","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"libcamera-devel@lists.libcamera.org","Date":"Thu, 18 Apr 2019 17:14:31 +0300","Message-Id":"<20190418141437.14014-8-laurent.pinchart@ideasonboard.com>","X-Mailer":"git-send-email 2.21.0","In-Reply-To":"<20190418141437.14014-1-laurent.pinchart@ideasonboard.com>","References":"<20190418141437.14014-1-laurent.pinchart@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=UTF-8","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH v3 07/13] test: geometry: Add tests for\n\tSize class comparison operators","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.23","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, 18 Apr 2019 14:14:57 -0000"},"content":"Add a test that exercises all the comparison operators for the Size\nclass.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\nReviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\nReviewed-by: Jacopo Mondi <jacopo@jmondi.org>\n---\nChanges since v1:\n\n- Remove the init() and cleanup() methods\n---\n test/geometry.cpp | 116 ++++++++++++++++++++++++++++++++++++++++++++++\n test/meson.build  |   1 +\n 2 files changed, 117 insertions(+)\n create mode 100644 test/geometry.cpp","diff":"diff --git a/test/geometry.cpp b/test/geometry.cpp\nnew file mode 100644\nindex 000000000000..27e65565d7c6\n--- /dev/null\n+++ b/test/geometry.cpp\n@@ -0,0 +1,116 @@\n+/* SPDX-License-Identifier: GPL-2.0-or-later */\n+/*\n+ * Copyright (C) 2019, Google Inc.\n+ *\n+ * geometry.cpp - Geometry classes tests\n+ */\n+\n+#include <iostream>\n+\n+#include <libcamera/geometry.h>\n+\n+#include \"test.h\"\n+\n+using namespace std;\n+using namespace libcamera;\n+\n+class GeometryTest : public Test\n+{\n+protected:\n+\tbool compare(const Size &lhs, const Size &rhs,\n+\t\t     bool (*op)(const Size &lhs, const Size &rhs),\n+\t\t     const char *opName, bool expect)\n+\t{\n+\t\tbool result = op(lhs, rhs);\n+\n+\t\tif (result != expect) {\n+\t\t\tcout << \"Size(\" << lhs.width << \", \" << lhs.height << \") \"\n+\t\t\t     << opName << \" \"\n+\t\t\t     << \"Size(\" << rhs.width << \", \" << rhs.height << \") \"\n+\t\t\t     << \"test failed\" << std::endl;\n+\t\t\treturn false;\n+\t\t}\n+\n+\t\treturn true;\n+\t}\n+\n+\tint run()\n+\t{\n+\t\t/* Test Size equality and inequality. */\n+\t\tif (!compare(Size(100, 100), Size(100, 100), &operator==, \"==\", true))\n+\t\t\treturn TestFail;\n+\t\tif (!compare(Size(100, 100), Size(100, 100), &operator!=, \"!=\", false))\n+\t\t\treturn TestFail;\n+\n+\t\tif (!compare(Size(100, 100), Size(200, 100), &operator==, \"==\", false))\n+\t\t\treturn TestFail;\n+\t\tif (!compare(Size(100, 100), Size(200, 100), &operator!=, \"!=\", true))\n+\t\t\treturn TestFail;\n+\n+\t\tif (!compare(Size(100, 100), Size(100, 200), &operator==, \"==\", false))\n+\t\t\treturn TestFail;\n+\t\tif (!compare(Size(100, 100), Size(100, 200), &operator!=, \"!=\", true))\n+\t\t\treturn TestFail;\n+\n+\t\t/* Test Size ordering based on combined with and height. */\n+\t\tif (!compare(Size(100, 100), Size(200, 200), &operator<, \"<\", true))\n+\t\t\treturn TestFail;\n+\t\tif (!compare(Size(100, 100), Size(200, 200), &operator<=, \"<=\", true))\n+\t\t\treturn TestFail;\n+\t\tif (!compare(Size(100, 100), Size(200, 200), &operator>, \">\", false))\n+\t\t\treturn TestFail;\n+\t\tif (!compare(Size(100, 100), Size(200, 200), &operator>=, \">=\", false))\n+\t\t\treturn TestFail;\n+\n+\t\tif (!compare(Size(200, 200), Size(100, 100), &operator<, \"<\", false))\n+\t\t\treturn TestFail;\n+\t\tif (!compare(Size(200, 200), Size(100, 100), &operator<=, \"<=\", false))\n+\t\t\treturn TestFail;\n+\t\tif (!compare(Size(200, 200), Size(100, 100), &operator>, \">\", true))\n+\t\t\treturn TestFail;\n+\t\tif (!compare(Size(200, 200), Size(100, 100), &operator>=, \">=\", true))\n+\t\t\treturn TestFail;\n+\n+\t\t/* Test Size ordering based on area (with overlapping sizes). */\n+\t\tif (!compare(Size(200, 100), Size(100, 400), &operator<, \"<\", true))\n+\t\t\treturn TestFail;\n+\t\tif (!compare(Size(200, 100), Size(100, 400), &operator<=, \"<=\", true))\n+\t\t\treturn TestFail;\n+\t\tif (!compare(Size(200, 100), Size(100, 400), &operator>, \">\", false))\n+\t\t\treturn TestFail;\n+\t\tif (!compare(Size(200, 100), Size(100, 400), &operator>=, \">=\", false))\n+\t\t\treturn TestFail;\n+\n+\t\tif (!compare(Size(100, 400), Size(200, 100), &operator<, \"<\", false))\n+\t\t\treturn TestFail;\n+\t\tif (!compare(Size(100, 400), Size(200, 100), &operator<=, \"<=\", false))\n+\t\t\treturn TestFail;\n+\t\tif (!compare(Size(100, 400), Size(200, 100), &operator>, \">\", true))\n+\t\t\treturn TestFail;\n+\t\tif (!compare(Size(100, 400), Size(200, 100), &operator>=, \">=\", true))\n+\t\t\treturn TestFail;\n+\n+\t\t/* Test Size ordering based on width (with identical areas). */\n+\t\tif (!compare(Size(100, 200), Size(200, 100), &operator<, \"<\", true))\n+\t\t\treturn TestFail;\n+\t\tif (!compare(Size(100, 200), Size(200, 100), &operator<=, \"<=\", true))\n+\t\t\treturn TestFail;\n+\t\tif (!compare(Size(100, 200), Size(200, 100), &operator>, \">\", false))\n+\t\t\treturn TestFail;\n+\t\tif (!compare(Size(100, 200), Size(200, 100), &operator>=, \">=\", false))\n+\t\t\treturn TestFail;\n+\n+\t\tif (!compare(Size(200, 100), Size(100, 200), &operator<, \"<\", false))\n+\t\t\treturn TestFail;\n+\t\tif (!compare(Size(200, 100), Size(100, 200), &operator<=, \"<=\", false))\n+\t\t\treturn TestFail;\n+\t\tif (!compare(Size(200, 100), Size(100, 200), &operator>, \">\", true))\n+\t\t\treturn TestFail;\n+\t\tif (!compare(Size(200, 100), Size(100, 200), &operator>=, \">=\", true))\n+\t\t\treturn TestFail;\n+\n+\t\treturn TestPass;\n+\t}\n+};\n+\n+TEST_REGISTER(GeometryTest)\ndiff --git a/test/meson.build b/test/meson.build\nindex 71a96921697c..d501f2beaf96 100644\n--- a/test/meson.build\n+++ b/test/meson.build\n@@ -9,6 +9,7 @@ subdir('v4l2_subdevice')\n public_tests = [\n     ['event',                           'event.cpp'],\n     ['event-dispatcher',                'event-dispatcher.cpp'],\n+    ['geometry',                        'geometry.cpp'],\n     ['list-cameras',                    'list-cameras.cpp'],\n     ['signal',                          'signal.cpp'],\n     ['timer',                           'timer.cpp'],\n","prefixes":["libcamera-devel","v3","07/13"]}