[{"id":1366,"web_url":"https://patchwork.libcamera.org/comment/1366/","msgid":"<20190415205823.GX1980@bigcity.dyn.berto.se>","date":"2019-04-15T20:58:23","subject":"Re: [libcamera-devel] [PATCH 07/11] test: geometry: Add tests for\n\tSize class comparison operators","submitter":{"id":5,"url":"https://patchwork.libcamera.org/api/people/5/","name":"Niklas Söderlund","email":"niklas.soderlund@ragnatech.se"},"content":"Hi Laurent,\n\nThanks for your test code,\n\nOn 2019-04-15 19:56:56 +0300, Laurent Pinchart wrote:\n> Add a test that exercises all the comparison operators for the Size\n> class.\n> \n> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\nReviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n\n> ---\n>  test/geometry.cpp | 125 ++++++++++++++++++++++++++++++++++++++++++++++\n>  test/meson.build  |   1 +\n>  2 files changed, 126 insertions(+)\n>  create mode 100644 test/geometry.cpp\n> \n> diff --git a/test/geometry.cpp b/test/geometry.cpp\n> new file mode 100644\n> index 000000000000..7ba3f72ed71d\n> --- /dev/null\n> +++ b/test/geometry.cpp\n> @@ -0,0 +1,125 @@\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> +\tint init()\n> +\t{\n> +\t\treturn 0;\n> +\t}\n> +\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> +\tvoid cleanup()\n> +\t{\n> +\t}\n> +};\n> +\n> +TEST_REGISTER(GeometryTest)\n> diff --git a/test/meson.build b/test/meson.build\n> index 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> -- \n> Regards,\n> \n> Laurent Pinchart\n> \n> _______________________________________________\n> libcamera-devel mailing list\n> libcamera-devel@lists.libcamera.org\n> https://lists.libcamera.org/listinfo/libcamera-devel","headers":{"Return-Path":"<niklas.soderlund@ragnatech.se>","Received":["from mail-lj1-x22f.google.com (mail-lj1-x22f.google.com\n\t[IPv6:2a00:1450:4864:20::22f])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 7738360B2E\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 15 Apr 2019 22:58:25 +0200 (CEST)","by mail-lj1-x22f.google.com with SMTP id r24so17060934ljg.3\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 15 Apr 2019 13:58:25 -0700 (PDT)","from localhost (89-233-230-99.cust.bredband2.com. [89.233.230.99])\n\tby smtp.gmail.com with ESMTPSA id\n\to3sm10171983lfd.53.2019.04.15.13.58.24\n\t(version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256);\n\tMon, 15 Apr 2019 13:58:24 -0700 (PDT)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=ragnatech-se.20150623.gappssmtp.com; s=20150623;\n\th=date:from:to:cc:subject:message-id:references:mime-version\n\t:content-disposition:content-transfer-encoding:in-reply-to\n\t:user-agent; bh=FXe6iFG8VgeBQvM0lf3qpPffN6ByyeNh4u3S90Qxy50=;\n\tb=XR6Z4c0j/c4R2qLZjFaQcBc3iqHdT1iq/LJ1tw0LX/iYHfWxS6EEEaM8KATjOy186t\n\t8zTKjg6risOifET9TTQ4sz3tsQVznj2gTgX/xnP5KSVpIZaqu6Pv59aBuzXAXQdhx1UY\n\tY5TU0tauDBUegyokoEJVqZ4t3GMsC8Xsz/lKn1MYlLRLjh5Igea+I73OWeTcekCRy1gZ\n\tU9wMmasrNn8JInxvIUmkqwNLBgRZUhxwHX5VzYHE4rcU2e2RG1awJDt9cw+d/2k0ZSFS\n\tk5nTPi7RN93jqPmonvgOscJrPSjg0ErL/P9u2fke9324v5AisStTYuJxyAPYnKpSDAXS\n\tHWnQ==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:date:from:to:cc:subject:message-id:references\n\t:mime-version:content-disposition:content-transfer-encoding\n\t:in-reply-to:user-agent;\n\tbh=FXe6iFG8VgeBQvM0lf3qpPffN6ByyeNh4u3S90Qxy50=;\n\tb=nZUefN2JGNvFoOIRmjRvvP7jCWSnK3sQRVnrYiA82QlDQ2yUif3g86VHqkFPIrZPcZ\n\teiOlurnyU37AqNfTfbFLoDeMR1k8GxBPKbm4JdmDhDvJSUgWFKF/SJiywLHq7/mFNBMM\n\tI5B0h5xjPyrKi+FGe6HeQFHX1IgceskwGMUdb7uLu4M1UH7R0NlNakhSIQa4KNgYgI49\n\tyKDmMtYVcPnfCVCU2J4Sv8gqh/Y6WYuy52d5NtEgJDfxT4mLJ7T/nDhWV7oyDACaApai\n\tN3WwDVP2DOIrpMGuo5yHfKDVTPsX3bLgvl8mxUJIRte3m2l9Fzo2q+vl7f1s+1w8EIZw\n\tgIcg==","X-Gm-Message-State":"APjAAAWywe+wx2eycSfeqLVOxPvZHwgw8XVLGjvM/txp9qELwsyw2XtA\n\tnoReyrv1yNit2gAMa7wDqd8QuGjog+w=","X-Google-Smtp-Source":"APXvYqyB80AjfVug2Ut6jvaT6avWVp831accyQHYCEtUccPzynV6pnA8Z3X7xOqeJt2x1/hlgKx2Og==","X-Received":"by 2002:a2e:9213:: with SMTP id\n\tk19mr26655098ljg.118.1555361904899; \n\tMon, 15 Apr 2019 13:58:24 -0700 (PDT)","Date":"Mon, 15 Apr 2019 22:58:23 +0200","From":"Niklas =?iso-8859-1?q?S=F6derlund?= <niklas.soderlund@ragnatech.se>","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","Message-ID":"<20190415205823.GX1980@bigcity.dyn.berto.se>","References":"<20190415165700.22970-1-laurent.pinchart@ideasonboard.com>\n\t<20190415165700.22970-8-laurent.pinchart@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=iso-8859-1","Content-Disposition":"inline","Content-Transfer-Encoding":"8bit","In-Reply-To":"<20190415165700.22970-8-laurent.pinchart@ideasonboard.com>","User-Agent":"Mutt/1.11.3 (2019-02-01)","Subject":"Re: [libcamera-devel] [PATCH 07/11] 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":"Mon, 15 Apr 2019 20:58:25 -0000"}},{"id":1393,"web_url":"https://patchwork.libcamera.org/comment/1393/","msgid":"<20190416151914.ebaskxhgp7etacgm@uno.localdomain>","date":"2019-04-16T15:19:14","subject":"Re: [libcamera-devel] [PATCH 07/11] test: geometry: Add tests for\n\tSize class comparison operators","submitter":{"id":3,"url":"https://patchwork.libcamera.org/api/people/3/","name":"Jacopo Mondi","email":"jacopo@jmondi.org"},"content":"Hi Laurent,\n\nOn Mon, Apr 15, 2019 at 07:56:56PM +0300, Laurent Pinchart wrote:\n> Add a test that exercises all the comparison operators for the Size\n> class.\n>\n> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> ---\n>  test/geometry.cpp | 125 ++++++++++++++++++++++++++++++++++++++++++++++\n>  test/meson.build  |   1 +\n>  2 files changed, 126 insertions(+)\n>  create mode 100644 test/geometry.cpp\n>\n> diff --git a/test/geometry.cpp b/test/geometry.cpp\n> new file mode 100644\n> index 000000000000..7ba3f72ed71d\n> --- /dev/null\n> +++ b/test/geometry.cpp\n> @@ -0,0 +1,125 @@\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> +\tint init()\n> +\t{\n> +\t\treturn 0;\n> +\t}\n\nDo you need this?\n\n> +\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> +\tvoid cleanup()\n> +\t{\n> +\t}\n\nthis too?\n\nMinors apart:\nReviewed-by: Jacopo Mondi <jacopo@jmondi.org>\n\nThanks\n  j\n\n> +};\n> +\n> +TEST_REGISTER(GeometryTest)\n> diff --git a/test/meson.build b/test/meson.build\n> index 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> --\n> Regards,\n>\n> Laurent Pinchart\n>\n> _______________________________________________\n> libcamera-devel mailing list\n> libcamera-devel@lists.libcamera.org\n> https://lists.libcamera.org/listinfo/libcamera-devel","headers":{"Return-Path":"<jacopo@jmondi.org>","Received":["from relay8-d.mail.gandi.net (relay8-d.mail.gandi.net\n\t[217.70.183.201])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 13F4260DB4\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 16 Apr 2019 17:18:23 +0200 (CEST)","from uno.localdomain (2-224-242-101.ip172.fastwebnet.it\n\t[2.224.242.101]) (Authenticated sender: jacopo@jmondi.org)\n\tby relay8-d.mail.gandi.net (Postfix) with ESMTPSA id 81A911BF206;\n\tTue, 16 Apr 2019 15:18:22 +0000 (UTC)"],"X-Originating-IP":"2.224.242.101","Date":"Tue, 16 Apr 2019 17:19:14 +0200","From":"Jacopo Mondi <jacopo@jmondi.org>","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","Message-ID":"<20190416151914.ebaskxhgp7etacgm@uno.localdomain>","References":"<20190415165700.22970-1-laurent.pinchart@ideasonboard.com>\n\t<20190415165700.22970-8-laurent.pinchart@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"multipart/signed; micalg=pgp-sha256;\n\tprotocol=\"application/pgp-signature\"; boundary=\"odqi6x32fzdckhen\"","Content-Disposition":"inline","In-Reply-To":"<20190415165700.22970-8-laurent.pinchart@ideasonboard.com>","User-Agent":"NeoMutt/20180716","Subject":"Re: [libcamera-devel] [PATCH 07/11] 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":"Tue, 16 Apr 2019 15:18:23 -0000"}},{"id":1403,"web_url":"https://patchwork.libcamera.org/comment/1403/","msgid":"<20190416201044.GB4822@pendragon.ideasonboard.com>","date":"2019-04-16T20:10:44","subject":"Re: [libcamera-devel] [PATCH 07/11] test: geometry: Add tests for\n\tSize class comparison operators","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Jacopo,\n\nOn Tue, Apr 16, 2019 at 05:19:14PM +0200, Jacopo Mondi wrote:\n> On Mon, Apr 15, 2019 at 07:56:56PM +0300, Laurent Pinchart wrote:\n> > Add a test that exercises all the comparison operators for the Size\n> > class.\n> >\n> > Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> > ---\n> >  test/geometry.cpp | 125 ++++++++++++++++++++++++++++++++++++++++++++++\n> >  test/meson.build  |   1 +\n> >  2 files changed, 126 insertions(+)\n> >  create mode 100644 test/geometry.cpp\n> >\n> > diff --git a/test/geometry.cpp b/test/geometry.cpp\n> > new file mode 100644\n> > index 000000000000..7ba3f72ed71d\n> > --- /dev/null\n> > +++ b/test/geometry.cpp\n> > @@ -0,0 +1,125 @@\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> > +\tint init()\n> > +\t{\n> > +\t\treturn 0;\n> > +\t}\n> \n> Do you need this?\n\nI don't, same for cleanup(). I'll fix that.\n\n> > +\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> > +\tvoid cleanup()\n> > +\t{\n> > +\t}\n> \n> this too?\n> \n> Minors apart:\n> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>\n> \n> > +};\n> > +\n> > +TEST_REGISTER(GeometryTest)\n> > diff --git a/test/meson.build b/test/meson.build\n> > index 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'],","headers":{"Return-Path":"<laurent.pinchart@ideasonboard.com>","Received":["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 5C1B660004\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 16 Apr 2019 22:10:53 +0200 (CEST)","from pendragon.ideasonboard.com\n\t(dfj612yhrgyx302h3jwwy-3.rev.dnainternet.fi\n\t[IPv6:2001:14ba:21f5:5b00:ce28:277f:58d7:3ca4])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id B0C47E2;\n\tTue, 16 Apr 2019 22:10:52 +0200 (CEST)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1555445452;\n\tbh=KOQFgpOBElh/bauiZZ64wRB1hQ039i2mzP3u7DQ+6RU=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=XSdkFI07mu+GXCJPN4WO27MP2w+40V1TZQC4a8m8gEnt9AC7Zr0IJ7iZbhqR8bu4g\n\tbxUrIgjn8cTsRbIwWPV8fa+BgGyQLCB1eFxXp8jf1JsfBSO+VsfvSazz2DseaCmTan\n\tk6Q7dIWKi+OqCdeyhjuxStJigdu5IGn9/63yC7Os=","Date":"Tue, 16 Apr 2019 23:10:44 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Jacopo Mondi <jacopo@jmondi.org>","Cc":"libcamera-devel@lists.libcamera.org","Message-ID":"<20190416201044.GB4822@pendragon.ideasonboard.com>","References":"<20190415165700.22970-1-laurent.pinchart@ideasonboard.com>\n\t<20190415165700.22970-8-laurent.pinchart@ideasonboard.com>\n\t<20190416151914.ebaskxhgp7etacgm@uno.localdomain>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20190416151914.ebaskxhgp7etacgm@uno.localdomain>","User-Agent":"Mutt/1.10.1 (2018-07-13)","Subject":"Re: [libcamera-devel] [PATCH 07/11] 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":"Tue, 16 Apr 2019 20:10:53 -0000"}}]